public JsonResult Update(SupplierDetailView vm) { GetSupplierRequest request = new GetSupplierRequest(); request.SupplierID = vm.SupplierID; ModifySupplierRequest updateRequest = _supplierService.GetSupplier(request).Supplier.ConvertToModifySupplierRequest(); updateRequest.SupplierID = vm.SupplierID; updateRequest.CompanyName = vm.CompanyName; updateRequest.ContactName = vm.ContactName; updateRequest.ContactTitle = vm.ContactTitle; updateRequest.Address = vm.Address; updateRequest.City = vm.City; updateRequest.Region = vm.Region; updateRequest.PostalCode = vm.PostalCode; updateRequest.Country = vm.Country; updateRequest.Phone = vm.Phone; updateRequest.Fax = vm.Fax; updateRequest.HomePage = vm.HomePage; ModifySupplierResponse response = _supplierService.ModifySupplier(updateRequest); return(Json(response)); }
public ModifySupplierResponse ModifySupplier(ModifySupplierRequest request) { ModifySupplierResponse response = new ModifySupplierResponse(); Supplier supplier = _supplierRepository .FindBy(request.SupplierID); supplier.Id = request.SupplierID; supplier.CompanyName = request.CompanyName; supplier.ContactName = request.ContactName; supplier.ContactTitle = request.ContactTitle; supplier.Address = request.Address; supplier.City = request.City; supplier.Region = request.Region; supplier.PostalCode = request.PostalCode; supplier.Country = request.Country; supplier.Phone = request.Phone; supplier.Fax = request.Fax; supplier.HomePage = request.HomePage; supplier.Products = request.Products.ConvertToProducts(); if (supplier.GetBrokenRules().Count() > 0) { response.Errors = supplier.GetBrokenRules().ToList(); } else { try { _supplierRepository.Save(supplier); _uow.Commit(); response.Errors = new List <BusinessRule>(); } catch (Exception ex) { response.Errors = new List <BusinessRule>(); response.Errors.Add(new BusinessRule("DAL", "DAL_ERROR: " + ex.Message)); } } return(response); }