public ActionResult Save(SubOrganizationPageViewModel viewModel) { if (string.IsNullOrEmpty(viewModel.SubOrganizationModel.Name)) { ModelState.AddModelError("SubOrganization.Name", "SubOrganization Name is requried"); } if (viewModel.SubOrganizationModel.OrganizationId != Guid.Empty) { //update the locations list var updatedLocations = new List <B2BAddressViewModel>(); foreach (var location in viewModel.SubOrganizationModel.Locations) { if (location.Name != "removed") { updatedLocations.Add(location); } else { if (location.AddressId != Guid.Empty) { _addressService.DeleteAddress(viewModel.SubOrganizationModel.OrganizationId.ToString(), location.AddressId.ToString()); } } } viewModel.SubOrganizationModel.Locations = updatedLocations; _organizationService.UpdateSubOrganization(viewModel.SubOrganizationModel); } return(RedirectToAction("Index", new { suborg = viewModel.SubOrganizationModel.OrganizationId })); }
public IHttpActionResult DeleteAddress(int addressID) { addressBookService.DeleteAddress(addressID); return(ResponseJson <string>("OK")); }