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