public async Task <IActionResult> EditFireDepartment(EditFireDepartmentViewModel model) { if (!ModelState.IsValid) { return(BadRequest("Model not valid")); } await fireDepartmentViewModelService.EditFireDepartment(model); return(Ok(model)); }
public async Task EditFireDepartment(EditFireDepartmentViewModel model) { var fireDepartment = await fireDepartmentRepository.GetByIdAsync(model.Id); if (fireDepartment == null) { throw new ApplicationException($"Fire Department with Id = {model.Id} doesn't exist"); } var address = fireDepartment.FireDepartmentAddress; address.Update(model.City, model.Street, model.StreetNumber, model.ZipCode); fireDepartment.Update(model.FireDepartmentName, address); await fireDepartmentRepository.UpdateAsync(fireDepartment); }