public async Task <int> Count(SLAEscalationFRTPhoneFilter filter)
        {
            IQueryable <SLAEscalationFRTPhoneDAO> SLAEscalationFRTPhones = DataContext.SLAEscalationFRTPhone.AsNoTracking();

            SLAEscalationFRTPhones = DynamicFilter(SLAEscalationFRTPhones, filter);
            return(await SLAEscalationFRTPhones.CountAsync());
        }
Exemplo n.º 2
0
 public SLAEscalationFRTPhoneFilter ToFilter(SLAEscalationFRTPhoneFilter filter)
 {
     if (filter.OrFilter == null)
     {
         filter.OrFilter = new List <SLAEscalationFRTPhoneFilter>();
     }
     if (CurrentContext.Filters == null || CurrentContext.Filters.Count == 0)
     {
         return(filter);
     }
     foreach (var currentFilter in CurrentContext.Filters)
     {
         SLAEscalationFRTPhoneFilter subFilter = new SLAEscalationFRTPhoneFilter();
         filter.OrFilter.Add(subFilter);
         List <FilterPermissionDefinition> FilterPermissionDefinitions = currentFilter.Value;
         foreach (FilterPermissionDefinition FilterPermissionDefinition in FilterPermissionDefinitions)
         {
             if (FilterPermissionDefinition.Name == nameof(subFilter.Id))
             {
                 subFilter.Id = FilterPermissionDefinition.IdFilter;
             }
             if (FilterPermissionDefinition.Name == nameof(subFilter.SLAEscalationFRTId))
             {
                 subFilter.SLAEscalationFRTId = FilterPermissionDefinition.IdFilter;
             }
             if (FilterPermissionDefinition.Name == nameof(subFilter.Phone))
             {
                 subFilter.Phone = FilterPermissionDefinition.StringFilter;
             }
         }
     }
     return(filter);
 }
        public async Task <List <SLAEscalationFRTPhone> > List(SLAEscalationFRTPhoneFilter filter)
        {
            if (filter == null)
            {
                return(new List <SLAEscalationFRTPhone>());
            }
            IQueryable <SLAEscalationFRTPhoneDAO> SLAEscalationFRTPhoneDAOs = DataContext.SLAEscalationFRTPhone.AsNoTracking();

            SLAEscalationFRTPhoneDAOs = DynamicFilter(SLAEscalationFRTPhoneDAOs, filter);
            SLAEscalationFRTPhoneDAOs = DynamicOrder(SLAEscalationFRTPhoneDAOs, filter);
            List <SLAEscalationFRTPhone> SLAEscalationFRTPhones = await DynamicSelect(SLAEscalationFRTPhoneDAOs, filter);

            return(SLAEscalationFRTPhones);
        }
        public async Task <bool> ValidateId(SLAEscalationFRTPhone SLAEscalationFRTPhone)
        {
            SLAEscalationFRTPhoneFilter SLAEscalationFRTPhoneFilter = new SLAEscalationFRTPhoneFilter
            {
                Skip = 0,
                Take = 10,
                Id   = new IdFilter {
                    Equal = SLAEscalationFRTPhone.Id
                },
                Selects = SLAEscalationFRTPhoneSelect.Id
            };

            int count = await UOW.SLAEscalationFRTPhoneRepository.Count(SLAEscalationFRTPhoneFilter);

            if (count == 0)
            {
                SLAEscalationFRTPhone.AddError(nameof(SLAEscalationFRTPhoneValidator), nameof(SLAEscalationFRTPhone.Id), ErrorCode.IdNotExisted);
            }
            return(count == 1);
        }
Exemplo n.º 5
0
        public async Task <List <SLAEscalationFRTPhone> > List(SLAEscalationFRTPhoneFilter SLAEscalationFRTPhoneFilter)
        {
            try
            {
                List <SLAEscalationFRTPhone> SLAEscalationFRTPhones = await UOW.SLAEscalationFRTPhoneRepository.List(SLAEscalationFRTPhoneFilter);

                return(SLAEscalationFRTPhones);
            }
            catch (Exception ex)
            {
                if (ex.InnerException == null)
                {
                    await Logging.CreateSystemLog(ex, nameof(SLAEscalationFRTPhoneService));

                    throw new MessageException(ex);
                }
                else
                {
                    await Logging.CreateSystemLog(ex.InnerException, nameof(SLAEscalationFRTPhoneService));

                    throw new MessageException(ex.InnerException);
                }
            }
        }
Exemplo n.º 6
0
        public async Task <int> Count(SLAEscalationFRTPhoneFilter SLAEscalationFRTPhoneFilter)
        {
            try
            {
                int result = await UOW.SLAEscalationFRTPhoneRepository.Count(SLAEscalationFRTPhoneFilter);

                return(result);
            }
            catch (Exception ex)
            {
                if (ex.InnerException == null)
                {
                    await Logging.CreateSystemLog(ex, nameof(SLAEscalationFRTPhoneService));

                    throw new MessageException(ex);
                }
                else
                {
                    await Logging.CreateSystemLog(ex.InnerException, nameof(SLAEscalationFRTPhoneService));

                    throw new MessageException(ex.InnerException);
                }
            }
        }
        private IQueryable <SLAEscalationFRTPhoneDAO> DynamicOrder(IQueryable <SLAEscalationFRTPhoneDAO> query, SLAEscalationFRTPhoneFilter filter)
        {
            switch (filter.OrderType)
            {
            case OrderType.ASC:
                switch (filter.OrderBy)
                {
                case SLAEscalationFRTPhoneOrder.Id:
                    query = query.OrderBy(q => q.Id);
                    break;

                case SLAEscalationFRTPhoneOrder.SLAEscalationFRT:
                    query = query.OrderBy(q => q.SLAEscalationFRTId);
                    break;

                case SLAEscalationFRTPhoneOrder.Phone:
                    query = query.OrderBy(q => q.Phone);
                    break;
                }
                break;

            case OrderType.DESC:
                switch (filter.OrderBy)
                {
                case SLAEscalationFRTPhoneOrder.Id:
                    query = query.OrderByDescending(q => q.Id);
                    break;

                case SLAEscalationFRTPhoneOrder.SLAEscalationFRT:
                    query = query.OrderByDescending(q => q.SLAEscalationFRTId);
                    break;

                case SLAEscalationFRTPhoneOrder.Phone:
                    query = query.OrderByDescending(q => q.Phone);
                    break;
                }
                break;
            }
            query = query.Skip(filter.Skip).Take(filter.Take);
            return(query);
        }
        private IQueryable <SLAEscalationFRTPhoneDAO> OrFilter(IQueryable <SLAEscalationFRTPhoneDAO> query, SLAEscalationFRTPhoneFilter filter)
        {
            if (filter.OrFilter == null || filter.OrFilter.Count == 0)
            {
                return(query);
            }
            IQueryable <SLAEscalationFRTPhoneDAO> initQuery = query.Where(q => false);

            foreach (SLAEscalationFRTPhoneFilter SLAEscalationFRTPhoneFilter in filter.OrFilter)
            {
                IQueryable <SLAEscalationFRTPhoneDAO> queryable = query;
                if (SLAEscalationFRTPhoneFilter.Id != null)
                {
                    queryable = queryable.Where(q => q.Id, SLAEscalationFRTPhoneFilter.Id);
                }
                if (SLAEscalationFRTPhoneFilter.SLAEscalationFRTId != null)
                {
                    queryable = queryable.Where(q => q.SLAEscalationFRTId.HasValue).Where(q => q.SLAEscalationFRTId, SLAEscalationFRTPhoneFilter.SLAEscalationFRTId);
                }
                if (SLAEscalationFRTPhoneFilter.Phone != null)
                {
                    queryable = queryable.Where(q => q.Phone, SLAEscalationFRTPhoneFilter.Phone);
                }
                initQuery = initQuery.Union(queryable);
            }
            return(initQuery);
        }
 private IQueryable <SLAEscalationFRTPhoneDAO> DynamicFilter(IQueryable <SLAEscalationFRTPhoneDAO> query, SLAEscalationFRTPhoneFilter filter)
 {
     if (filter == null)
     {
         return(query.Where(q => false));
     }
     query = query.Where(q => !q.DeletedAt.HasValue);
     if (filter.CreatedAt != null)
     {
         query = query.Where(q => q.CreatedAt, filter.CreatedAt);
     }
     if (filter.UpdatedAt != null)
     {
         query = query.Where(q => q.UpdatedAt, filter.UpdatedAt);
     }
     if (filter.Id != null)
     {
         query = query.Where(q => q.Id, filter.Id);
     }
     if (filter.SLAEscalationFRTId != null)
     {
         query = query.Where(q => q.SLAEscalationFRTId.HasValue).Where(q => q.SLAEscalationFRTId, filter.SLAEscalationFRTId);
     }
     if (filter.Phone != null)
     {
         query = query.Where(q => q.Phone, filter.Phone);
     }
     query = OrFilter(query, filter);
     return(query);
 }
        private async Task <List <SLAEscalationFRTPhone> > DynamicSelect(IQueryable <SLAEscalationFRTPhoneDAO> query, SLAEscalationFRTPhoneFilter filter)
        {
            List <SLAEscalationFRTPhone> SLAEscalationFRTPhones = await query.Select(q => new SLAEscalationFRTPhone()
            {
                Id = filter.Selects.Contains(SLAEscalationFRTPhoneSelect.Id) ? q.Id : default(long),
                SLAEscalationFRTId = filter.Selects.Contains(SLAEscalationFRTPhoneSelect.SLAEscalationFRT) ? q.SLAEscalationFRTId : default(long?),
                Phone            = filter.Selects.Contains(SLAEscalationFRTPhoneSelect.Phone) ? q.Phone : default(string),
                SLAEscalationFRT = filter.Selects.Contains(SLAEscalationFRTPhoneSelect.SLAEscalationFRT) && q.SLAEscalationFRT != null ? new SLAEscalationFRT
                {
                    Id = q.SLAEscalationFRT.Id,
                    TicketIssueLevelId = q.SLAEscalationFRT.TicketIssueLevelId,
                    IsNotification     = q.SLAEscalationFRT.IsNotification,
                    IsMail             = q.SLAEscalationFRT.IsMail,
                    IsSMS             = q.SLAEscalationFRT.IsSMS,
                    Time              = q.SLAEscalationFRT.Time,
                    TimeUnitId        = q.SLAEscalationFRT.TimeUnitId,
                    IsAssignedToUser  = q.SLAEscalationFRT.IsAssignedToUser,
                    IsAssignedToGroup = q.SLAEscalationFRT.IsAssignedToGroup,
                    SmsTemplateId     = q.SLAEscalationFRT.SmsTemplateId,
                    MailTemplateId    = q.SLAEscalationFRT.MailTemplateId,
                } : null,
                CreatedAt = q.CreatedAt,
                UpdatedAt = q.UpdatedAt,
            }).ToListAsync();

            return(SLAEscalationFRTPhones);
        }