//
//  WSStyleView.swift
//  iPOS
//
//  Created by bbc on 24/11/16.
//  Copyright © 2016 BBC. All rights reserved.
//

import Foundation
import ObjectMapper

class WSStyleView: Mappable {
    var StoreId: Int
    var StyleId: Int!
    var Barcode: String?
    var ProductId: String
    var ProductName: String
    var ColorId: Int?
    var ColorName: String?
    var SizeId: Int?
    var SizeCode: String?
    var AvailableStockQuantity: Int?
    var SalePrice: Double?
    var Discount: Double?
    var StyleAttributeId: Int?
    var StyleAttributeName: String?
    var ColorGroupId: Int?
    var ColorGroupName: String?
    
    var styleBarcodes: [StyleBarcode] = [StyleBarcode]()
    var shouldReloadStyleBarcode:Bool = true

    func mapping(map: Map) {
        StoreId <- map["StoreId"]
        StyleId <- map["StyleId"]
        Barcode <- map["Barcode"]
        ProductId <- map["ProductId"]
        ProductName <- map["ProductName"]
        ColorId <- map["ColorId"]
        ColorName <- map["ColorName"]
        SizeId <- map["SizeId"]
        SizeCode <- map["SizeCode"]
        AvailableStockQuantity <- map["AvailableStockQuantity"]
        SalePrice <- (map["SalePrice"], Util.CustomDoubleTransform())
        Discount <- (map["Discount"], Util.CustomDoubleTransform())
        StyleAttributeId <- map["StyleAttributeId"]
        StyleAttributeName <- map["StyleAttributeName"]
        ColorGroupId <- map["ColorGroupId"]
        ColorGroupName <- map["ColorGroupName"]
    }
    
    required init?(map: Map) {
        ProductId = ""
        ProductName = ""
        StoreId = Int(settings.StoreId)!
        StyleId = 0
    }
    
    init() {
        ProductId = ""
        ProductName = ""
        StoreId = Int(settings.StoreId)!
        StyleId = 0
    }
    
    func clone() -> WSStyleView {
        let clone  = WSStyleView()
        clone.StoreId = self.StoreId
        clone.StyleId = self.StyleId
        clone.Barcode = self.Barcode
        clone.ProductId = self.ProductId
        clone.ProductName = self.ProductName
        clone.ColorId = self.ColorId
        clone.ColorName = self.ColorName
        clone.SizeId = self.SizeId
        clone.SizeCode = self.SizeCode
        clone.AvailableStockQuantity = self.AvailableStockQuantity
        clone.SalePrice = self.SalePrice
        clone.Discount = self.Discount
        clone.StyleAttributeId = self.StyleAttributeId
        clone.StyleAttributeName = self.StyleAttributeName
        clone.ColorGroupId = self.ColorGroupId
        clone.ColorGroupName = self.ColorGroupName
        
        clone.styleBarcodes = self.styleBarcodes
        clone.shouldReloadStyleBarcode = self.shouldReloadStyleBarcode
        
        return clone
    }
}
