Example #1
0
 public ActionResult Edit(UOM uom)
 {
     try
     {
         if (ModelState.IsValid)
         {
             UOMService.Update(uom);
         }
     }
     catch
     {
     }
     return(View(uom));
 }
        public async Task <IActionResult> Put([FromRoute] int id, [FromBody] FormDto form)
        {
            try
            {
                VerifyUser();

                var data = await _service.GetById(id);

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

                _validateService.Validate(form);
                await _service.Update(id, form);

                return(NoContent());
            }
            catch (ServiceValidationException ex)
            {
                var Result = new
                {
                    error      = ResultFormatter.Fail(ex),
                    apiVersion = "1.0.0",
                    statusCode = HttpStatusCode.BadRequest,
                    message    = "Data does not pass validation"
                };

                return(new BadRequestObjectResult(Result));
            }
            catch (Exception ex)
            {
                var error = new
                {
                    statusCode = HttpStatusCode.InternalServerError,
                    error      = ex.Message
                };
                return(StatusCode((int)HttpStatusCode.InternalServerError, error));
            }
        }