public async Task <SLAAlertMail> Get(long Id) { SLAAlertMail SLAAlertMail = await DataContext.SLAAlertMail.AsNoTracking() .Where(x => x.Id == Id).Select(x => new SLAAlertMail() { CreatedAt = x.CreatedAt, UpdatedAt = x.UpdatedAt, Id = x.Id, SLAAlertId = x.SLAAlertId, Mail = x.Mail, SLAAlert = x.SLAAlert == null ? null : new SLAAlert { Id = x.SLAAlert.Id, TicketIssueLevelId = x.SLAAlert.TicketIssueLevelId, IsNotification = x.SLAAlert.IsNotification, IsMail = x.SLAAlert.IsMail, IsSMS = x.SLAAlert.IsSMS, Time = x.SLAAlert.Time, TimeUnitId = x.SLAAlert.TimeUnitId, IsAssignedToUser = x.SLAAlert.IsAssignedToUser, IsAssignedToGroup = x.SLAAlert.IsAssignedToGroup, SmsTemplateId = x.SLAAlert.SmsTemplateId, MailTemplateId = x.SLAAlert.MailTemplateId, }, }).FirstOrDefaultAsync(); if (SLAAlertMail == null) { return(null); } return(SLAAlertMail); }
public async Task <bool> Delete(SLAAlertMail SLAAlertMail) { if (await ValidateId(SLAAlertMail)) { } return(SLAAlertMail.IsValidated); }
public async Task <bool> Delete(SLAAlertMail SLAAlertMail) { await DataContext.SLAAlertMail.Where(x => x.Id == SLAAlertMail.Id).UpdateFromQueryAsync(x => new SLAAlertMailDAO { DeletedAt = StaticParams.DateTimeNow }); return(true); }
public async Task <SLAAlertMail> Get(long Id) { SLAAlertMail SLAAlertMail = await UOW.SLAAlertMailRepository.Get(Id); if (SLAAlertMail == null) { return(null); } return(SLAAlertMail); }
public TicketIssueLevel_SLAAlertMailDTO(SLAAlertMail SLAAlertMail) { this.Id = SLAAlertMail.Id; this.SLAAlertId = SLAAlertMail.SLAAlertId; this.Mail = SLAAlertMail.Mail; this.SLAAlert = SLAAlertMail.SLAAlert == null ? null : new TicketIssueLevel_SLAAlertDTO(SLAAlertMail.SLAAlert); this.CreatedAt = SLAAlertMail.CreatedAt; this.UpdatedAt = SLAAlertMail.UpdatedAt; this.Errors = SLAAlertMail.Errors; }
public async Task <bool> Create(SLAAlertMail SLAAlertMail) { SLAAlertMailDAO SLAAlertMailDAO = new SLAAlertMailDAO(); SLAAlertMailDAO.Id = SLAAlertMail.Id; SLAAlertMailDAO.SLAAlertId = SLAAlertMail.SLAAlertId; SLAAlertMailDAO.Mail = SLAAlertMail.Mail; SLAAlertMailDAO.CreatedAt = StaticParams.DateTimeNow; SLAAlertMailDAO.UpdatedAt = StaticParams.DateTimeNow; DataContext.SLAAlertMail.Add(SLAAlertMailDAO); await DataContext.SaveChangesAsync(); SLAAlertMail.Id = SLAAlertMailDAO.Id; await SaveReference(SLAAlertMail); return(true); }
public async Task <bool> Update(SLAAlertMail SLAAlertMail) { SLAAlertMailDAO SLAAlertMailDAO = DataContext.SLAAlertMail.Where(x => x.Id == SLAAlertMail.Id).FirstOrDefault(); if (SLAAlertMailDAO == null) { return(false); } SLAAlertMailDAO.Id = SLAAlertMail.Id; SLAAlertMailDAO.SLAAlertId = SLAAlertMail.SLAAlertId; SLAAlertMailDAO.Mail = SLAAlertMail.Mail; SLAAlertMailDAO.UpdatedAt = StaticParams.DateTimeNow; await DataContext.SaveChangesAsync(); await SaveReference(SLAAlertMail); return(true); }
public async Task <bool> ValidateId(SLAAlertMail SLAAlertMail) { SLAAlertMailFilter SLAAlertMailFilter = new SLAAlertMailFilter { Skip = 0, Take = 10, Id = new IdFilter { Equal = SLAAlertMail.Id }, Selects = SLAAlertMailSelect.Id }; int count = await UOW.SLAAlertMailRepository.Count(SLAAlertMailFilter); if (count == 0) { SLAAlertMail.AddError(nameof(SLAAlertMailValidator), nameof(SLAAlertMail.Id), ErrorCode.IdNotExisted); } return(count == 1); }
public async Task <SLAAlertMail> Update(SLAAlertMail SLAAlertMail) { if (!await SLAAlertMailValidator.Update(SLAAlertMail)) { return(SLAAlertMail); } try { var oldData = await UOW.SLAAlertMailRepository.Get(SLAAlertMail.Id); await UOW.Begin(); await UOW.SLAAlertMailRepository.Update(SLAAlertMail); await UOW.Commit(); SLAAlertMail = await UOW.SLAAlertMailRepository.Get(SLAAlertMail.Id); await Logging.CreateAuditLog(SLAAlertMail, oldData, nameof(SLAAlertMailService)); return(SLAAlertMail); } catch (Exception ex) { await UOW.Rollback(); if (ex.InnerException == null) { await Logging.CreateSystemLog(ex, nameof(SLAAlertMailService)); throw new MessageException(ex); } else { await Logging.CreateSystemLog(ex.InnerException, nameof(SLAAlertMailService)); throw new MessageException(ex.InnerException); } } }
public async Task <bool> Create(SLAAlertMail SLAAlertMail) { return(SLAAlertMail.IsValidated); }
private async Task SaveReference(SLAAlertMail SLAAlertMail) { }