示例#1
0
 public JsonResult UpdateShipper(Shipper model)
 {
     try
     {
         Shipper shipper = _shipperService.GetByID(model.ShipperID);
         shipper.CompanyName = model.CompanyName;
         shipper.Phone       = model.Phone;
         _shipperService.Update(shipper);
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message);
     }
     return(Json("ok", JsonRequestBehavior.AllowGet));
 }
        public async Task <ActionResult <ShipperModel> > UpdateShipper(int shipperId, ShipperModel shipperModel)
        {
            var oldShipper = await _shipperService.GetById(shipperId);

            if (oldShipper == null)
            {
                return(NotFound());
            }

            var newShipper = _mapper.Map(shipperModel, oldShipper);

            _shipperService.Update(newShipper);

            if (await _shipperService.IsSavedToDb())
            {
                return(Ok(_mapper.Map <ShipperModel>(newShipper)));
            }

            return(BadRequest());
        }
示例#3
0
        public IActionResult SaveEntity(ShipperViewModel viewModel)
        {
            if (!ModelState.IsValid)
            {
                IEnumerable <ModelError> allErrors = ModelState.Values.SelectMany(n => n.Errors);
                return(new BadRequestObjectResult(allErrors));
            }
            else
            {
                if (viewModel.Id == 0)
                {
                    _shipperService.Add(viewModel);
                }
                else
                {
                    _shipperService.Update(viewModel);
                }
            }

            _shipperService.Save();

            return(new OkObjectResult(viewModel));
        }
 public ActionResult Edit(Shipper shipper)
 {
     _shipperService.Update(shipper);
     return(RedirectToAction("Index"));
 }
示例#5
0
 public IActionResult Put(int id, [FromBody] ShipperDto dto)
 {
     ShipperService.Update(id, dto);
     return(Ok());
 }
示例#6
0
        public async Task <Shipper> Update(Shipper shipper)
        {
            var shipperUpdate = await _shipperService.Update(shipper);

            return(shipperUpdate);
        }
示例#7
0
 public ShipperEntity Update(Guid shipperId, [FromBody] ShipperEntity shipperEntity)
 {
     return(shipperService.Update(shipperId, shipperEntity));
 }