public IHttpActionResult UpdateTeacher([FromBody] TeacherInfosModel teach) { if (teacherManager.UpdateTeacherIntoDB(teach)) { return(Ok()); } else { return(BadRequest("Not a valid teacher to update")); } }
public bool UpdateTeacherIntoDB(TeacherInfosModel teach) { bool rep = false; try { db.Database.ExecuteSqlCommand("update_TEACHER_BY_ID_PS @Id,@FirstName,@LastName,@Email, @Code", new SqlParameter("Id", teach.Id), new SqlParameter("FirstName", teach.FirstName), new SqlParameter("LastName", teach.LastName), new SqlParameter("Email", teach.Email), new SqlParameter("Code", teach.Code)); rep = true; } catch { rep = false; } return(rep); }