public static ProductTypeUpdateRequest ConvertToEntity(this ProductTypeUpdateRequestAddModel addModel) => new ProductTypeUpdateRequest { ProductTypeId = addModel.ProductTypeId, Name = addModel.Name, CategoryId = addModel.CategoryId, Descriptions = addModel.Descriptions };
public IActionResult Index(ProductTypeUpdateRequestAddModel addModel) { SellerView seller = loginPersistence.PersistLogin(); eCommerce.RequestAnUpdateForProductType(int.Parse(seller.Id), addModel, out ICollection <string> errors); if (errors.Any()) { ViewData[GlobalViewBagKeys.Errors] = errors; return(RedirectToAction("Index", new { productTypeId = addModel.ProductTypeId })); } return(RedirectToAction("RequestSended")); }
public IActionResult Index(int productTypeId) { SellerView seller = loginPersistence.PersistLogin(); var errors = new List <string>(); ProductTypeView productType = eCommerce.GetProductTypeBy(productTypeId); if (productType != null) { if (productType.Status == ProductTypeStatus.Locked) { errors.Add("Product is unavailable at the moment"); } } else { errors.Add("Could not found product type"); } if (errors.Any()) { ViewData[GlobalViewBagKeys.Errors] = errors; return(RedirectToAction("SelectProductType")); } ViewData[GlobalViewBagKeys.ECommerceService] = eCommerce; ProductTypeUpdateRequestView updateRequest = eCommerce.GetProductTypeUpdateRequestBy(int.Parse(seller.Id), int.Parse(productType.Id)); ProductTypeUpdateRequestAddModel addModel = new ProductTypeUpdateRequestAddModel(); if (updateRequest != null) { if (updateRequest.CategoryId != null) { addModel.CategoryId = int.Parse(updateRequest.CategoryId); } addModel.Name = updateRequest.Name; addModel.ProductTypeId = int.Parse(productType.Id); addModel.Descriptions = updateRequest.Descriptions; } else { addModel.CategoryId = int.Parse(productType.CategoryId); addModel.Name = productType.Name; addModel.ProductTypeId = int.Parse(productType.Id); } return(View(addModel)); }