Ejemplo n.º 1
0
 public IHttpActionResult AddSimpleTest([FromBody] SimpleTest newtest)
 {
     try
     {
         if (ModelState.IsValid)
         {
             return(Ok(TestLogic.AddSimpleTest(newtest)));
         }
         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));
     }
 }