public ActionResult AddOrEditProductVariation(Guid?id) { try { var model = new ProVarationViewModel(); model.DropDownProduct = DropDownListDomain.DropDownList_Product(_productService.SelectAll()); model.DropDownVolume = DropDownListDomain.DropDownList_Volume(); if (id.HasValue) { var productVariation = _productVariationService.GetById(id.Value); model = ConvertDomainToModel.ConvertModelFromDomainToProVa(productVariation); model.DropDownProduct = DropDownListDomain.DropDownList_Product(_productService.SelectAll()); model.DropDownVolume = DropDownListDomain.DropDownList_Volume(); model.Image = _productImageService.GetProductImage(model.Id) == null ? null : ConvertDomainToModel.GetProductImage(_productImageService.GetProductImage(model.Id)); return(View(model)); } else { return(View(model)); } } catch { return(RedirectToAction("Erorr500", "HomdeAdmin")); } }
/// <summary> /// get product variation have image with image id /// </summary> /// <param name="proVas">ProductVatiation List</param> /// <returns>ProVarationViewModel List</returns> public IList <ProVarationViewModel> GetProductVariations(IList <ProductVariation> proVas) { return(proVas.Select(x => new ProVarationViewModel { Id = x.Id, SKU = x.SKU, StockQuantity = x.StockQuantity, Price = x.Price, Volume = x.Volume, Image = _productImageService.GetProductImage(x.Id) == null ? null : ConvertDomainToModel.GetProductImage(_productImageService.GetProductImage(x.Id)), DiscountPrice = x.DiscountPrice, CreateDate = x.CreatedDate, UpdateDate = x.UpdatedDate, IsActive = x.IsActive }).ToList()); }