public async Task <Result> DeleteWorkAsync(Guid id) { var existWork = await _workRepository.ExistAsync(id); if (!existWork) { return(new Result(Status.NotFund, $"Work with {nameof(id)} does not exist")); } var work = await _workRepository.GetByIdAsync(id); await _workRepository.DeleteAsync(work); var result = await _mockyService.SendNotificationAsync("Lançamento de horas", "Um lançamento de horas foi removido"); if (!result.Success || !result.Data) { return(new Result(Status.Error, result.ErrorMessages)); } return(new Result()); }
public async Task <Result <ProjectWorkDetailDto> > GetProjectWorkByIdAsync(Guid id) { var existWork = await _workRepository.ExistAsync(id); if (!existWork) { return(new Result <ProjectWorkDetailDto>(Status.NotFund, $"Work with {nameof(id)} does not exist")); } var work = await _workRepository.Query() .Include(w => w.DeveloperProject) .ThenInclude(dp => dp.Project) .Include(w => w.DeveloperProject) .ThenInclude(dp => dp.Developer) .SingleAsync(p => p.Id == id); var workDetail = new ProjectWorkDetailDto { Id = work.Id, StartTime = work.StartTime, EndTime = work.EndTime, Comment = work.Comment, Hours = work.Hours, Project = new ProjectListDto { Id = work.DeveloperProject.ProjectId, Title = work.DeveloperProject.Project.Title }, Developer = new DeveloperListDto { Id = work.DeveloperProject.DeveloperId, Name = work.DeveloperProject.Developer.Name } }; return(new Result <ProjectWorkDetailDto>(workDetail)); }