public ModifyShipperResponse ModifyShipper(ModifyShipperRequest request) { ModifyShipperResponse response = new ModifyShipperResponse(); Shipper shipper = _shipperRepository .FindBy(request.ShipperID); shipper.Id = request.ShipperID; shipper.CompanyName = request.CompanyName; shipper.Phone = request.Phone; shipper.Orders = request.Orders.ConvertToOrders(); if (shipper.GetBrokenRules().Count() > 0) { response.Errors = shipper.GetBrokenRules().ToList(); } else { try { _shipperRepository.Save(shipper); _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); }
public CreateShipperResponse CreateShipper(CreateShipperRequest request) { CreateShipperResponse response = new CreateShipperResponse(); Shipper shipper = new Shipper(); shipper.CompanyName = request.CompanyName; shipper.Phone = request.Phone; shipper.Orders = request.Orders.ConvertToOrders(); if (shipper.GetBrokenRules().Count() > 0) { response.Errors = shipper.GetBrokenRules().ToList(); } else { try { _shipperRepository.Add(shipper); _uow.Commit(); response.Errors = new List <BusinessRule>(); } catch (Exception ex) { List <BusinessRule> errors = new List <BusinessRule>(); do { errors.Add(new BusinessRule("DAL", "DAL_ERROR: " + ex.Message)); ex = ex.InnerException; } while (ex != null); response.Errors = errors; } } return(response); }