public async Task <bool> StatusUpdate(Guid userId, Guid reportId, Guid newStatusId, string updateDescription) { var reportToUpdate = await _reportRepository.GetById(reportId); Guid oldStatus = reportToUpdate.ReportStatusId; reportToUpdate.ReportStatusId = newStatusId; await _reportRepository.Update(reportToUpdate); InteractionHistory interaction = new InteractionHistory() { UserId = userId, ReportId = reportId, oldReportStatusId = oldStatus, NewReportStatusId = newStatusId, Description = updateDescription, CreationDate = DateTime.Now }; await _interactionRepository.Add(interaction); var currentStatus = await _statusRepository.GetById(newStatusId); if (currentStatus.InProgress) { var records = await _progressRepo.Find(x => x.ReportId == reportToUpdate.Id); if (!records.Any()) { ReportInProgress inProgress = new ReportInProgress() { InteractionHistoryId = interaction.Id, ReportId = reportToUpdate.Id, UserId = interaction.UserId, CreationDate = DateTime.Now }; //TO-DO: Disparar notificacao para os usuários await _progressRepo.Add(inProgress); } } await SendNotifications(reportToUpdate, interaction.Id); return(true); }
public async Task Add(ReportInProgress report) { await _repository.Add(report); }