Ejemplo n.º 1
0
        public async Task <IHttpActionResult> PutAnswerItem(int id, Answer item)
        {
            AnswerBL bL = new AnswerBL(_context);

            if (!id.Equals(item.answerID))
            {
                return(BadRequest());
            }

            else if (!bL.AnswerExists(id))
            {
                var ItemId = await bL.CreateNewAnswer(item);

                if (ItemId == null)
                {
                    return(InternalServerError());
                }

                return(Created(Request.RequestUri, item));
            }
            var isUpdated = await bL.UpdateAnswer(item);

            if (isUpdated == false)
            {
                return(InternalServerError());
            }
            return(StatusCode(HttpStatusCode.NoContent));
        }
Ejemplo n.º 2
0
        public async Task <IHttpActionResult> PostAnswer(Answer item)
        {
            AnswerBL bL     = new AnswerBL(_context);
            var      ItemId = await bL.CreateNewAnswer(item);

            if (ItemId == null)
            {
                return(InternalServerError());
            }
            return(Created(String.Format("{0}/{1}", Request.RequestUri, ItemId), item));
        }