EditProductIPViewModel createModel(int productId) { var model = new EditProductIPViewModel(); var product = ProductService.FindProductModel(productId, 0, CurrentCompany); model.ProductId = product.Id; PrepareViewModel(model, EvolutionResources.bnrIntellectualProperty + (productId == 0 ? "" : " - " + product.ItemName), productId, MakeMenuOptionFlags(0, 0, 0, 0, productId)); return(model); }
public ActionResult Save(EditProductIPViewModel model, string command) { var product = ProductService.FindProductModel(model.ProductId, null, null, false); string cmd = command.ToLower(); if (cmd == "save" || cmd == "saveandexit") { if (ModelState.IsValid) { model.Error = ProductService.InsertOrUpdateProductIP(product, model.ProductIPs, model.LGS); if (model.Error.IsError) { prepareViewModel(model); model.SetErrorOnField(ErrorIcon.Error, model.Error.Message, model.Error.FieldName); return(View("Edit", model)); } else { if (cmd == "saveandexit") { return(RedirectToAction("Products", "Products", new { BrandId = product.BrandId })); } else { model.SetErrorOnField(ErrorIcon.Information, EvolutionResources.infChangesSuccessfullySaved, "", null, null, null, null, true); return(RedirectToAction("Edit", new { Id = product.Id })); } } } else { prepareViewModel(model); return(View("Edit", model)); } } else { return(RedirectToAction("Products", "Products", new { BrandId = product.BrandId })); } }
void prepareViewModel(EditProductIPViewModel model) { model.ProductIPs = ProductService.FindProductIPListModel(model.ProductId, 0); }