Ejemplo n.º 1
0
        private void SendToUser(long surveyId, long poolSurveyId, long userId)
        {
            TblUserSurvey tblUserSurvey = new TblUserSurvey();

            tblUserSurvey.SurveyId     = surveyId;
            tblUserSurvey.PoolSurveyId = poolSurveyId;
            tblUserSurvey.UserId       = userId;

            _context.TblUserSurvey.Add(tblUserSurvey);
            _context.SaveChanges();
            //return true;
        }
Ejemplo n.º 2
0
        public bool UpdateSurveyDetail(Int64?sid, Int64?uid)
        {
            TblUserSurvey userSurvey = _context.TblUserSurvey.Include(i => i.Survey).Where(i => i.SurveyId == sid && i.UserId == uid).FirstOrDefault();
            TblUser       user       = _context.TblUser.Where(i => i.Id == uid).FirstOrDefault();

            if (userSurvey != null)
            {
                userSurvey.IsCompleted   = true;
                userSurvey.CompletedDate = DateTime.Now;
                if (userSurvey.Survey != null)
                {
                    userSurvey.AwardedPoints = userSurvey.Survey.Points;
                    if (user != null)
                    {
                        if (user.CurrentCreditPoints == null || user.CurrentCreditPoints == 0)
                        {
                            user.CurrentCreditPoints = userSurvey.Survey.Points;
                        }
                        else
                        {
                            user.CurrentCreditPoints = user.CurrentCreditPoints + userSurvey.Survey.Points;
                        }
                    }
                    if (userSurvey.Survey.SurveyAnswer == null || userSurvey.Survey.SurveyAnswer == 0)
                    {
                        userSurvey.Survey.SurveyAnswer = 1;
                    }
                    else
                    {
                        userSurvey.Survey.SurveyAnswer = userSurvey.Survey.SurveyAnswer + 1;
                    }
                }
            }

            return(_context.SaveChanges() > 0 ? true : false);
        }