public ProductDetailModels GetDetail(string Id) { try { var model = _factory.GetDetail(Id); model.CategoryId = model.ListCategory.Select(x => x.CategoryID).FirstOrDefault(); model.ImageURL = string.IsNullOrEmpty(model.ImageURL) ? Commons.Image100_100 : model.ImageURL; model.CategoryName = model.ListCategory.Select(x => x.CategoryName).FirstOrDefault(); if (model.ListComposite == null) { model.ListComposite = new List <ProductCompositeModels>(); } if (model.ListPrice == null) { model.ListPrice = new List <ProductPriceModels>(); model.ListPriceExtend = new List <ProductPriceModels>(); } else { var _ListPrice = model.ListPrice.Where(x => !x.IsExtend).ToList(); var _ListPriceExtend = model.ListPrice.Where(x => x.IsExtend).ToList(); model.ListPrice = _ListPrice; model.ListPriceExtend = _ListPriceExtend; } if (model.ListFunction != null) { model.ListFunction.Where(x => x.IsDefault).ToList().ForEach(x => x.IsSelected = true); } return(model); }catch (Exception ex) { NSLog.Logger.Error("GetDetail :", ex); return(null); } }
public ProductDetailModels GetDetail(string id) { try { ProductDetailModels model = _factory.GetDetail(id); //==========Price List <ProductPriceModels> listPrice = model.ListPrice; listPrice.ForEach(x => { if (x.Status == 0) { x.Status = (byte)Commons.EStatus.Actived; } if (x.PeriodType == (byte)Commons.EPeriodType.Day) { x.NamePeriodType = Commons.EPeriodType.Day.ToString(); } else if (x.PeriodType == (byte)Commons.EPeriodType.Month) { x.NamePeriodType = Commons.EPeriodType.Month.ToString(); } else if (x.PeriodType == (byte)Commons.EPeriodType.None) { x.NamePeriodType = Commons.EPeriodType.None.ToString(); } else if (x.PeriodType == (byte)Commons.EPeriodType.OneTime) { x.NamePeriodType = Commons.EPeriodType.OneTime.ToString().Insert(3, " "); } else if (x.PeriodType == (byte)Commons.EPeriodType.Year) { x.NamePeriodType = Commons.EPeriodType.Year.ToString(); } }); //======ListPrice int OffSet = 0; model.ListPrice = listPrice.Where(x => !x.IsExtend).OrderBy(x => x.Period).ToList(); model.ListPrice.ForEach(x => { x.OffSet = OffSet++; }); //=====ListPriceExtend OffSet = 0; model.ListPriceExtend = listPrice.Where(x => x.IsExtend).OrderBy(x => x.Period).ToList(); model.ListPriceExtend.ForEach(x => { x.OffSet = OffSet++; }); //==================Composite OffSet = 0; List <ProductCompositeModels> ListComposite = model.ListComposite; ListComposite.ForEach(x => { x.OffSet = OffSet++; if (x.Status == 0) { x.Status = (byte)Commons.EStatus.Actived; } //if (x.ProductType == (byte)Commons.EProductType.Addition) //{ // if (x.AdditionType == (byte)Commons.EAdditionType.Hardware) // x.CategoryName = Commons.EAdditionType.Hardware.ToString(); // else if (x.AdditionType == (byte)Commons.EAdditionType.Service) // x.CategoryName = Commons.EAdditionType.Service.ToString(); //} if (x.ProductType == (byte)Commons.EProductType.Product) { x.CategoryName = x.ListCategory.Select(s => s.CategoryName).FirstOrDefault().ToString(); int categoryType = x.ListCategory.Select(s => s.Type).FirstOrDefault(); x.TypeName = ((Commons.EType)Enum.ToObject(typeof(Commons.EType), categoryType)).ToString().Replace("_", " "); } else if (x.ProductType == (byte)Commons.EProductType.Addition) { x.TypeName = ((Commons.EAdditionType)Enum.ToObject(typeof(Commons.EAdditionType), x.AdditionType)).ToString(); } if (x.Quantity == -1) { x.IsUnlimited = true; } }); model.ListComposite = ListComposite.OrderBy(x => x.ProductName).ToList(); return(model); } catch (Exception ex) { NSLog.Logger.Error("ProductPackageDetail: ", ex); return(null); } }
public ProductDetailModels GetDetail(string id) { try { ProductDetailModels model = _factory.GetDetail(id); int OffSet = 0; if (model.ListCategory != null) { model.ListCategory.ForEach(x => { x.OffSet = OffSet++; if (x.Status == 0) { x.Status = (byte)Commons.EStatus.Actived; } }); model.ListCategory = model.ListCategory.OrderBy(x => x.CategoryName).ToList(); } //================= OffSet = 0; if (model.ListPrice != null) { model.ListPrice.ForEach(x => { x.OffSet = OffSet++; if (x.Status == 0) { x.Status = (byte)Commons.EStatus.Actived; } //============= if (x.PeriodType == (byte)Commons.EPeriodType.Day) { x.NamePeriodType = Commons.EPeriodType.Day.ToString(); } else if (x.PeriodType == (byte)Commons.EPeriodType.Month) { x.NamePeriodType = Commons.EPeriodType.Month.ToString(); } else if (x.PeriodType == (byte)Commons.EPeriodType.None) { x.NamePeriodType = Commons.EPeriodType.None.ToString(); } else if (x.PeriodType == (byte)Commons.EPeriodType.OneTime) { x.NamePeriodType = Commons.EPeriodType.OneTime.ToString().Insert(3, " "); } else if (x.PeriodType == (byte)Commons.EPeriodType.Year) { x.NamePeriodType = Commons.EPeriodType.Year.ToString(); } }); model.ListPrice = model.ListPrice.OrderBy(x => x.Period).ToList(); } //Get CategoryName from AdditionType if (model.AdditionType == (byte)Commons.EAdditionType.Hardware) { model.CategoryName = Commons.EAdditionType.Hardware.ToString(); } else if (model.AdditionType == (byte)Commons.EAdditionType.Location) { model.CategoryName = Commons.EAdditionType.Location.ToString(); } else if (model.AdditionType == (byte)Commons.EAdditionType.Service) { model.CategoryName = Commons.EAdditionType.Service.ToString(); } else if (model.AdditionType == (byte)Commons.EAdditionType.Software) { model.CategoryName = Commons.EAdditionType.Software.ToString(); } else if (model.AdditionType == (byte)Commons.EAdditionType.Account) { model.CategoryName = Commons.EAdditionType.Account.ToString(); } else if (model.AdditionType == (byte)Commons.EAdditionType.Function) { model.CategoryName = Commons.EAdditionType.Function.ToString(); } return(model); } catch (Exception ex) { NSLog.Logger.Error("ProductAdditionDetail: ", ex); return(null); } }