Example #1
0
        public IHttpActionResult GetKingAnswer(int id)
        {
            KingAnswer kinganswer = db.KingAnswers.Find(id);

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

            return(Ok(kinganswer));
        }
Example #2
0
        public IHttpActionResult PostKingAnswer(KingAnswer kinganswer)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.KingAnswers.Add(kinganswer);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = kinganswer.Id }, kinganswer));
        }
Example #3
0
        public IHttpActionResult DeleteKingAnswer(int id)
        {
            KingAnswer kinganswer = db.KingAnswers.Find(id);

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

            db.KingAnswers.Remove(kinganswer);
            db.SaveChanges();

            return(Ok(kinganswer));
        }
Example #4
0
        // PUT api/KingAnswer/5
        public IHttpActionResult PutKingAnswer(int id, KingAnswer kinganswer)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }


            //get week
            var weekId = db.Week.First().Week_Id;

            //set week to geomaster
            kinganswer.Week = weekId;


            if (id != kinganswer.Id)
            {
                return(BadRequest());
            }

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }