Ejemplo n.º 1
0
        public async Task <int> Count(OrderQuoteStatusFilter filter)
        {
            IQueryable <OrderQuoteStatusDAO> OrderQuoteStatuses = DataContext.OrderQuoteStatus.AsNoTracking();

            OrderQuoteStatuses = DynamicFilter(OrderQuoteStatuses, filter);
            return(await OrderQuoteStatuses.CountAsync());
        }
Ejemplo n.º 2
0
        public async Task <ActionResult <List <OrderQuote_OrderQuoteStatusDTO> > > FilterListOrderQuoteStatus([FromBody] OrderQuote_OrderQuoteStatusFilterDTO OrderQuote_OrderQuoteStatusFilterDTO)
        {
            if (UnAuthorization)
            {
                return(Forbid());
            }
            if (!ModelState.IsValid)
            {
                throw new BindException(ModelState);
            }

            OrderQuoteStatusFilter OrderQuoteStatusFilter = new OrderQuoteStatusFilter();

            OrderQuoteStatusFilter.Skip      = 0;
            OrderQuoteStatusFilter.Take      = 20;
            OrderQuoteStatusFilter.OrderBy   = OrderQuoteStatusOrder.Id;
            OrderQuoteStatusFilter.OrderType = OrderType.ASC;
            OrderQuoteStatusFilter.Selects   = OrderQuoteStatusSelect.ALL;
            OrderQuoteStatusFilter.Id        = OrderQuote_OrderQuoteStatusFilterDTO.Id;
            OrderQuoteStatusFilter.Code      = OrderQuote_OrderQuoteStatusFilterDTO.Code;
            OrderQuoteStatusFilter.Name      = OrderQuote_OrderQuoteStatusFilterDTO.Name;

            List <OrderQuoteStatus> OrderQuoteStatuses = await OrderQuoteStatusService.List(OrderQuoteStatusFilter);

            List <OrderQuote_OrderQuoteStatusDTO> OrderQuote_OrderQuoteStatusDTOs = OrderQuoteStatuses
                                                                                    .Select(x => new OrderQuote_OrderQuoteStatusDTO(x)).ToList();

            return(OrderQuote_OrderQuoteStatusDTOs);
        }
Ejemplo n.º 3
0
        public async Task <List <OrderQuoteStatus> > List(OrderQuoteStatusFilter OrderQuoteStatusFilter)
        {
            try
            {
                List <OrderQuoteStatus> OrderQuoteStatuss = await UOW.OrderQuoteStatusRepository.List(OrderQuoteStatusFilter);

                return(OrderQuoteStatuss);
            }
            catch (Exception ex)
            {
                await Logging.CreateSystemLog(ex, nameof(OrderQuoteStatusService));
            }
            return(null);
        }
Ejemplo n.º 4
0
        public async Task <int> Count(OrderQuoteStatusFilter OrderQuoteStatusFilter)
        {
            try
            {
                int result = await UOW.OrderQuoteStatusRepository.Count(OrderQuoteStatusFilter);

                return(result);
            }
            catch (Exception ex)
            {
                await Logging.CreateSystemLog(ex, nameof(OrderQuoteStatusService));
            }
            return(0);
        }
Ejemplo n.º 5
0
        public async Task <List <OrderQuoteStatus> > List(OrderQuoteStatusFilter filter)
        {
            if (filter == null)
            {
                return(new List <OrderQuoteStatus>());
            }
            IQueryable <OrderQuoteStatusDAO> OrderQuoteStatusDAOs = DataContext.OrderQuoteStatus.AsNoTracking();

            OrderQuoteStatusDAOs = DynamicFilter(OrderQuoteStatusDAOs, filter);
            OrderQuoteStatusDAOs = DynamicOrder(OrderQuoteStatusDAOs, filter);
            List <OrderQuoteStatus> OrderQuoteStatuses = await DynamicSelect(OrderQuoteStatusDAOs, filter);

            return(OrderQuoteStatuses);
        }
Ejemplo n.º 6
0
        public async Task <bool> ValidateId(OrderQuoteStatus OrderQuoteStatus)
        {
            OrderQuoteStatusFilter OrderQuoteStatusFilter = new OrderQuoteStatusFilter
            {
                Skip = 0,
                Take = 10,
                Id   = new IdFilter {
                    Equal = OrderQuoteStatus.Id
                },
                Selects = OrderQuoteStatusSelect.Id
            };

            int count = await UOW.OrderQuoteStatusRepository.Count(OrderQuoteStatusFilter);

            if (count == 0)
            {
                OrderQuoteStatus.AddError(nameof(OrderQuoteStatusValidator), nameof(OrderQuoteStatus.Id), ErrorCode.IdNotExisted);
            }
            return(count == 1);
        }
Ejemplo n.º 7
0
        private IQueryable <OrderQuoteStatusDAO> DynamicOrder(IQueryable <OrderQuoteStatusDAO> query, OrderQuoteStatusFilter filter)
        {
            switch (filter.OrderType)
            {
            case OrderType.ASC:
                switch (filter.OrderBy)
                {
                case OrderQuoteStatusOrder.Id:
                    query = query.OrderBy(q => q.Id);
                    break;

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

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

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

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

                case OrderQuoteStatusOrder.Name:
                    query = query.OrderByDescending(q => q.Name);
                    break;
                }
                break;
            }
            query = query.Skip(filter.Skip).Take(filter.Take);
            return(query);
        }
Ejemplo n.º 8
0
        private IQueryable <OrderQuoteStatusDAO> OrFilter(IQueryable <OrderQuoteStatusDAO> query, OrderQuoteStatusFilter filter)
        {
            if (filter.OrFilter == null || filter.OrFilter.Count == 0)
            {
                return(query);
            }
            IQueryable <OrderQuoteStatusDAO> initQuery = query.Where(q => false);

            foreach (OrderQuoteStatusFilter OrderQuoteStatusFilter in filter.OrFilter)
            {
                IQueryable <OrderQuoteStatusDAO> queryable = query;
                if (OrderQuoteStatusFilter.Id != null && OrderQuoteStatusFilter.Id.HasValue)
                {
                    queryable = queryable.Where(q => q.Id, OrderQuoteStatusFilter.Id);
                }
                if (OrderQuoteStatusFilter.Code != null && OrderQuoteStatusFilter.Code.HasValue)
                {
                    queryable = queryable.Where(q => q.Code, OrderQuoteStatusFilter.Code);
                }
                if (OrderQuoteStatusFilter.Name != null && OrderQuoteStatusFilter.Name.HasValue)
                {
                    queryable = queryable.Where(q => q.Name, OrderQuoteStatusFilter.Name);
                }
                initQuery = initQuery.Union(queryable);
            }
            return(initQuery);
        }
Ejemplo n.º 9
0
 private IQueryable <OrderQuoteStatusDAO> DynamicFilter(IQueryable <OrderQuoteStatusDAO> query, OrderQuoteStatusFilter 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);
     }
     query = OrFilter(query, filter);
     return(query);
 }
Ejemplo n.º 10
0
        private async Task <List <OrderQuoteStatus> > DynamicSelect(IQueryable <OrderQuoteStatusDAO> query, OrderQuoteStatusFilter filter)
        {
            List <OrderQuoteStatus> OrderQuoteStatuses = await query.Select(q => new OrderQuoteStatus()
            {
                Id   = filter.Selects.Contains(OrderQuoteStatusSelect.Id) ? q.Id : default(long),
                Code = filter.Selects.Contains(OrderQuoteStatusSelect.Code) ? q.Code : default(string),
                Name = filter.Selects.Contains(OrderQuoteStatusSelect.Name) ? q.Name : default(string),
            }).ToListAsync();

            return(OrderQuoteStatuses);
        }