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 }); }
public DeleteOutput <long> Delete(DeleteInput <long> input) { throw new NotSupportedException("This method is implemented but it is not safely to use it."); GameTaskType gameTaskTypeEntityForDelete = GameTaskTypeRepository.Get(input.EntityId); if (gameTaskTypeEntityForDelete == null) { throw new CityQuestItemNotFoundException(CityQuestConsts.CityQuestItemNotFoundExceptionMessageBody, "\"GameTaskType\""); } if (!GameTaskTypePolicy.CanDeleteEntity(gameTaskTypeEntityForDelete)) { throw new CityQuestPolicyException(CityQuestConsts.CQPolicyExceptionDeleteDenied, "\"GameTaskType\""); } GameTaskTypeRepository.Delete(gameTaskTypeEntityForDelete); return(new DeleteOutput <long>() { DeletedEntityId = input.EntityId }); }