public async Task <IActionResult> PutFeedBackQuestion([FromRoute] long id, [FromBody] FeedBackQuestion feedBackQuestion)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

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

            _context.Entry(feedBackQuestion).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!FeedBackQuestionExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Пример #2
0
        public HttpResponseMessage GetFeedBackQuestionsBylang(int langCode)
        {
            LanguageName = comObj.fetchLang(langCode);

            List <FeedBackQuestion> question = new List <FeedBackQuestion>();
            var questiondata = (from questions in db.FeedBackQuestions
                                where questions.Active == true
                                select new { questions.Id, questions.Questions, questions.Active }).ToList();

            foreach (var item in questiondata)
            {
                FeedBackQuestion questionObj = new FeedBackQuestion();
                switch (LanguageName)
                {
                case "Hindi":
                    questionObj.Id        = item.Id;
                    questionObj.Questions = item.Questions != null?comObj.GetResxNameByValue_Hindi(item.Questions) : string.Empty;

                    questionObj.Active = item.Active;
                    question.Add(questionObj);
                    break;

                case "English":
                    questionObj.Id        = item.Id;
                    questionObj.Questions = item.Questions;
                    questionObj.Active    = item.Active;
                    question.Add(questionObj);
                    break;

                case "Oriya":
                    questionObj.Id        = item.Id;
                    questionObj.Questions = item.Questions != null?comObj.GetResxNameByValue_Oriya(item.Questions) : string.Empty;

                    questionObj.Active = item.Active;
                    question.Add(questionObj);
                    break;

                case "Santhali":
                    questionObj.Id        = item.Id;
                    questionObj.Questions = item.Questions != null?comObj.GetResxNameByValue_Hindi(item.Questions) : string.Empty;

                    questionObj.Active = item.Active;
                    question.Add(questionObj);
                    break;

                case "Ho":
                    questionObj.Id        = item.Id;
                    questionObj.Questions = item.Questions != null?comObj.GetResxNameByValue_Hindi(item.Questions) : string.Empty;

                    questionObj.Active = item.Active;
                    question.Add(questionObj);
                    break;

                default:
                    break;
                }
            }

            return((HttpResponseMessage)Request.CreateResponse(HttpStatusCode.OK, new { data = new { question }, success = true, error = string.Empty }));
        }
Пример #3
0
        public IHttpActionResult GetFeedBackQuestion(int id)
        {
            FeedBackQuestion feedBackQuestion = db.FeedBackQuestions.Find(id);

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

            return(Ok(feedBackQuestion));
        }
        public async Task <IActionResult> PostFeedBackQuestion([FromBody] FeedBackQuestion feedBackQuestion)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            _context.FeedBackQuestions.Add(feedBackQuestion);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetFeedBackQuestion", new { id = feedBackQuestion.Id }, feedBackQuestion));
        }
Пример #5
0
        public HttpResponseMessage PostFeedBackQuestion(FeedBackQuestion feedBackQuestion)
        {
            if (!ModelState.IsValid)
            {
                return((HttpResponseMessage)Request.CreateResponse(HttpStatusCode.BadRequest, new { data = new { string.Empty }, success = false, error = string.Empty }));
            }

            db.FeedBackQuestions.Add(feedBackQuestion);
            db.SaveChanges();

            return((HttpResponseMessage)Request.CreateResponse(HttpStatusCode.OK, new { data = new { id = feedBackQuestion.Id }, success = true, error = string.Empty }));
        }
Пример #6
0
        public IHttpActionResult DeleteFeedBackQuestion(int id)
        {
            FeedBackQuestion feedBackQuestion = db.FeedBackQuestions.Find(id);

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

            db.FeedBackQuestions.Remove(feedBackQuestion);
            db.SaveChanges();

            return(Ok(feedBackQuestion));
        }
Пример #7
0
        public HttpResponseMessage PutFeedBackQuestion(int id, FeedBackQuestion feedBackQuestion)
        {
            if (!ModelState.IsValid)
            {
                return((HttpResponseMessage)Request.CreateResponse(HttpStatusCode.BadRequest, new { data = new { string.Empty }, success = false, error = string.Empty }));
            }

            if (id != feedBackQuestion.Id)
            {
                return((HttpResponseMessage)Request.CreateResponse(HttpStatusCode.BadRequest, new { data = new { string.Empty }, success = false, error = string.Empty }));
            }

            //db.Entry(feedBackQuestion).State = EntityState.Modified;

            try
            {
                FeedBackQuestion feedBackQuestiondata = db.FeedBackQuestions.Where(a => a.Id == feedBackQuestion.Id).FirstOrDefault();
                feedBackQuestiondata.Questions = feedBackQuestion.Questions;
                feedBackQuestiondata.Active    = feedBackQuestion.Active;

                if (feedBackQuestion.UpdatedBy != null)
                {
                    feedBackQuestiondata.UpdatedBy = feedBackQuestion.UpdatedBy;
                    feedBackQuestiondata.UpdatedOn = feedBackQuestion.UpdatedOn;
                }
                if (feedBackQuestion.ActiveBy != null)
                {
                    feedBackQuestiondata.ActiveBy = feedBackQuestion.ActiveBy;
                    feedBackQuestiondata.ActiveOn = feedBackQuestion.ActiveOn;
                }
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!FeedBackQuestionExists(id))
                {
                    return((HttpResponseMessage)Request.CreateResponse(HttpStatusCode.NotFound, new { data = new { string.Empty }, success = false, error = string.Empty }));
                }
                else
                {
                    throw;
                }
            }

            return((HttpResponseMessage)Request.CreateResponse(HttpStatusCode.OK, new { data = new { feedBackQuestion }, success = true, error = string.Empty }));
        }