public async Task <Response <Project> > Handle(GetProjectByIdQuery query, CancellationToken cancellationToken) { var Project = await _ProjectRepository.GetByIdAsync(query.Id); if (Project == null) { throw new ApiException($"Project Not Found."); } return(new Response <Project>(Project)); }
public async Task <Response <int> > Handle(DeleteProjectByIdCommand command, CancellationToken cancellationToken) { var Project = await _ProjectRepository.GetByIdAsync(command.Id); if (Project == null) { throw new ApiException($"Project Not Found."); } await _ProjectRepository.DeleteAsync(Project); return(new Response <int>(Project.Id)); }
public async Task <Response <int> > Handle(UpdateProjectCommand command, CancellationToken cancellationToken) { var Project = await _ProjectRepository.GetByIdAsync(command.Id); if (Project == null) { throw new ApiException($"Project Not Found."); } else { Project.Name = command.Name; Project.Description = command.Description; await _ProjectRepository.UpdateAsync(Project); return(new Response <int>(Project.Id)); } }