Esempio n. 1
0
        public async Task <int> Count(SLAStatusFilter filter)
        {
            IQueryable <SLAStatusDAO> SLAStatuses = DataContext.SLAStatus.AsNoTracking();

            SLAStatuses = DynamicFilter(SLAStatuses, filter);
            return(await SLAStatuses.CountAsync());
        }
Esempio n. 2
0
        private IQueryable <SLAStatusDAO> OrFilter(IQueryable <SLAStatusDAO> query, SLAStatusFilter filter)
        {
            if (filter.OrFilter == null || filter.OrFilter.Count == 0)
            {
                return(query);
            }
            IQueryable <SLAStatusDAO> initQuery = query.Where(q => false);

            foreach (SLAStatusFilter SLAStatusFilter in filter.OrFilter)
            {
                IQueryable <SLAStatusDAO> queryable = query;
                if (SLAStatusFilter.Id != null && SLAStatusFilter.Id.HasValue)
                {
                    queryable = queryable.Where(q => q.Id, SLAStatusFilter.Id);
                }
                if (SLAStatusFilter.Code != null && SLAStatusFilter.Code.HasValue)
                {
                    queryable = queryable.Where(q => q.Code, SLAStatusFilter.Code);
                }
                if (SLAStatusFilter.Name != null && SLAStatusFilter.Name.HasValue)
                {
                    queryable = queryable.Where(q => q.Name, SLAStatusFilter.Name);
                }
                if (SLAStatusFilter.ColorCode != null && SLAStatusFilter.ColorCode.HasValue)
                {
                    queryable = queryable.Where(q => q.ColorCode, SLAStatusFilter.ColorCode);
                }
                initQuery = initQuery.Union(queryable);
            }
            return(initQuery);
        }
Esempio n. 3
0
        public async Task <List <SLAStatus> > List(SLAStatusFilter filter)
        {
            if (filter == null)
            {
                return(new List <SLAStatus>());
            }
            IQueryable <SLAStatusDAO> SLAStatusDAOs = DataContext.SLAStatus.AsNoTracking();

            SLAStatusDAOs = DynamicFilter(SLAStatusDAOs, filter);
            SLAStatusDAOs = DynamicOrder(SLAStatusDAOs, filter);
            List <SLAStatus> SLAStatuses = await DynamicSelect(SLAStatusDAOs, filter);

            return(SLAStatuses);
        }
Esempio n. 4
0
        public async Task <List <SLAStatus> > List(SLAStatusFilter SLAStatusFilter)
        {
            try
            {
                List <SLAStatus> SLAStatuss = await UOW.SLAStatusRepository.List(SLAStatusFilter);

                return(SLAStatuss);
            }
            catch (Exception ex)
            {
                await Logging.CreateSystemLog(ex, nameof(SLAStatusService));
            }
            return(null);
        }
Esempio n. 5
0
        public async Task <int> Count(SLAStatusFilter SLAStatusFilter)
        {
            try
            {
                int result = await UOW.SLAStatusRepository.Count(SLAStatusFilter);

                return(result);
            }
            catch (Exception ex)
            {
                await Logging.CreateSystemLog(ex, nameof(SLAStatusService));
            }
            return(0);
        }
Esempio n. 6
0
        public async Task <bool> ValidateId(SLAStatus SLAStatus)
        {
            SLAStatusFilter SLAStatusFilter = new SLAStatusFilter
            {
                Skip = 0,
                Take = 10,
                Id   = new IdFilter {
                    Equal = SLAStatus.Id
                },
                Selects = SLAStatusSelect.Id
            };

            int count = await UOW.SLAStatusRepository.Count(SLAStatusFilter);

            if (count == 0)
            {
                SLAStatus.AddError(nameof(SLAStatusValidator), nameof(SLAStatus.Id), ErrorCode.IdNotExisted);
            }
            return(count == 1);
        }
        public async Task <List <TicketReport_SLAStatusDTO> > FilterListSLAStatus([FromBody] TicketReport_SLAStatusFilterDTO TicketReport_SLAStatusFilterDTO)
        {
            if (!ModelState.IsValid)
            {
                throw new BindException(ModelState);
            }

            SLAStatusFilter SLAStatusFilter = new SLAStatusFilter();

            SLAStatusFilter.Skip      = 0;
            SLAStatusFilter.Take      = 20;
            SLAStatusFilter.OrderBy   = SLAStatusOrder.Id;
            SLAStatusFilter.OrderType = OrderType.ASC;
            SLAStatusFilter.Selects   = SLAStatusSelect.ALL;
            SLAStatusFilter.Id        = TicketReport_SLAStatusFilterDTO.Id;
            SLAStatusFilter.Name      = TicketReport_SLAStatusFilterDTO.Name;

            List <SLAStatus> SLAStatuss = await SLAStatusService.List(SLAStatusFilter);

            List <TicketReport_SLAStatusDTO> TicketReport_SLAStatusDTOs = SLAStatuss
                                                                          .Select(x => new TicketReport_SLAStatusDTO(x)).ToList();

            return(TicketReport_SLAStatusDTOs);
        }
Esempio n. 8
0
        private IQueryable <SLAStatusDAO> DynamicOrder(IQueryable <SLAStatusDAO> query, SLAStatusFilter filter)
        {
            switch (filter.OrderType)
            {
            case OrderType.ASC:
                switch (filter.OrderBy)
                {
                case SLAStatusOrder.Id:
                    query = query.OrderBy(q => q.Id);
                    break;

                case SLAStatusOrder.Code:
                    query = query.OrderBy(q => q.Code);
                    break;

                case SLAStatusOrder.Name:
                    query = query.OrderBy(q => q.Name);
                    break;

                case SLAStatusOrder.ColorCode:
                    query = query.OrderBy(q => q.ColorCode);
                    break;
                }
                break;

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

                case SLAStatusOrder.Code:
                    query = query.OrderByDescending(q => q.Code);
                    break;

                case SLAStatusOrder.Name:
                    query = query.OrderByDescending(q => q.Name);
                    break;

                case SLAStatusOrder.ColorCode:
                    query = query.OrderByDescending(q => q.ColorCode);
                    break;
                }
                break;
            }
            query = query.Skip(filter.Skip).Take(filter.Take);
            return(query);
        }
Esempio n. 9
0
 private IQueryable <SLAStatusDAO> DynamicFilter(IQueryable <SLAStatusDAO> query, SLAStatusFilter filter)
 {
     if (filter == null)
     {
         return(query.Where(q => false));
     }
     if (filter.Id != null && filter.Id.HasValue)
     {
         query = query.Where(q => q.Id, filter.Id);
     }
     if (filter.Code != null && filter.Code.HasValue)
     {
         query = query.Where(q => q.Code, filter.Code);
     }
     if (filter.Name != null && filter.Name.HasValue)
     {
         query = query.Where(q => q.Name, filter.Name);
     }
     if (filter.ColorCode != null && filter.ColorCode.HasValue)
     {
         query = query.Where(q => q.ColorCode, filter.ColorCode);
     }
     query = OrFilter(query, filter);
     return(query);
 }
Esempio n. 10
0
        private async Task <List <SLAStatus> > DynamicSelect(IQueryable <SLAStatusDAO> query, SLAStatusFilter filter)
        {
            List <SLAStatus> SLAStatuses = await query.Select(q => new SLAStatus()
            {
                Id        = filter.Selects.Contains(SLAStatusSelect.Id) ? q.Id : default(long),
                Code      = filter.Selects.Contains(SLAStatusSelect.Code) ? q.Code : default(string),
                Name      = filter.Selects.Contains(SLAStatusSelect.Name) ? q.Name : default(string),
                ColorCode = filter.Selects.Contains(SLAStatusSelect.ColorCode) ? q.ColorCode : default(string),
            }).ToListAsync();

            return(SLAStatuses);
        }