Exemplo n.º 1
0
        private DailyRewardModel GetSpecialDailyRewardModel(int[] qtSpecialList, DailyReward reward, int[] qtOwnerList, int[] qtOthersList, QuizzOverviewModel item)
        {
            DailyRewardModel model = new DailyRewardModel
            {
                DailyRewardId   = reward.Id,
                IsTaken         = false,
                Points          = 0,
                AvailablePoints = _svcContainer.QuizzPointsSvc.GetPointsFor(QuizzPointsEnum.DailySpecialQuizz)
            };;

            bool qtSpecialListHasId = qtSpecialList.Contains(reward.Id);

            if (qtSpecialList.Length < QuizzPointsService.MaxDailySpecialQuizzTake)
            {
                model.IsTaken = qtSpecialListHasId;
            }
            else
            {
                if (qtSpecialListHasId)
                {
                    model.IsTaken = true;
                }
                else
                {
                    model = GetNormalDailRewardModel(qtOwnerList, qtOthersList, item);
                }
            }

            return(model);
        }
Exemplo n.º 2
0
        public void UpdateWithDailyReward(
            IEnumerable <DailyReward> dailyRewardList, IEnumerable <QuizzOverviewModel> qoList)
        {
            var qtSpecialList = HelperUtil.GetIntArrayFromString(_currentUser.DailySpecialPointsQuizzStrList);
            var qtOwnerList   = HelperUtil.GetIntArrayFromString(_currentUser.DailyNormalPointsQuizzSelfStrList);
            var qtOthersList  = HelperUtil.GetIntArrayFromString(_currentUser.DailyNormalPointsQuizzOthersStrList);

            foreach (var item in qoList)
            {
                DailyRewardModel model = null;
                var reward             = dailyRewardList.Where(dr => dr.QuizzId == item.Id)
                                         .FirstOrDefault();

                if (reward != null)
                {
                    model = GetSpecialDailyRewardModel(qtSpecialList, reward, qtOwnerList, qtOthersList, item);
                }
                else
                {
                    model = GetNormalDailRewardModel(qtOwnerList, qtOthersList, item);
                }

                item.DailyReward = model;
            }
        }
Exemplo n.º 3
0
        private DailyRewardModel GetNormalDailRewardModel(int[] qtOwnerList, int[] qtOthersList, QuizzOverviewModel item)
        {
            DailyRewardModel model = new DailyRewardModel()
            {
                DailyRewardId = 0
            };

            if (_svcContainer.QuizzSvc.IsAuthor(item.Id, _currentUser.Id))
            {
                model.AvailablePoints = _svcContainer.QuizzPointsSvc.GetPointsFor(QuizzPointsEnum.QuizzTakeSelf);

                if (qtOwnerList.Length < QuizzPointsService.MaxQuizzTakeSelf &&
                    qtOwnerList.Contains(item.Id) == false)
                {
                    model.IsTaken = false;
                }
                else
                {
                    model.IsTaken = true;
                }
            }
            else
            {
                model.AvailablePoints = _svcContainer.QuizzPointsSvc.GetPointsFor(QuizzPointsEnum.QUizzTakeOthers);

                if (qtOthersList.Length < QuizzPointsService.MaxQuizzTakeOthers &&
                    qtOthersList.Contains(item.Id) == false)
                {
                    model.IsTaken = false;
                }
                else
                {
                    model.IsTaken = true;
                }
            }

            return(model);
        }