Exemple #1
0
        public HttpResponseMessage UpdateQuestion(int id, Question question)
        {
            if (!ModelState.IsValid)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState));
            }

            if (id != question.QuestionId)
            {
                return(Request.CreateResponse(HttpStatusCode.BadRequest));
            }

            QuestionRepository.Attach(question);

            try
            {
                unitOfWork.SaveChanges();
            }
            catch (DbUpdateConcurrencyException ex)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.NotFound, ex));
            }

            return(Request.CreateResponse(HttpStatusCode.OK));
        }