private Faw.Models.Domain.Quest GetQuestInternal(Guid questId)
 {
     using (ContextScopeFactory.CreateReadOnly())
     {
         return(_questRepository.GetById(questId));
     }
 }
Пример #2
0
 public Quest GetById(Guid questId)
 {
     using (ContextScopeFactory.CreateReadOnly())
     {
         return(Mapper.Map <Quest>(_questRepository.GetById(questId)));
     }
 }
Пример #3
0
        public QuestGetModels Get(int id)
        {
            Quest quest = questRepository.GetById(id);

            return(new QuestGetModels
            {
                id = quest.ID,
                name = quest.Name,
                scenarioId = quest.ScenarioID,
                type = quest.QuestType.Name,
                dueDate = quest.DueDate,
                doneDate = quest.DoneDate,
                Latitude = quest.Latitude,
                Longitude = quest.Longitude,
                isQuiz = quest.QuestTypeID == (int)QuestTypeEnum.Quiz,
                completed = quest.Completed,
                description = quest.Description,
                points = quest.Points
            });
        }
Пример #4
0
        protected override void ExecuteRequest(HttpContext context)
        {
            (bool isOk, User user) = CheckClaimsForUser(Request, context, _userRepository);
            if (!isOk || user == null)
            {
                return;
            }

            Quest                 quest        = _questRepository.GetById(user, Request.QuestId).GetAwaiter().GetResult();
            QuestHandler          questHandler = QuestHandlers.Create(quest, user, _questTypeRepository);
            ClaimQuestDTOResponse claimQuestDTOResponse;
            string                serializedString;

            if (questHandler != null)
            {
                switch (questHandler.GetState())
                {
                case QuestState.InProgress:
                    context.Response.StatusCode = StatusCodes.Status400BadRequest;
                    claimQuestDTOResponse       = new ClaimQuestDTOResponse(QuestState.InProgress.ToString(), "0", "you cannot claim this quest, it's in progress");
                    break;

                case QuestState.Claimed:
                    context.Response.StatusCode = StatusCodes.Status400BadRequest;
                    claimQuestDTOResponse       = new ClaimQuestDTOResponse(QuestState.Claimed.ToString(), "0", "you cannot claim this quest, it was already claimed");
                    break;

                case QuestState.Failed:
                    context.Response.StatusCode = StatusCodes.Status400BadRequest;
                    claimQuestDTOResponse       = new ClaimQuestDTOResponse(QuestState.Failed.ToString(), "0", "you cannot claim this quest, it was already failed");
                    break;

                case QuestState.Finished:
                    context.Response.StatusCode = StatusCodes.Status200OK;
                    quest = _questRepository.SetIsClaimedById(user, quest.Id).GetAwaiter().GetResult();
                    _avatarRepository.AddXp(user, quest).GetAwaiter().GetResult();
                    claimQuestDTOResponse = new ClaimQuestDTOResponse(QuestState.Finished.ToString(), quest.XpValue.ToString(), "you have claimed this quest");
                    break;

                default:
                    throw new NotSupportedException();
                }
                serializedString = JsonSerializer.Serialize(claimQuestDTOResponse);
                dtoResponse      = claimQuestDTOResponse;
                context.Response.WriteAsync(serializedString).GetAwaiter().GetResult();
            }
        }