示例#1
0
        public IHttpActionResult PutInkeyUserQuestion(int id, InkeyUserQuestion inkeyUserQuestion)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != inkeyUserQuestion.InkeyUserQuestionsId)
            {
                return(BadRequest());
            }

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
        public async Task <IHttpActionResult> PostInkeyUserQuestion(InkeyUserQuestion inkeyUserQuestion)
        {
            if (!IsValid(inkeyUserQuestion.userEmail))
            {
                return(BadRequest("invalid email"));
            }

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            InkeyUserQuestion userQuestion = db.InkeyUserQuestions.FirstOrDefault(q => q.InkeyUserQuestionsId == inkeyUserQuestion.InkeyUserQuestionsId);

            if (userQuestion != null)
            {
                userQuestion.userEmail = inkeyUserQuestion.userEmail;

                db.Entry(userQuestion).State = EntityState.Modified;
                await db.SaveChangesAsync();

                return(CreatedAtRoute("DefaultApi", new { id = inkeyUserQuestion.InkeyUserQuestionsId }, inkeyUserQuestion));
            }

            return(BadRequest(ModelState));
        }
示例#3
0
        public IHttpActionResult GetInkeyUserQuestion(int id)
        {
            InkeyUserQuestion inkeyUserQuestion = db.InkeyUserQuestions.Find(id);

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

            return(Ok(inkeyUserQuestion));
        }
        public async Task <IHttpActionResult> GetInkeyUserQuestion(int id)
        {
            InkeyUserQuestion inkeyUserQuestion = await db.InkeyUserQuestions.FindAsync(id);

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

            return(Ok(inkeyUserQuestion));
        }
示例#5
0
        public IHttpActionResult PostInkeyUserQuestion(InkeyUserQuestion inkeyUserQuestion)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            inkeyUserQuestion.Created = DateTime.Now;
            db.InkeyUserQuestions.Add(inkeyUserQuestion);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = inkeyUserQuestion.InkeyUserQuestionsId }, inkeyUserQuestion));
        }
示例#6
0
        public IHttpActionResult DeleteInkeyUserQuestion(int id)
        {
            InkeyUserQuestion inkeyUserQuestion = db.InkeyUserQuestions.Find(id);

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

            db.InkeyUserQuestions.Remove(inkeyUserQuestion);
            db.SaveChanges();

            return(Ok(inkeyUserQuestion));
        }
        public async Task <IHttpActionResult> DeleteInkeyUserQuestion(int id)
        {
            InkeyUserQuestion inkeyUserQuestion = await db.InkeyUserQuestions.FindAsync(id);

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

            db.InkeyUserQuestions.Remove(inkeyUserQuestion);
            await db.SaveChangesAsync();

            return(Ok(inkeyUserQuestion));
        }