示例#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>(),
            });
        }
示例#2
0
        public DeleteOutput <long> Delete(DeleteInput <long> input)
        {
            TeamRequest teamRequestEntityForDelete = TeamRequestRepository.Get(input.EntityId);

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

            if (!TeamRequestPolicy.CanDeleteEntity(teamRequestEntityForDelete))
            {
                throw new CityQuestPolicyException(CityQuestConsts.CQPolicyExceptionDeleteDenied, "\"TeamRequest\"");
            }

            TeamRequestRepository.Delete(teamRequestEntityForDelete);

            return(new DeleteOutput <long>()
            {
                DeletedEntityId = input.EntityId
            });
        }
示例#3
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()
            {
            });
        }