Beispiel #1
0
        public IHttpActionResult PutTeacher(string id, Teacher teacher)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (string.IsNullOrEmpty(id) || id != teacher.Id)
            {
                return(BadRequest());
            }

            if (!TeacherExists(id))
            {
                return(NotFound());
            }
            if (!HasAccesToTeacher(id))
            {
                return(ResponseMessage(new HttpResponseMessage(HttpStatusCode.Forbidden)));
            }
            _repo.MarkAsModified(teacher);
            _repo.SaveChanges();

            return(Ok(teacher));
        }