public void UpdateModel(QuizzOverviewModel model)
        {
            SetAge(model);

            if (model.OwnerId == _currentUser.Id)
            {
                model.IsQuizzmate = true;
                model.IsOwner     = true;
                model.CanEdit     = true;
            }
            else
            {
                var childIds = _currentUser.AsUserDependents.Select(ud => ud.ChildId)
                               .ToList();
                model.CanEdit = childIds.Contains(model.OwnerId);
            }

            model.OwnerName     = model.IsQuizzmate ? model.OwnerFullName : model.OwnerUserName;
            model.OwnerUserName = "";
            model.OwnerFullName = "";
        }
Пример #2
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);
        }
Пример #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);
        }