public ActionResult UpdatePerson(PersonModel model)
 {
     try {
         if (ModelState.IsValid)
         {
             _personsService.UpdatePerson(model);
             return(Json(new { success = true }, JsonRequestBehavior.AllowGet));
         }
         else
         {
             string errors = "";
             foreach (ModelState modelState in ViewData.ModelState.Values)
             {
                 foreach (ModelError error in modelState.Errors)
                 {
                     errors += error.ErrorMessage + "<br/>";
                 }
             }
             return(Json(new { success = false, error = errors }, JsonRequestBehavior.AllowGet));
         }
     }catch (Exception ex)
     {
         return(Json(new { success = false, error = ex.Message }, JsonRequestBehavior.AllowGet));
     }
 }
Beispiel #2
0
 public IActionResult Put(int id, [FromBody] PersonDto person)
 {
     if (!ModelState.IsValid || id != person.Id)
     {
         return(BadRequest("Data are not valid!"));
     }
     _personsService.UpdatePerson(person);
     return(Ok("New element inserted successfully"));
 }
Beispiel #3
0
 public ResponseModel <List <PersonsModel> > UpdatePerson(PersonsModel model)
 {
     _logger.Debug($"UpdatePerson with payload: {JsonConvert.SerializeObject(model)}");
     return(_personService.UpdatePerson(model));
 }