Exemple #1
0
 public IHttpActionResult AddTest([FromBody] TestDTO test)
 {
     try
     {
         if (ModelState.IsValid)
         {
             return(Ok(TestLogic.AddTest(test)));
         }
         var errors = ModelState.Select(x => x.Value.Errors)
                      .Where(y => y.Count > 0)
                      .ToList();
         return(BadRequest(errors.ToString()));
     }
     catch (Exception ex)
     {
         return(BadRequest(ex.Message));
     }
 }