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 }); }
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 }); }