public List <GarmentLeftoverWarehouseReceiptAccessoryItem> getProductForPDF(GarmentLeftoverWarehouseExpenditureAccessories model)
        {
            List <GarmentLeftoverWarehouseReceiptAccessoryItem> garmentProducts = new List <GarmentLeftoverWarehouseReceiptAccessoryItem>();

            foreach (var item in model.Items)
            {
                var stock = DbContext.GarmentLeftoverWarehouseReceiptAccessoryItems.Where(a => a.POSerialNumber == item.PONo && a.ProductId == item.ProductId).FirstOrDefault();
                if (stock != null)
                {
                    garmentProducts.Add(stock);
                }
                else
                {
                    var balance = DbContext.GarmentLeftoverWarehouseBalanceStocksItems.Where(a => a.PONo == item.PONo && a.ProductId == item.ProductId).FirstOrDefault();
                    if (balance != null)
                    {
                        GarmentLeftoverWarehouseReceiptAccessoryItem garmentLeftoverWarehouseReceiptAccessoryItem = new GarmentLeftoverWarehouseReceiptAccessoryItem
                        {
                            ProductRemark = balance.ProductRemark,
                            ProductId     = balance.ProductId
                        };
                        garmentProducts.Add(garmentLeftoverWarehouseReceiptAccessoryItem);
                    }
                }
            }
            return(garmentProducts);
        }
        public GarmentLeftoverWarehouseReceiptAccessory CopyData(GarmentLeftoverWarehouseReceiptAccessory oldData)
        {
            GarmentLeftoverWarehouseReceiptAccessory newData = new GarmentLeftoverWarehouseReceiptAccessory();

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

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

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

                newData.Items.Add(newItem);
            }

            return(newData);
        }
        public GarmentLeftoverWarehouseReceiptAccessory MapToModel(GarmentLeftoverWarehouseReceiptAccessoriesViewModel viewModel)
        {
            GarmentLeftoverWarehouseReceiptAccessory model = new GarmentLeftoverWarehouseReceiptAccessory();

            PropertyCopier <GarmentLeftoverWarehouseReceiptAccessoriesViewModel, GarmentLeftoverWarehouseReceiptAccessory> .Copy(viewModel, model);

            if (viewModel.RequestUnit != null)
            {
                model.RequestUnitId   = long.Parse(viewModel.RequestUnit.Id);
                model.RequestUnitCode = viewModel.RequestUnit.Code;
                model.RequestUnitName = viewModel.RequestUnit.Name;
            }

            if (viewModel.Storage != null)
            {
                model.StorageFromId   = long.Parse(viewModel.Storage._id);
                model.StorageFromCode = viewModel.Storage.code;
                model.StorageFromName = viewModel.Storage.name;
            }

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

                if (viewModelItem.Product != null)
                {
                    modelItem.ProductId   = long.Parse(viewModelItem.Product.Id);
                    modelItem.ProductCode = viewModelItem.Product.Code;
                    modelItem.ProductName = viewModelItem.Product.Name;
                }

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

                model.Items.Add(modelItem);
            }

            return(model);
        }