public async Task <bool> Delete(SLAAlertUser SLAAlertUser) { if (await ValidateId(SLAAlertUser)) { } return(SLAAlertUser.IsValidated); }
public async Task <bool> Delete(SLAAlertUser SLAAlertUser) { await DataContext.SLAAlertUser.Where(x => x.Id == SLAAlertUser.Id).UpdateFromQueryAsync(x => new SLAAlertUserDAO { DeletedAt = StaticParams.DateTimeNow }); return(true); }
public async Task <SLAAlertUser> Get(long Id) { SLAAlertUser SLAAlertUser = await UOW.SLAAlertUserRepository.Get(Id); if (SLAAlertUser == null) { return(null); } return(SLAAlertUser); }
public TicketIssueLevel_SLAAlertUserDTO(SLAAlertUser SLAAlertUser) { this.Id = SLAAlertUser.Id; this.SLAAlertId = SLAAlertUser.SLAAlertId; this.AppUserId = SLAAlertUser.AppUserId; this.AppUser = SLAAlertUser.AppUser == null ? null : new TicketIssueLevel_AppUserDTO(SLAAlertUser.AppUser); this.SLAAlert = SLAAlertUser.SLAAlert == null ? null : new TicketIssueLevel_SLAAlertDTO(SLAAlertUser.SLAAlert); this.CreatedAt = SLAAlertUser.CreatedAt; this.UpdatedAt = SLAAlertUser.UpdatedAt; this.Errors = SLAAlertUser.Errors; }
public async Task <SLAAlertUser> Get(long Id) { SLAAlertUser SLAAlertUser = await DataContext.SLAAlertUser.AsNoTracking() .Where(x => x.Id == Id).Select(x => new SLAAlertUser() { CreatedAt = x.CreatedAt, UpdatedAt = x.UpdatedAt, Id = x.Id, SLAAlertId = x.SLAAlertId, AppUserId = x.AppUserId, AppUser = x.AppUser == null ? null : new AppUser { Id = x.AppUser.Id, Username = x.AppUser.Username, DisplayName = x.AppUser.DisplayName, Address = x.AppUser.Address, Email = x.AppUser.Email, Phone = x.AppUser.Phone, SexId = x.AppUser.SexId, Birthday = x.AppUser.Birthday, Avatar = x.AppUser.Avatar, Department = x.AppUser.Department, OrganizationId = x.AppUser.OrganizationId, Longitude = x.AppUser.Longitude, Latitude = x.AppUser.Latitude, StatusId = x.AppUser.StatusId, }, 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 (SLAAlertUser == null) { return(null); } return(SLAAlertUser); }
public async Task <bool> Create(SLAAlertUser SLAAlertUser) { SLAAlertUserDAO SLAAlertUserDAO = new SLAAlertUserDAO(); SLAAlertUserDAO.Id = SLAAlertUser.Id; SLAAlertUserDAO.SLAAlertId = SLAAlertUser.SLAAlertId; SLAAlertUserDAO.AppUserId = SLAAlertUser.AppUserId; SLAAlertUserDAO.CreatedAt = StaticParams.DateTimeNow; SLAAlertUserDAO.UpdatedAt = StaticParams.DateTimeNow; DataContext.SLAAlertUser.Add(SLAAlertUserDAO); await DataContext.SaveChangesAsync(); SLAAlertUser.Id = SLAAlertUserDAO.Id; await SaveReference(SLAAlertUser); return(true); }
public async Task <bool> Update(SLAAlertUser SLAAlertUser) { SLAAlertUserDAO SLAAlertUserDAO = DataContext.SLAAlertUser.Where(x => x.Id == SLAAlertUser.Id).FirstOrDefault(); if (SLAAlertUserDAO == null) { return(false); } SLAAlertUserDAO.Id = SLAAlertUser.Id; SLAAlertUserDAO.SLAAlertId = SLAAlertUser.SLAAlertId; SLAAlertUserDAO.AppUserId = SLAAlertUser.AppUserId; SLAAlertUserDAO.UpdatedAt = StaticParams.DateTimeNow; await DataContext.SaveChangesAsync(); await SaveReference(SLAAlertUser); return(true); }
public async Task <bool> ValidateId(SLAAlertUser SLAAlertUser) { SLAAlertUserFilter SLAAlertUserFilter = new SLAAlertUserFilter { Skip = 0, Take = 10, Id = new IdFilter { Equal = SLAAlertUser.Id }, Selects = SLAAlertUserSelect.Id }; int count = await UOW.SLAAlertUserRepository.Count(SLAAlertUserFilter); if (count == 0) { SLAAlertUser.AddError(nameof(SLAAlertUserValidator), nameof(SLAAlertUser.Id), ErrorCode.IdNotExisted); } return(count == 1); }
public async Task <SLAAlertUser> Update(SLAAlertUser SLAAlertUser) { if (!await SLAAlertUserValidator.Update(SLAAlertUser)) { return(SLAAlertUser); } try { var oldData = await UOW.SLAAlertUserRepository.Get(SLAAlertUser.Id); await UOW.Begin(); await UOW.SLAAlertUserRepository.Update(SLAAlertUser); await UOW.Commit(); SLAAlertUser = await UOW.SLAAlertUserRepository.Get(SLAAlertUser.Id); await Logging.CreateAuditLog(SLAAlertUser, oldData, nameof(SLAAlertUserService)); return(SLAAlertUser); } catch (Exception ex) { await UOW.Rollback(); if (ex.InnerException == null) { await Logging.CreateSystemLog(ex, nameof(SLAAlertUserService)); throw new MessageException(ex); } else { await Logging.CreateSystemLog(ex.InnerException, nameof(SLAAlertUserService)); throw new MessageException(ex.InnerException); } } }
public async Task <bool> Create(SLAAlertUser SLAAlertUser) { return(SLAAlertUser.IsValidated); }
private async Task SaveReference(SLAAlertUser SLAAlertUser) { }