Beispiel #1
0
        public IHttpActionResult PutJeopardyQuestion(int id, JeopardyQuestion jeopardyQuestion)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != jeopardyQuestion.JeopardyQuestionId)
            {
                return(BadRequest());
            }

            db.Entry(jeopardyQuestion).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!JeopardyQuestionExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Beispiel #2
0
        public IHttpActionResult GetJeopardyQuestion(int id)
        {
            JeopardyQuestion jeopardyQuestion = db.JeopardyQuestions.Find(id);

            if (jeopardyQuestion == null)
            {
                return(NotFound());
            }

            return(Ok(jeopardyQuestion));
        }
Beispiel #3
0
        public IHttpActionResult DeleteJeopardyQuestion(int id)
        {
            JeopardyQuestion jeopardyQuestion = db.JeopardyQuestions.Find(id);

            if (jeopardyQuestion == null)
            {
                return(NotFound());
            }

            db.JeopardyQuestions.Remove(jeopardyQuestion);
            db.SaveChanges();

            return(Ok(jeopardyQuestion));
        }
Beispiel #4
0
        public IHttpActionResult PostJeopardyQuestion(JeopardyQuestion jeopardyQuestion)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }



            db.JeopardyQuestions.Add(jeopardyQuestion);
            db.SaveChanges();

            Category categoryQuestion = db.Categorys.Find(jeopardyQuestion.CategoryId);

            categoryQuestion.JeopardyQuestions.Add(jeopardyQuestion);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = jeopardyQuestion.JeopardyQuestionId }, jeopardyQuestion));
        }