Пример #1
0
 public IActionResult PostData([FromBody] IMViewModel data)
 {
     if (ModelState.IsValid)
     {
         context.UpdateMovie(data);
         return(new JsonResult(new { success = true, msg = "Success" }));
     }
     else
     {
         var errors = new StringBuilder();
         foreach (ModelStateEntry modelState in ViewData.ModelState.Values)
         {
             foreach (ModelError error in modelState.Errors)
             {
                 errors.Append(error.ErrorMessage);
             }
         }
         return(new JsonResult(new { success = false, msg = errors.ToString() }));
     }
 }