public void ValidateDefault() { UOMViewModel viewModel = new UOMViewModel(); var result = viewModel.Validate(null); Assert.True(result.Count() > 0); }
public ActionResult Details(UOMViewModel uomDetails) { IEnumerable <UOM> lstUOM = null; if (!string.IsNullOrEmpty(uomDetails.UOMName)) { lstUOM = UOMService.FindBy(p => p.UOMName == uomDetails.UOMName); } else { uomDetails.ToDate = new DateTime(uomDetails.ToDate.Year, uomDetails.ToDate.Month, uomDetails.ToDate.Day, 23, 59, 59); if (uomDetails.ToDate.Year >= 1900 && uomDetails.FromDate.Year >= 1900) { lstUOM = UOMService.FindBy(p => p.CreatedDate >= uomDetails.FromDate && p.CreatedDate <= uomDetails.ToDate); } else if (uomDetails.ToDate.Year >= 1900 && uomDetails.FromDate.Year <= 1900) { lstUOM = UOMService.FindBy(p => p.CreatedDate >= DateTime.MinValue && p.CreatedDate <= uomDetails.ToDate); } else if (uomDetails.ToDate.Year <= 1900 && uomDetails.FromDate.Year >= 1900) { lstUOM = UOMService.FindBy(p => p.CreatedDate >= uomDetails.FromDate && p.CreatedDate <= DateTime.MaxValue); } else { lstUOM = UOMService.FindBy(p => p.CreatedDate >= DateTime.MinValue && p.CreatedDate <= DateTime.MaxValue); } } uomDetails.lstUOM = lstUOM; return(View(uomDetails)); }
public UOM MapToModel(UOMViewModel viewModel) { UOM model = new UOM(); PropertyCopier <UOMViewModel, UOM> .Copy(viewModel, model); return(model); }
public UOMViewModel MapToViewModel(UOM model) { UOMViewModel viewModel = new UOMViewModel(); PropertyCopier <UOM, UOMViewModel> .Copy(model, viewModel); return(viewModel); }
public void should_Success_Instantiate() { UOMViewModel viewModel = new UOMViewModel() { code = "code" }; Assert.Equal("code", viewModel.code); }
public CostCalculationGarmentViewModel MapToViewModel(CostCalculationGarment model) { CostCalculationGarmentViewModel viewModel = new CostCalculationGarmentViewModel(); PropertyCopier <CostCalculationGarment, CostCalculationGarmentViewModel> .Copy(model, viewModel); viewModel.Convection = model.Convection; viewModel.AutoIncrementNumber = model.AutoIncrementNumber; viewModel.FabricAllowance = Percentage.ToPercent(model.FabricAllowance); viewModel.AccessoriesAllowance = Percentage.ToPercent(model.AccessoriesAllowance); viewModel.SizeRange = model.SizeRange; viewModel.Buyer = new BuyerViewModel(); viewModel.Buyer._id = model.BuyerId; viewModel.Buyer.name = model.BuyerName; viewModel.Efficiency = new EfficiencyViewModel(); viewModel.Efficiency.Id = model.EfficiencyId; viewModel.Efficiency.Value = Percentage.ToPercent(model.EfficiencyValue); viewModel.UOM = new UOMViewModel() { _id = model.UOMID, code = model.UOMCode, unit = model.UOMUnit }; viewModel.Wage = new RateViewModel(); viewModel.Wage.Id = model.WageId; viewModel.Wage.Value = model.WageRate; viewModel.THR = new RateViewModel(); viewModel.THR.Id = model.THRId; viewModel.THR.Value = model.THRRate; viewModel.Rate = new RateViewModel(); viewModel.Rate.Id = model.RateId; viewModel.Rate.Value = model.RateValue; viewModel.Commodity = new MasterPlanComodityViewModel(); viewModel.Commodity.name = model.Commodity; viewModel.Commodity._id = model.ComodityID; viewModel.CommodityDescription = model.CommodityDescription; viewModel.CostCalculationGarment_Materials = new List <CostCalculationGarment_MaterialViewModel>(); if (model.CostCalculationGarment_Materials != null) { foreach (CostCalculationGarment_Material CostCalculationGarment_Material in model.CostCalculationGarment_Materials) { CostCalculationGarment_MaterialViewModel CostCalculationGarment_MaterialVM = new CostCalculationGarment_MaterialViewModel(); PropertyCopier <CostCalculationGarment_Material, CostCalculationGarment_MaterialViewModel> .Copy(CostCalculationGarment_Material, CostCalculationGarment_MaterialVM); CostCalculationGarment_Material.Convection = model.Convection; CategoryViewModel categoryVM = new CategoryViewModel() { _id = CostCalculationGarment_Material.CategoryId }; string[] names = CostCalculationGarment_Material.CategoryName.Split(new[] { " - " }, StringSplitOptions.None); categoryVM.name = names[0]; try { categoryVM.SubCategory = names[1]; } catch (IndexOutOfRangeException) { categoryVM.SubCategory = null; } CostCalculationGarment_MaterialVM.Category = categoryVM; //CostCalculationGarment_Material.ProductId = new GarmentProductViewModel(); UOMViewModel uomQuantityVM = new UOMViewModel() { _id = CostCalculationGarment_Material.UOMQuantityId, unit = CostCalculationGarment_Material.UOMQuantityName }; CostCalculationGarment_MaterialVM.UOMQuantity = uomQuantityVM; UOMViewModel uomPriceVM = new UOMViewModel() { _id = CostCalculationGarment_Material.UOMPriceId, unit = CostCalculationGarment_Material.UOMPriceName }; CostCalculationGarment_MaterialVM.UOMPrice = uomPriceVM; CostCalculationGarment_MaterialVM.ShippingFeePortion = Percentage.ToPercent(CostCalculationGarment_Material.ShippingFeePortion); CostCalculationGarment_MaterialVM.Product = new GarmentProductViewModel { _id = CostCalculationGarment_Material.ProductId, code = CostCalculationGarment_Material.ProductCode, composition = CostCalculationGarment_Material.Composition, construction = CostCalculationGarment_Material.Construction, yarn = CostCalculationGarment_Material.Yarn, width = CostCalculationGarment_Material.Width }; //CostCalculationGarment_MaterialVM.PO_SerialNumber = viewModel.CostCalculationGarment_Materials.Add(CostCalculationGarment_MaterialVM); } } viewModel.CommissionPortion = Percentage.ToPercent(model.CommissionPortion); viewModel.Risk = Percentage.ToPercent(model.Risk); viewModel.OTL1 = new RateCalculatedViewModel(); viewModel.OTL1.Id = model.OTL1Id; viewModel.OTL1.Value = model.OTL1Rate; viewModel.OTL1.CalculatedValue = model.OTL1CalculatedRate; viewModel.OTL2 = new RateCalculatedViewModel(); viewModel.OTL2.Id = model.OTL2Id; viewModel.OTL2.Value = model.OTL2Rate; viewModel.OTL2.CalculatedValue = model.OTL2CalculatedRate; viewModel.NETFOBP = Percentage.ToPercent((double)model.NETFOBP); return(viewModel); }
public CostCalculationGarmentViewModel MapToViewModel(CostCalculationGarment model) { CostCalculationGarmentViewModel viewModel = new CostCalculationGarmentViewModel(); PropertyCopier <CostCalculationGarment, CostCalculationGarmentViewModel> .Copy(model, viewModel); viewModel.Line = new LineViewModel(); viewModel.Line.Id = model.LineId; viewModel.Line.Name = model.LineName; viewModel.FabricAllowance = Percentage.ToPercent(model.FabricAllowance); viewModel.AccessoriesAllowance = Percentage.ToPercent(model.AccessoriesAllowance); viewModel.SizeRange = new SizeRangeViewModel(); viewModel.SizeRange.Id = model.SizeRangeId; viewModel.SizeRange.Name = model.SizeRangeName; viewModel.Buyer = new BuyerViewModel(); viewModel.Buyer.Id = model.BuyerId; viewModel.Buyer.Name = model.BuyerName; viewModel.Efficiency = new EfficiencyViewModel(); viewModel.Efficiency.Id = model.EfficiencyId; viewModel.Efficiency.Value = Percentage.ToPercent(model.EfficiencyValue); viewModel.Wage = new RateViewModel(); viewModel.Wage.Id = model.WageId; viewModel.Wage.Value = model.WageRate; viewModel.THR = new RateViewModel(); viewModel.THR.Id = model.THRId; viewModel.THR.Value = model.THRRate; viewModel.Rate = new RateViewModel(); viewModel.Rate.Id = model.RateId; viewModel.Rate.Value = model.RateValue; viewModel.CostCalculationGarment_Materials = new List <CostCalculationGarment_MaterialViewModel>(); if (model.CostCalculationGarment_Materials != null) { foreach (CostCalculationGarment_Material CostCalculationGarment_Material in model.CostCalculationGarment_Materials) { CostCalculationGarment_MaterialViewModel CostCalculationGarment_MaterialVM = new CostCalculationGarment_MaterialViewModel(); PropertyCopier <CostCalculationGarment_Material, CostCalculationGarment_MaterialViewModel> .Copy(CostCalculationGarment_Material, CostCalculationGarment_MaterialVM); CategoryViewModel categoryVM = new CategoryViewModel() { Id = CostCalculationGarment_Material.CategoryId }; string[] names = CostCalculationGarment_Material.CategoryName.Split(new[] { " - " }, StringSplitOptions.None); categoryVM.Name = names[0]; try { categoryVM.SubCategory = names[1]; } catch (IndexOutOfRangeException) { categoryVM.SubCategory = null; } CostCalculationGarment_MaterialVM.Category = categoryVM; MaterialViewModel materialVM = new MaterialViewModel() { Id = CostCalculationGarment_Material.MaterialId, Name = CostCalculationGarment_Material.MaterialName }; CostCalculationGarment_MaterialVM.Material = materialVM; UOMViewModel uomQuantityVM = new UOMViewModel() { Id = CostCalculationGarment_Material.UOMQuantityId, Name = CostCalculationGarment_Material.UOMQuantityName }; CostCalculationGarment_MaterialVM.UOMQuantity = uomQuantityVM; UOMViewModel uomPriceVM = new UOMViewModel() { Id = CostCalculationGarment_Material.UOMPriceId, Name = CostCalculationGarment_Material.UOMPriceName }; CostCalculationGarment_MaterialVM.UOMPrice = uomPriceVM; CostCalculationGarment_MaterialVM.ShippingFeePortion = Percentage.ToPercent(CostCalculationGarment_Material.ShippingFeePortion); viewModel.CostCalculationGarment_Materials.Add(CostCalculationGarment_MaterialVM); } } viewModel.CommissionPortion = Percentage.ToPercent(model.CommissionPortion); viewModel.Risk = Percentage.ToPercent(model.Risk); viewModel.OTL1 = new RateCalculatedViewModel(); viewModel.OTL1.Id = model.OTL1Id; viewModel.OTL1.Value = model.OTL1Rate; viewModel.OTL1.CalculatedValue = model.OTL1CalculatedRate; viewModel.OTL2 = new RateCalculatedViewModel(); viewModel.OTL2.Id = model.OTL2Id; viewModel.OTL2.Value = model.OTL2Rate; viewModel.OTL2.CalculatedValue = model.OTL2CalculatedRate; viewModel.NETFOBP = Percentage.ToPercent((double)model.NETFOBP); return(viewModel); }
public CostCalculationRetailViewModel MapToViewModel(CostCalculationRetail model) { CostCalculationRetailViewModel viewModel = new CostCalculationRetailViewModel(); PropertyCopier <CostCalculationRetail, CostCalculationRetailViewModel> .Copy(model, viewModel); viewModel.Style = new ArticleStyleViewModel(); viewModel.Style._id = model.StyleId; viewModel.Style.name = model.StyleName; viewModel.Season = new ArticleSeasonViewModel(); viewModel.Season._id = model.SeasonId; viewModel.Season.name = model.SeasonName; viewModel.Buyer = new BuyerViewModel(); viewModel.Buyer.Id = model.BuyerId; viewModel.Buyer.Name = model.BuyerName; viewModel.SizeRange = new SizeRangeViewModel(); viewModel.SizeRange.Id = model.SizeRangeId; viewModel.SizeRange.Name = model.SizeRangeName; viewModel.FabricAllowance = Percentage.ToPercent(model.FabricAllowance); viewModel.AccessoriesAllowance = Percentage.ToPercent(model.AccessoriesAllowance); try { // Get Related Size of particular Size Range if possible viewModel.SizeRange.RelatedSizes = new List <RelatedSizeViewModel>(); Task <SizeRange> sizeRange = this.SizeRangeService.ReadModelById(model.SizeRangeId); sizeRange.Wait(); foreach (RelatedSize rs in sizeRange.Result.RelatedSizes) { RelatedSizeViewModel relatedSizeVM = new RelatedSizeViewModel(); PropertyCopier <RelatedSize, RelatedSizeViewModel> .Copy(rs, relatedSizeVM); SizeViewModel sizeVM = new SizeViewModel(); PropertyCopier <Size, SizeViewModel> .Copy(rs.Size, sizeVM); relatedSizeVM.Size = sizeVM; viewModel.SizeRange.RelatedSizes.Add(relatedSizeVM); } } catch (Exception) { // If cannot get Related Size, do nothing } viewModel.Counter = new ArticleCounterViewModel(); viewModel.Counter._id = model.CounterId; viewModel.Counter.name = model.CounterName; viewModel.Efficiency = new EfficiencyViewModel(); viewModel.Efficiency.Id = model.EfficiencyId; viewModel.Efficiency.Value = model.EfficiencyValue; viewModel.Risk = Percentage.ToPercent(model.Risk); viewModel.OL = new RateCalculatedViewModel(); viewModel.OL.Id = model.OLId; viewModel.OL.Value = model.OLRate; viewModel.OL.CalculatedValue = model.OLCalculatedRate; viewModel.OTL1 = new RateCalculatedViewModel(); viewModel.OTL1.Id = model.OTL1Id; viewModel.OTL1.Value = model.OTL1Rate; viewModel.OTL1.CalculatedValue = model.OTL1CalculatedRate; viewModel.OTL2 = new RateCalculatedViewModel(); viewModel.OTL2.Id = model.OTL2Id; viewModel.OTL2.Value = model.OTL2Rate; viewModel.OTL2.CalculatedValue = model.OTL2CalculatedRate; viewModel.OTL3 = new RateCalculatedViewModel(); viewModel.OTL3.Id = model.OTL3Id; viewModel.OTL3.Value = model.OTL3Rate; viewModel.OTL3.CalculatedValue = model.OTL3CalculatedRate; viewModel.CostCalculationRetail_Materials = new List <CostCalculationRetail_MaterialViewModel>(); if (model.CostCalculationRetail_Materials != null) { foreach (CostCalculationRetail_Material costCalculationRetail_Material in model.CostCalculationRetail_Materials) { CostCalculationRetail_MaterialViewModel costCalculationRetail_MaterialVM = new CostCalculationRetail_MaterialViewModel(); PropertyCopier <CostCalculationRetail_Material, CostCalculationRetail_MaterialViewModel> .Copy(costCalculationRetail_Material, costCalculationRetail_MaterialVM); CategoryViewModel categoryVM = new CategoryViewModel() { Id = costCalculationRetail_Material.CategoryId }; string[] names = costCalculationRetail_Material.CategoryName.Split(new[] { " - " }, StringSplitOptions.None); categoryVM.Name = names[0]; try { categoryVM.SubCategory = names[1]; } catch (IndexOutOfRangeException) { categoryVM.SubCategory = null; } costCalculationRetail_MaterialVM.Category = categoryVM; MaterialViewModel materialVM = new MaterialViewModel() { Id = costCalculationRetail_Material.MaterialId, Name = costCalculationRetail_Material.MaterialName }; costCalculationRetail_MaterialVM.Material = materialVM; UOMViewModel uomQuantityVM = new UOMViewModel() { Id = costCalculationRetail_Material.UOMQuantityId, Name = costCalculationRetail_Material.UOMQuantityName }; costCalculationRetail_MaterialVM.UOMQuantity = uomQuantityVM; UOMViewModel uomPriceVM = new UOMViewModel() { Id = costCalculationRetail_Material.UOMPriceId, Name = costCalculationRetail_Material.UOMPriceName }; costCalculationRetail_MaterialVM.UOMPrice = uomPriceVM; viewModel.CostCalculationRetail_Materials.Add(costCalculationRetail_MaterialVM); } } return(viewModel); }