Ejemplo n.º 1
0
        public async Task <int> Count(SLAAlertFRTUserFilter filter)
        {
            IQueryable <SLAAlertFRTUserDAO> SLAAlertFRTUsers = DataContext.SLAAlertFRTUser.AsNoTracking();

            SLAAlertFRTUsers = DynamicFilter(SLAAlertFRTUsers, filter);
            return(await SLAAlertFRTUsers.CountAsync());
        }
Ejemplo n.º 2
0
        public async Task <bool> ValidateId(SLAAlertFRTUser SLAAlertFRTUser)
        {
            SLAAlertFRTUserFilter SLAAlertFRTUserFilter = new SLAAlertFRTUserFilter
            {
                Skip = 0,
                Take = 10,
                Id   = new IdFilter {
                    Equal = SLAAlertFRTUser.Id
                },
                Selects = SLAAlertFRTUserSelect.Id
            };

            int count = await UOW.SLAAlertFRTUserRepository.Count(SLAAlertFRTUserFilter);

            if (count == 0)
            {
                SLAAlertFRTUser.AddError(nameof(SLAAlertFRTUserValidator), nameof(SLAAlertFRTUser.Id), ErrorCode.IdNotExisted);
            }
            return(count == 1);
        }
Ejemplo n.º 3
0
        private async Task <List <SLAAlertFRTUser> > DynamicSelect(IQueryable <SLAAlertFRTUserDAO> query, SLAAlertFRTUserFilter filter)
        {
            List <SLAAlertFRTUser> SLAAlertFRTUsers = await query.Select(q => new SLAAlertFRTUser()
            {
                Id            = filter.Selects.Contains(SLAAlertFRTUserSelect.Id) ? q.Id : default(long),
                SLAAlertFRTId = filter.Selects.Contains(SLAAlertFRTUserSelect.SLAAlertFRT) ? q.SLAAlertFRTId : default(long?),
                AppUserId     = filter.Selects.Contains(SLAAlertFRTUserSelect.AppUser) ? q.AppUserId : default(long?),
                AppUser       = filter.Selects.Contains(SLAAlertFRTUserSelect.AppUser) && q.AppUser != null ? new AppUser
                {
                    Id             = q.AppUser.Id,
                    Username       = q.AppUser.Username,
                    DisplayName    = q.AppUser.DisplayName,
                    Address        = q.AppUser.Address,
                    Email          = q.AppUser.Email,
                    Phone          = q.AppUser.Phone,
                    SexId          = q.AppUser.SexId,
                    Birthday       = q.AppUser.Birthday,
                    Avatar         = q.AppUser.Avatar,
                    Department     = q.AppUser.Department,
                    OrganizationId = q.AppUser.OrganizationId,
                    Longitude      = q.AppUser.Longitude,
                    Latitude       = q.AppUser.Latitude,
                    StatusId       = q.AppUser.StatusId,
                } : null,
                SLAAlertFRT = filter.Selects.Contains(SLAAlertFRTUserSelect.SLAAlertFRT) && q.SLAAlertFRT != null ? new SLAAlertFRT
                {
                    Id = q.SLAAlertFRT.Id,
                    TicketIssueLevelId = q.SLAAlertFRT.TicketIssueLevelId,
                    IsNotification     = q.SLAAlertFRT.IsNotification,
                    IsMail             = q.SLAAlertFRT.IsMail,
                    IsSMS             = q.SLAAlertFRT.IsSMS,
                    Time              = q.SLAAlertFRT.Time,
                    TimeUnitId        = q.SLAAlertFRT.TimeUnitId,
                    IsAssignedToUser  = q.SLAAlertFRT.IsAssignedToUser,
                    IsAssignedToGroup = q.SLAAlertFRT.IsAssignedToGroup,
                    SmsTemplateId     = q.SLAAlertFRT.SmsTemplateId,
                    MailTemplateId    = q.SLAAlertFRT.MailTemplateId,
                } : null,
                CreatedAt = q.CreatedAt,
                UpdatedAt = q.UpdatedAt,
            }).ToListAsync();

            return(SLAAlertFRTUsers);
        }