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()); }
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")); }
public IActionResult Put(int id, [FromBody] ShipperDto dto) { ShipperService.Update(id, dto); return(Ok()); }
public async Task <Shipper> Update(Shipper shipper) { var shipperUpdate = await _shipperService.Update(shipper); return(shipperUpdate); }
public ShipperEntity Update(Guid shipperId, [FromBody] ShipperEntity shipperEntity) { return(shipperService.Update(shipperId, shipperEntity)); }