예제 #1
0
        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 JsonResult Update(ShipperDetailView vm)
        {
            GetShipperRequest request = new GetShipperRequest();

            request.ShipperID = vm.ShipperID;

            ModifyShipperRequest updateRequest = _shipperService.GetShipper(request).Shipper.ConvertToModifyShipperRequest();

            updateRequest.ShipperID   = vm.ShipperID;
            updateRequest.CompanyName = vm.CompanyName;
            updateRequest.Phone       = vm.Phone;

            ModifyShipperResponse response = _shipperService.ModifyShipper(updateRequest);

            return(Json(response));
        }