public async Task <EmailDTO> UpdateEmailStatus(EmailDTO emailDTO, StatusEmailDTO newEmailStatus, string userId) { var email = await this.context.Emails.Include(e => e.Status).FirstOrDefaultAsync(e => e.Id == emailDTO.Id); if (email is null) { Log.Information($"{DateTime.Now} Email with id {emailDTO.Id} has not found."); throw new Exception("Email is not found"); } var oldEmailStatus = email.Status.StatusType; email.StatusEmailId = newEmailStatus.Id; email.ModifiedOnDate = DateTime.Now; email.ModifiedByUserId = userId; if (newEmailStatus.StatusType == "Open Application" || newEmailStatus.StatusType == "Closed Application") { email.UserId = userId; } Log.Information($"{email.ModifiedOnDate} Update Emails by User Id: {userId}, from: {oldEmailStatus} to {newEmailStatus.StatusType}."); await this.context.SaveChangesAsync(); return(email.ToDTO()); }
public static EmailStatusViewModel ToVM(this StatusEmailDTO emailStatusDTO) { var status = new EmailStatusViewModel { Id = emailStatusDTO.Id, StatusType = emailStatusDTO.StatusType }; return(status); }
public static StatusEmailDTO ToDTO(this StatusEmail entity) { if (entity is null) { return(null); } var statusEmail = new StatusEmailDTO { Id = entity.Id, StatusType = entity.StatusType }; return(statusEmail); }