コード例 #1
0
 public IHttpActionResult Delete(int id)
 {
     try
     {
         Student s = StudentsDB.GetStudentById(id);
         if (s != null)
         {
             int res = StudentsDB.DeleteStudentById(id);
             if (res == 1)
             {
                 return(Ok());
             }
             return(Content(HttpStatusCode.BadRequest, $"student with id {id} exsits but could not be deleted!!!"));
         }
         return(Content(HttpStatusCode.NotFound, "student with id = " + id + " was not found to delete!!!"));
     }
     catch (Exception ex)
     {
         return(BadRequest(ex.Message));
     }
 }