Пример #1
0
        public ChangeActivityOutput <GameTaskTypeDto, long> ChangeActivity(ChangeActivityInput input)
        {
            GameTaskTypeRepository.Includes.Add(r => r.LastModifierUser);
            GameTaskTypeRepository.Includes.Add(r => r.CreatorUser);

            GameTaskType gameTaskTypeEntity = GameTaskTypeRepository.Get(input.EntityId);

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

            if (!GameTaskTypePolicy.CanChangeActivityForEntity(gameTaskTypeEntity))
            {
                throw new CityQuestPolicyException(CityQuestConsts.CQPolicyExceptionChangeActivityDenied, "\"GameTaskType\"");
            }

            gameTaskTypeEntity.IsActive = input.IsActive == null ? !gameTaskTypeEntity.IsActive : (bool)input.IsActive;

            GameTaskTypeDto newGameTaskTypeDto = (gameTaskTypeEntity).MapTo <GameTaskTypeDto>();

            GameTaskTypeRepository.Update(gameTaskTypeEntity);

            GameTaskTypeRepository.Includes.Clear();

            return(new ChangeActivityOutput <GameTaskTypeDto, long>()
            {
                Entity = newGameTaskTypeDto
            });
        }
Пример #2
0
        public CreateOutput <GameTaskTypeDto, long> Create(CreateInput <GameTaskTypeDto, long> input)
        {
            throw new NotSupportedException("This method is implemented but it is not safely to use it.");

            GameTaskType newGameTaskTypeEntity = input.Entity.MapTo <GameTaskType>();

            newGameTaskTypeEntity.IsDefault = false;
            newGameTaskTypeEntity.IsActive  = true;

            if (!GameTaskTypePolicy.CanCreateEntity(newGameTaskTypeEntity))
            {
                throw new CityQuestPolicyException(CityQuestConsts.CQPolicyExceptionCreateDenied, "\"GameTaskType\"");
            }

            GameTaskTypeRepository.Includes.Add(r => r.LastModifierUser);
            GameTaskTypeRepository.Includes.Add(r => r.CreatorUser);

            GameTaskTypeDto newGameTaskTypeDto = (GameTaskTypeRepository.Insert(newGameTaskTypeEntity)).MapTo <GameTaskTypeDto>();

            GameTaskTypeRepository.Includes.Clear();

            return(new CreateOutput <GameTaskTypeDto, long>()
            {
                CreatedEntity = newGameTaskTypeDto
            });
        }
Пример #3
0
        public UpdateOutput <GameTaskTypeDto, long> Update(UpdateInput <GameTaskTypeDto, long> input)
        {
            throw new NotSupportedException("This method is implemented but it is not safely to use it.");

            GameTaskType newGameTaskTypeEntity = input.Entity.MapTo <GameTaskType>();

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

            if (!GameTaskTypePolicy.CanUpdateEntity(newGameTaskTypeEntity))
            {
                throw new CityQuestPolicyException(CityQuestConsts.CQPolicyExceptionUpdateDenied, "\"GameTaskType\"");
            }

            GameTaskTypeRepository.Includes.Add(r => r.LastModifierUser);
            GameTaskTypeRepository.Includes.Add(r => r.CreatorUser);

            GameTaskTypeRepository.Update(newGameTaskTypeEntity);
            GameTaskTypeDto newGameTaskTypeDto = (GameTaskTypeRepository.Get(newGameTaskTypeEntity.Id)).MapTo <GameTaskTypeDto>();

            GameTaskTypeRepository.Includes.Clear();

            return(new UpdateOutput <GameTaskTypeDto, long>()
            {
                UpdatedEntity = newGameTaskTypeDto
            });
        }
Пример #4
0
        public RetrieveOutput <GameTaskTypeDto, long> Retrieve(RetrieveGameTaskTypeInput input)
        {
            if (input.IsActive ?? true)
            {
                UowManager.Current.EnableFilter(Filters.IPassivableFilter);
            }

            GameTaskTypeRepository.Includes.Add(r => r.LastModifierUser);
            GameTaskTypeRepository.Includes.Add(r => r.CreatorUser);

            IList <GameTaskType> gameTaskTypeEntities = GameTaskTypeRepository.GetAll()
                                                        .WhereIf(input.Id != null, r => r.Id == input.Id)
                                                        .WhereIf(!String.IsNullOrEmpty(input.Name), r => r.Name.ToLower().Contains(input.Name.ToLower()))
                                                        .ToList();

            if (gameTaskTypeEntities.Count != 1)
            {
                throw new CityQuestItemNotFoundException(CityQuestConsts.CityQuestItemNotFoundExceptionMessageBody, "\"GameTaskType\"");
            }

            if (!GameTaskTypePolicy.CanRetrieveEntity(gameTaskTypeEntities.Single()))
            {
                throw new CityQuestPolicyException(CityQuestConsts.CQPolicyExceptionRetrieveDenied, "\"GameTaskType\"");
            }

            GameTaskTypeDto gameTaskTypeEntity = gameTaskTypeEntities.Single().MapTo <GameTaskTypeDto>();

            GameTaskTypeRepository.Includes.Clear();

            return(new RetrieveOutput <GameTaskTypeDto, long>()
            {
                RetrievedEntity = gameTaskTypeEntity
            });
        }