Beispiel #1
0
        public AnswerOnRequestOutput AnswerOnRequest(AnswerOnRequestInput input)
        {
            TeamRequest teamRequestEntity = TeamRequestRepository.Get(input.TeamRequestId);

            if (teamRequestEntity == null)
            {
                throw new CityQuestItemNotFoundException(CityQuestConsts.CityQuestItemNotFoundExceptionMessageBody, "\"TeamRequest\"");
            }

            if (!TeamRequestPolicy.CanAnswerOnRequestFromTeam(teamRequestEntity))
            {
                throw new CityQuestPolicyException(CityQuestConsts.CQPolicyExceptionUpdateDenied, "\"TeamRequest\"");
            }

            DateTime currentDT = DateTime.Now;

            teamRequestEntity.InvitedUserResponse         = input.Answer;
            teamRequestEntity.InvitedUserResponseDateTime = currentDT;
            TeamRequestRepository.Update(teamRequestEntity);

            #region Creating new career if joined new team

            if (teamRequestEntity.InvitedUserResponse == true)
            {
                CreateNewPlayerCareer(teamRequestEntity.InvitedUserId, teamRequestEntity.TeamId, currentDT);
            }

            #endregion

            return(new AnswerOnRequestOutput()
            {
                TeamRequest = teamRequestEntity.MapTo <TeamRequestDto>(),
            });
        }
Beispiel #2
0
        public DenyRequestOutput DenyRequest(DenyRequestInput input)
        {
            TeamRequest teamRequestEntity = TeamRequestRepository.Get(input.TeamRequestId);

            if (teamRequestEntity == null)
            {
                throw new CityQuestItemNotFoundException(CityQuestConsts.CityQuestItemNotFoundExceptionMessageBody, "\"TeamRequest\"");
            }

            if (!TeamRequestPolicy.CanDenyRequestToPlayer(teamRequestEntity))
            {
                throw new CityQuestPolicyException(CityQuestConsts.CQPolicyExceptionUpdateDenied, "\"TeamRequest\"");
            }

            DateTime currentDT = DateTime.Now;

            teamRequestEntity.DeclinedByInviter         = true;
            teamRequestEntity.DeclinedByInviterDateTime = currentDT;
            TeamRequestRepository.Update(teamRequestEntity);

            return(new DenyRequestOutput()
            {
            });
        }