Пример #1
0
        public IActionResult Edit(int id, CarrierDto carrierDto)
        {
            log.Info(nameof(Edit) + ":Post");

            if (id != carrierDto.Id)
            {
                log.Warn(nameof(Edit) + " id is not equal to carrierDto.Id");

                return(NotFound());
            }

            try
            {
                if (ModelState.IsValid)
                {
                    carrierService.Update(carrierDto);

                    return(RedirectToAction(nameof(Index)));
                }

                return(View(carrierDto));
            }
            catch (Exception e)
            {
                log.Error(e);

                return(BadRequest());
            }
        }
Пример #2
0
 public ActionResult Edit(CarrierViewModel carrierViewModel)
 {
     try
     {
         var carrierDTO = ConvertToCarrierDTO(carrierViewModel);
         _carrierService.Update(carrierDTO);
         TempData["AlertSuccess"] = "Operation Done!";
     }
     catch (Exception e)
     {
         this.ModelState.AddModelError("CustomError", e.Message);
         return(View());
     }
     return(RedirectToAction("Index"));
 }
Пример #3
0
        public IActionResult UpdateCarrier([SwaggerParameter("Int", Required = true)] int id, [FromBody, SwaggerRequestBody("Carrier payload", Required = true)] CarrierDto carrierDto)
        {
            log.Info(nameof(UpdateCarrier));

            try
            {
                if (id != carrierDto.Id)
                {
                    log.Warn(nameof(UpdateCarrier) + " id is not equal to carrierDto.Id");

                    return(BadRequest());
                }

                carrierService.Update(carrierDto);

                return(NoContent());
            }
            catch (Exception e)
            {
                log.Error(e);

                return(BadRequest());
            }
        }
Пример #4
0
 public CarrierEntity Update(Guid CarrierId, [FromBody] CarrierEntity CarrierEntity)
 {
     return(CarrierService.Update(EmployeeEntity, CarrierId, CarrierEntity));
 }