Beispiel #1
0
        public GarmentLeftoverWarehouseReceiptFinishedGood MapToModel(GarmentLeftoverWarehouseReceiptFinishedGoodViewModel viewModel)
        {
            GarmentLeftoverWarehouseReceiptFinishedGood model = new GarmentLeftoverWarehouseReceiptFinishedGood();

            PropertyCopier <GarmentLeftoverWarehouseReceiptFinishedGoodViewModel, GarmentLeftoverWarehouseReceiptFinishedGood> .Copy(viewModel, model);

            if (viewModel.UnitFrom != null)
            {
                model.UnitFromId   = long.Parse(viewModel.UnitFrom.Id);
                model.UnitFromCode = viewModel.UnitFrom.Code;
                model.UnitFromName = viewModel.UnitFrom.Name;
            }

            model.Items = new List <GarmentLeftoverWarehouseReceiptFinishedGoodItem>();
            foreach (var viewModelItem in viewModel.Items)
            {
                GarmentLeftoverWarehouseReceiptFinishedGoodItem modelItem = new GarmentLeftoverWarehouseReceiptFinishedGoodItem();
                PropertyCopier <GarmentLeftoverWarehouseReceiptFinishedGoodItemViewModel, GarmentLeftoverWarehouseReceiptFinishedGoodItem> .Copy(viewModelItem, modelItem);

                if (viewModelItem.Size != null)
                {
                    modelItem.SizeId   = viewModelItem.Size.Id;
                    modelItem.SizeName = viewModelItem.Size.Name;
                }

                if (viewModelItem.Uom != null)
                {
                    modelItem.UomId   = long.Parse(viewModelItem.Uom.Id);
                    modelItem.UomUnit = viewModelItem.Uom.Unit;
                }

                if (viewModelItem.LeftoverComodity != null)
                {
                    modelItem.LeftoverComodityCode = viewModelItem.LeftoverComodity.Code;
                    modelItem.LeftoverComodityId   = viewModelItem.LeftoverComodity.Id;
                    modelItem.LeftoverComodityName = viewModelItem.LeftoverComodity.Name;
                }

                if (viewModelItem.Buyer != null)
                {
                    modelItem.BuyerId   = viewModelItem.Buyer.Id;
                    modelItem.BuyerCode = viewModelItem.Buyer.Code;
                    modelItem.BuyerName = viewModelItem.Buyer.Name;
                }

                if (viewModelItem.Comodity != null)
                {
                    modelItem.ComodityId   = viewModelItem.Comodity.Id;
                    modelItem.ComodityCode = viewModelItem.Comodity.Code;
                    modelItem.ComodityName = viewModelItem.Comodity.Name;
                }

                model.Items.Add(modelItem);
            }

            return(model);
        }
        public GarmentLeftoverWarehouseReceiptFinishedGood CopyData(GarmentLeftoverWarehouseReceiptFinishedGood oldData)
        {
            GarmentLeftoverWarehouseReceiptFinishedGood newData = new GarmentLeftoverWarehouseReceiptFinishedGood();

            PropertyCopier <GarmentLeftoverWarehouseReceiptFinishedGood, GarmentLeftoverWarehouseReceiptFinishedGood> .Copy(oldData, newData);

            newData.Items = new List <GarmentLeftoverWarehouseReceiptFinishedGoodItem>();
            foreach (var oldItem in oldData.Items)
            {
                GarmentLeftoverWarehouseReceiptFinishedGoodItem newItem = new GarmentLeftoverWarehouseReceiptFinishedGoodItem();

                PropertyCopier <GarmentLeftoverWarehouseReceiptFinishedGoodItem, GarmentLeftoverWarehouseReceiptFinishedGoodItem> .Copy(oldItem, newItem);

                newData.Items.Add(newItem);
            }

            return(newData);
        }