Ejemplo n.º 1
0
        public IActionResult UpdateFeedbackComment(int surveyId, SurveyFeedbackViewModel surveyFeedbackViewModel)
        {
            UserFeedbackResponse userFeedbackResponse = new UserFeedbackResponse();
            string userId = Request.Headers[Constants.UserToken];
            User   user;

            _memoryCache.TryGetValue(userId, out user);
            if (user == null)
            {
                return(Unauthorized(Messages.UserNotFoundError));
            }

            Survey survey = _dBContext.Survey.Where(x => x.CreatedBy == user.Userid && x.Surveyid == surveyId).FirstOrDefault();

            if (survey == null)
            {
                return(BadRequest(Messages.SurveyNotFoundError));
            }

            SurveyFeedback surveyFeedback = _dBContext.SurveyFeedback.Where(x => x.SurveyId == surveyId && x.SurveyFeedbackId == surveyFeedbackViewModel.FeedbackId).FirstOrDefault();

            if (surveyFeedback == null)
            {
                return(BadRequest(Messages.FeedbackNotFound));
            }

            surveyFeedback.ReviewComment   = surveyFeedbackViewModel.Comment;
            surveyFeedback.ReviewCompleted = Convert.ToBoolean(surveyFeedbackViewModel.reviewComplete) ? 1 : 0;
            surveyFeedback.ReviewDatetime  = DateTime.UtcNow;
            _dBContext.SurveyFeedback.Update(surveyFeedback);
            _dBContext.SaveChanges();
            return(Ok(surveyFeedback));
        }
Ejemplo n.º 2
0
        public IActionResult GetFeedbacks(string surveyGuid, int pagenum, int pagesize)
        {
            UserFeedbackResponse userFeedbackResponse = new UserFeedbackResponse();
            string userId = Request.Headers[Constants.UserToken];
            User   user;

            _memoryCache.TryGetValue(userId, out user);
            if (user == null)
            {
                return(Unauthorized(Messages.UserNotFoundError));
            }

            _memoryCache.TryGetValue($"user_survey_feedback_{surveyGuid}_pageno_{pagenum}_pagesize_{pagesize}", out userFeedbackResponse);
            if (userFeedbackResponse != null)
            {
                return(Ok(userFeedbackResponse));
            }
            userFeedbackResponse = new UserFeedbackResponse();

            Survey survey = _dBContext.Survey.Where(x => x.CreatedBy == user.Userid && x.SurveyGuid == surveyGuid).FirstOrDefault();

            if (survey == null)
            {
                return(BadRequest(Messages.SurveyNotFoundError));
            }

            userFeedbackResponse.surveyTitle = survey.Welcometitle;
            userFeedbackResponse.surveyLogo  = survey.Welcomeimage;

            var userFeedbacks = from fb in _dBContext.SurveyFeedback
                                where fb.SurveyId == survey.Surveyid && fb.CompletedDatetime != null
                                orderby fb.InsertedDatetime descending
                                select new Feedbacks()
            {
                surveyUserId      = fb.SurveyFeedbackId,
                surveyUserGuid    = fb.SurveyUserGuid,
                EmailId           = fb.SurveyUserEmail,
                receivedDate      = fb.CompletedDatetime,
                Comment           = fb.ReviewComment,
                reviewComplete    = Convert.ToBoolean(fb.ReviewCompleted),
                reviewUpdatedDate = fb.ReviewDatetime
            };

            var total = userFeedbacks.Count();

            var filteredFeedbacks = userFeedbacks.Skip(pagesize * pagenum)
                                    .Take(pagesize).ToList();

            userFeedbackResponse.feedbacks = filteredFeedbacks;
            userFeedbackResponse.total     = total;

            userFeedbackResponse.questions = _dBContext.SurveyQuestions.Where(x => x.StatusId != (int)EnumStatus.Deleted && x.SurveyId == survey.Surveyid).Select(x => x.SurveyQuestionId).ToList();
            _memoryCache.Set($"user_survey_feedback_{surveyGuid}_pageno_{pagenum}_pagesize_{pagesize}", userFeedbackResponse);
            return(Ok(userFeedbackResponse));
        }
Ejemplo n.º 3
0
        public IActionResult GetFeedbacks(string surveyGuid, int pagenum, int pagesize)
        {
            UserFeedbackResponse userFeedbackResponse = new UserFeedbackResponse();
            string userguid      = Request.Headers[Constants.UserToken];
            string decyrptstring = Security.Decrypt(userguid);

            if (string.IsNullOrEmpty(decyrptstring))
            {
                return(BadRequest(Messages.UnauthorizedUserError));
            }

            User user = _dBContext.User.Where(x => x.UserGuid == decyrptstring).FirstOrDefault();

            if (user == null)
            {
                return(BadRequest(Messages.UserNotFoundError));
            }

            Survey survey = _dBContext.Survey.Where(x => x.CreatedBy == user.Userid && x.SurveyGuid == surveyGuid).FirstOrDefault();

            if (survey == null)
            {
                return(BadRequest(Messages.SurveyNotFoundError));
            }

            userFeedbackResponse.surveyTitle = survey.Welcometitle;
            userFeedbackResponse.surveyLogo  = survey.Welcomeimage;

            var userFeedbacks = from fb in _dBContext.SurveyUser
                                where fb.SurveyId == survey.Surveyid && fb.CompletedDatetime != null
                                orderby fb.InsertedDatetime descending
                                select new Feedbacks()
            {
                surveyUserId      = fb.SurveyUserId,
                surveyUserGuid    = fb.SurveyUserGuid,
                EmailId           = fb.SurveyUserEmail,
                receivedDate      = fb.CompletedDatetime,
                Comment           = fb.ReviewComment,
                reviewComplete    = Convert.ToBoolean(fb.ReviewCompleted),
                reviewUpdatedDate = fb.ReviewDatetime
            };

            var total = userFeedbacks.Count();

            var filteredFeedbacks = userFeedbacks.Skip(pagesize * pagenum)
                                    .Take(pagesize).ToList();

            userFeedbackResponse.feedbacks = filteredFeedbacks;
            userFeedbackResponse.total     = total;

            return(Ok(userFeedbackResponse));
        }
Ejemplo n.º 4
0
        public IActionResult UpdateFeedbackComment(int surveyId, SurveyFeedbackViewModel surveyFeedbackViewModel)
        {
            UserFeedbackResponse userFeedbackResponse = new UserFeedbackResponse();
            string userguid      = Request.Headers[Constants.UserToken];
            string decyrptstring = Security.Decrypt(userguid);

            if (string.IsNullOrEmpty(decyrptstring))
            {
                return(BadRequest(Messages.UnauthorizedUserError));
            }

            User user = _dBContext.User.Where(x => x.UserGuid == decyrptstring).FirstOrDefault();

            if (user == null)
            {
                return(BadRequest(Messages.UserNotFoundError));
            }

            Survey survey = _dBContext.Survey.Where(x => x.CreatedBy == user.Userid && x.Surveyid == surveyId).FirstOrDefault();

            if (survey == null)
            {
                return(BadRequest(Messages.SurveyNotFoundError));
            }

            SurveyUser surveyUser = _dBContext.SurveyUser.Where(x => x.SurveyId == surveyId && x.SurveyUserId == surveyFeedbackViewModel.FeedbackId).FirstOrDefault();

            if (surveyUser == null)
            {
                return(BadRequest(Messages.FeedbackNotFound));
            }

            surveyUser.ReviewComment   = surveyFeedbackViewModel.Comment;
            surveyUser.ReviewCompleted = Convert.ToBoolean(surveyFeedbackViewModel.reviewComplete) ? 1 : 0;
            surveyUser.ReviewDatetime  = DateTime.UtcNow;
            _dBContext.SurveyUser.Update(surveyUser);
            _dBContext.SaveChanges();
            return(Ok(surveyUser));
        }