public ActionResult Edit(int id, int supplierId) { var model = new EditSupplierAddressViewModel(); prepareEditModel(model, id, supplierId); model.SupplierAddress = SupplierService.FindSupplierAddressModel(id, supplierId, model.CurrentCompany); model.LGS = SupplierService.LockSupplierAddress(model.SupplierAddress); return(View(model)); }
void prepareEditModel(EditSupplierAddressViewModel model, int id, int supplierId) { var supplier = SupplierService.FindSupplierModel(supplierId); string title = EvolutionResources.bnrAddEditSupplierAddress + (supplier == null ? "" : " - " + supplier.Name); if (id <= 0) { title += " - " + EvolutionResources.lblNewAddress; } PrepareViewModel(model, title, supplierId, MakeMenuOptionFlags(supplierId, 0)); model.AddressTypeList = LookupService.FindLOVItemsListItemModel(null, LOVName.AddressType); model.CountryList = LookupService.FindCountriesListItemModel(); model.ParentId = supplierId; }
public ActionResult Save(EditSupplierAddressViewModel model, string command) { if (command.ToLower() == "save") { var modelError = SupplierService.InsertOrUpdateSupplierAddress(model.SupplierAddress, model.LGS); if (modelError.IsError) { prepareEditModel(model, model.SupplierAddress.Id, model.SupplierAddress.SupplierId.Value); model.SetErrorOnField(ErrorIcon.Error, modelError.Message, "SupplierAddress_" + modelError.FieldName); return(View("Edit", model)); } else { return(RedirectToAction("SupplierAddresses", new { id = model.ParentId })); } } else { return(RedirectToAction("SupplierAddresses", new { id = model.ParentId })); } }