コード例 #1
0
        public OrderContentFilter ConvertFilterDTOToFilterEntity(OrderContentMaster_OrderContentFilterDTO OrderContentMaster_OrderContentFilterDTO)
        {
            OrderContentFilter OrderContentFilter = new OrderContentFilter();

            OrderContentFilter.Selects = OrderContentSelect.ALL;

            OrderContentFilter.Id = new LongFilter {
                Equal = OrderContentMaster_OrderContentFilterDTO.Id
            };
            OrderContentFilter.OrderId = new LongFilter {
                Equal = OrderContentMaster_OrderContentFilterDTO.OrderId
            };
            OrderContentFilter.ItemId = new LongFilter {
                Equal = OrderContentMaster_OrderContentFilterDTO.ItemId
            };
            OrderContentFilter.ProductName = new StringFilter {
                StartsWith = OrderContentMaster_OrderContentFilterDTO.ProductName
            };
            OrderContentFilter.FirstVersion = new StringFilter {
                StartsWith = OrderContentMaster_OrderContentFilterDTO.FirstVersion
            };
            OrderContentFilter.SecondVersion = new StringFilter {
                StartsWith = OrderContentMaster_OrderContentFilterDTO.SecondVersion
            };
            OrderContentFilter.Price = new LongFilter {
                Equal = OrderContentMaster_OrderContentFilterDTO.Price
            };
            OrderContentFilter.DiscountPrice = new LongFilter {
                Equal = OrderContentMaster_OrderContentFilterDTO.DiscountPrice
            };
            OrderContentFilter.Quantity = new LongFilter {
                Equal = OrderContentMaster_OrderContentFilterDTO.Quantity
            };
            return(OrderContentFilter);
        }
コード例 #2
0
        public async Task <int> Count(OrderContentFilter filter)
        {
            IQueryable <OrderContentDAO> OrderContentDAOs = DataContext.OrderContent;

            OrderContentDAOs = DynamicFilter(OrderContentDAOs, filter);
            return(await OrderContentDAOs.CountAsync());
        }
コード例 #3
0
        public async Task <int> Count([FromBody] OrderContentMaster_OrderContentFilterDTO OrderContentMaster_OrderContentFilterDTO)
        {
            if (!ModelState.IsValid)
            {
                throw new MessageException(ModelState);
            }

            OrderContentFilter OrderContentFilter = ConvertFilterDTOToFilterEntity(OrderContentMaster_OrderContentFilterDTO);

            return(await OrderContentService.Count(OrderContentFilter));
        }
コード例 #4
0
        public async Task <ActionResult <int> > Count([FromBody] OrderContent_OrderContentFilterDTO OrderContent_OrderContentFilterDTO)
        {
            if (!ModelState.IsValid)
            {
                throw new BindException(ModelState);
            }

            OrderContentFilter OrderContentFilter = ConvertFilterDTOToFilterEntity(OrderContent_OrderContentFilterDTO);
            int count = await OrderContentService.Count(OrderContentFilter);

            return(count);
        }
コード例 #5
0
        public async Task <List <OrderContentMaster_OrderContentDTO> > List([FromBody] OrderContentMaster_OrderContentFilterDTO OrderContentMaster_OrderContentFilterDTO)
        {
            if (!ModelState.IsValid)
            {
                throw new MessageException(ModelState);
            }

            OrderContentFilter OrderContentFilter = ConvertFilterDTOToFilterEntity(OrderContentMaster_OrderContentFilterDTO);

            List <OrderContent> OrderContents = await OrderContentService.List(OrderContentFilter);

            return(OrderContents.Select(c => new OrderContentMaster_OrderContentDTO(c)).ToList());
        }
コード例 #6
0
        public async Task <List <OrderContent> > List(OrderContentFilter filter)
        {
            if (filter == null)
            {
                return(new List <OrderContent>());
            }
            IQueryable <OrderContentDAO> OrderContentDAOs = DataContext.OrderContent;

            OrderContentDAOs = DynamicFilter(OrderContentDAOs, filter);
            OrderContentDAOs = DynamicOrder(OrderContentDAOs, filter);
            var OrderContents = await DynamicSelect(OrderContentDAOs, filter);

            return(OrderContents);
        }
コード例 #7
0
        private OrderContentFilter ConvertFilterDTOToFilterEntity(OrderContent_OrderContentFilterDTO OrderContent_OrderContentFilterDTO)
        {
            OrderContentFilter OrderContentFilter = new OrderContentFilter();

            OrderContentFilter.Selects   = OrderContentSelect.ALL;
            OrderContentFilter.Skip      = OrderContent_OrderContentFilterDTO.Skip;
            OrderContentFilter.Take      = OrderContent_OrderContentFilterDTO.Take;
            OrderContentFilter.OrderBy   = OrderContent_OrderContentFilterDTO.OrderBy;
            OrderContentFilter.OrderType = OrderContent_OrderContentFilterDTO.OrderType;

            OrderContentFilter.Id      = OrderContent_OrderContentFilterDTO.Id;
            OrderContentFilter.Code    = OrderContent_OrderContentFilterDTO.Code;
            OrderContentFilter.OrderId = OrderContent_OrderContentFilterDTO.OrderId;
            OrderContentFilter.FoodFoodTypeMappingId = OrderContent_OrderContentFilterDTO.FoodFoodTypeMappingId;
            OrderContentFilter.Quantity = OrderContent_OrderContentFilterDTO.Quantity;
            OrderContentFilter.StatusId = OrderContent_OrderContentFilterDTO.StatusId;
            return(OrderContentFilter);
        }
コード例 #8
0
        public async Task <bool> ValidateId(OrderContent OrderContent)
        {
            OrderContentFilter OrderContentFilter = new OrderContentFilter
            {
                Skip = 0,
                Take = 10,
                Id   = new IdFilter {
                    Equal = OrderContent.Id
                },
                Selects = OrderContentSelect.Id
            };

            int count = await UOW.OrderContentRepository.Count(OrderContentFilter);

            if (count == 0)
            {
                OrderContent.AddError(nameof(OrderContentValidator), nameof(OrderContent.Id), ErrorCode.IdNotExisted);
            }
            return(count == 1);
        }
コード例 #9
0
        public async Task <List <OrderContent> > List(OrderContentFilter OrderContentFilter)
        {
            try
            {
                List <OrderContent> OrderContents = await UOW.OrderContentRepository.List(OrderContentFilter);

                return(OrderContents);
            }
            catch (Exception ex)
            {
                await Logging.CreateSystemLog(ex.InnerException, nameof(OrderContentService));

                if (ex.InnerException == null)
                {
                    throw new MessageException(ex);
                }
                else
                {
                    throw new MessageException(ex.InnerException);
                }
            }
        }
コード例 #10
0
        public async Task <int> Count(OrderContentFilter OrderContentFilter)
        {
            try
            {
                int result = await UOW.OrderContentRepository.Count(OrderContentFilter);

                return(result);
            }
            catch (Exception ex)
            {
                await Logging.CreateSystemLog(ex.InnerException, nameof(OrderContentService));

                if (ex.InnerException == null)
                {
                    throw new MessageException(ex);
                }
                else
                {
                    throw new MessageException(ex.InnerException);
                }
            }
        }
コード例 #11
0
        public async Task <ActionResult <List <Food_FoodFoodTypeMappingDTO> > > ListTopOrder([FromBody] Food_FoodFilterDTO Food_FoodFilterDTO)
        {
            if (!ModelState.IsValid)
            {
                throw new BindException(ModelState);
            }

            OrderContentFilter OrderContentFilter = new OrderContentFilter
            {
                Skip      = 0,
                Take      = 10,
                Selects   = OrderContentSelect.ALL,
                OrderBy   = OrderContentOrder.Quantity,
                OrderType = OrderType.DESC
            };

            List <OrderContent> OrderContents = await OrderContentService.List(OrderContentFilter);

            List <Food_FoodFoodTypeMappingDTO> Food_FoodFoodTypeMappingDTOs = OrderContents
                                                                              .Select(o => new Food_FoodFoodTypeMappingDTO(o.FoodFoodTypeMapping)).ToList();

            return(Food_FoodFoodTypeMappingDTOs);
        }
コード例 #12
0
        private IQueryable <OrderContentDAO> DynamicOrder(IQueryable <OrderContentDAO> query, OrderContentFilter filter)
        {
            switch (filter.OrderType)
            {
            case OrderType.ASC:
                switch (filter.OrderBy)
                {
                case OrderContentOrder.Id:
                    query = query.OrderBy(q => q.Id);
                    break;

                case OrderContentOrder.Order:
                    query = query.OrderBy(q => q.Order.Id);
                    break;

                case OrderContentOrder.Item:
                    query = query.OrderBy(q => q.Item.Id);
                    break;

                case OrderContentOrder.ProductName:
                    query = query.OrderBy(q => q.ProductName);
                    break;

                case OrderContentOrder.FirstVersion:
                    query = query.OrderBy(q => q.FirstVersion);
                    break;

                case OrderContentOrder.SecondVersion:
                    query = query.OrderBy(q => q.SecondVersion);
                    break;

                case OrderContentOrder.Price:
                    query = query.OrderBy(q => q.Price);
                    break;

                case OrderContentOrder.DiscountPrice:
                    query = query.OrderBy(q => q.DiscountPrice);
                    break;

                case OrderContentOrder.Quantity:
                    query = query.OrderBy(q => q.Quantity);
                    break;
                }
                break;

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

                case OrderContentOrder.Order:
                    query = query.OrderByDescending(q => q.Order.Id);
                    break;

                case OrderContentOrder.Item:
                    query = query.OrderByDescending(q => q.Item.Id);
                    break;

                case OrderContentOrder.ProductName:
                    query = query.OrderByDescending(q => q.ProductName);
                    break;

                case OrderContentOrder.FirstVersion:
                    query = query.OrderByDescending(q => q.FirstVersion);
                    break;

                case OrderContentOrder.SecondVersion:
                    query = query.OrderByDescending(q => q.SecondVersion);
                    break;

                case OrderContentOrder.Price:
                    query = query.OrderByDescending(q => q.Price);
                    break;

                case OrderContentOrder.DiscountPrice:
                    query = query.OrderByDescending(q => q.DiscountPrice);
                    break;

                case OrderContentOrder.Quantity:
                    query = query.OrderByDescending(q => q.Quantity);
                    break;
                }
                break;
            }
            query = query.Skip(filter.Skip).Take(filter.Take);
            return(query);
        }
コード例 #13
0
        private IQueryable <OrderContentDAO> DynamicFilter(IQueryable <OrderContentDAO> query, OrderContentFilter filter)
        {
            if (filter == null)
            {
                return(query.Where(q => false));
            }

            if (filter.Id != null)
            {
                query = query.Where(q => q.Id, filter.Id);
            }
            if (filter.OrderId != null)
            {
                query = query.Where(q => q.OrderId, filter.OrderId);
            }
            if (filter.ItemId != null)
            {
                query = query.Where(q => q.ItemId, filter.ItemId);
            }
            if (filter.ProductName != null)
            {
                query = query.Where(q => q.ProductName, filter.ProductName);
            }
            if (filter.FirstVersion != null)
            {
                query = query.Where(q => q.FirstVersion, filter.FirstVersion);
            }
            if (filter.SecondVersion != null)
            {
                query = query.Where(q => q.SecondVersion, filter.SecondVersion);
            }
            if (filter.Price != null)
            {
                query = query.Where(q => q.Price, filter.Price);
            }
            if (filter.DiscountPrice != null)
            {
                query = query.Where(q => q.DiscountPrice, filter.DiscountPrice);
            }
            if (filter.Quantity != null)
            {
                query = query.Where(q => q.Quantity, filter.Quantity);
            }
            if (filter.Ids != null)
            {
                query = query.Where(q => filter.Ids.Contains(q.Id));
            }
            if (filter.ExceptIds != null)
            {
                query = query.Where(q => !filter.ExceptIds.Contains(q.Id));
            }
            return(query);
        }
コード例 #14
0
        public async Task <int> Count(OrderContentFilter OrderContentFilter)
        {
            int result = await UOW.OrderContentRepository.Count(OrderContentFilter);

            return(result);
        }
コード例 #15
0
        private async Task <List <OrderContent> > DynamicSelect(IQueryable <OrderContentDAO> query, OrderContentFilter filter)
        {
            List <OrderContent> OrderContents = await query.Select(q => new OrderContent()
            {
                Id            = filter.Selects.Contains(OrderContentSelect.Id) ? q.Id : default(long),
                OrderId       = filter.Selects.Contains(OrderContentSelect.Order) ? q.OrderId : default(long),
                ItemId        = filter.Selects.Contains(OrderContentSelect.Item) ? q.ItemId : default(long?),
                ProductName   = filter.Selects.Contains(OrderContentSelect.ProductName) ? q.ProductName : default(string),
                FirstVersion  = filter.Selects.Contains(OrderContentSelect.FirstVersion) ? q.FirstVersion : default(string),
                SecondVersion = filter.Selects.Contains(OrderContentSelect.SecondVersion) ? q.SecondVersion : default(string),
                Price         = filter.Selects.Contains(OrderContentSelect.Price) ? q.Price : default(long),
                DiscountPrice = filter.Selects.Contains(OrderContentSelect.DiscountPrice) ? q.DiscountPrice : default(long),
                Quantity      = filter.Selects.Contains(OrderContentSelect.Quantity) ? q.Quantity : default(long),
                Item          = filter.Selects.Contains(OrderContentSelect.Item) && q.Item != null ? new Item
                {
                    Id                = q.Item.Id,
                    ProductId         = q.Item.ProductId,
                    FirstVariationId  = q.Item.FirstVariationId,
                    SecondVariationId = q.Item.SecondVariationId,
                    SKU               = q.Item.SKU,
                    Price             = q.Item.Price,
                    MinPrice          = q.Item.MinPrice,
                } : null,
                Order = filter.Selects.Contains(OrderContentSelect.Order) && q.Order != null ? new Order
                {
                    Id               = q.Order.Id,
                    CustomerId       = q.Order.CustomerId,
                    CreatedDate      = q.Order.CreatedDate,
                    VoucherCode      = q.Order.VoucherCode,
                    Total            = q.Order.Total,
                    VoucherDiscount  = q.Order.VoucherDiscount,
                    CampaignDiscount = q.Order.CampaignDiscount,
                    StatusId         = q.Order.StatusId,
                } : null,
            }).ToListAsync();

            return(OrderContents);
        }
コード例 #16
0
        public async Task <List <OrderContent> > List(OrderContentFilter OrderContentFilter)
        {
            List <OrderContent> OrderContents = await UOW.OrderContentRepository.List(OrderContentFilter);

            return(OrderContents);
        }
コード例 #17
0
        private IQueryable <OrderContentDAO> DynamicOrder(IQueryable <OrderContentDAO> query, OrderContentFilter filter)
        {
            switch (filter.OrderType)
            {
            case OrderType.ASC:
                switch (filter.OrderBy)
                {
                case OrderContentOrder.Id:
                    query = query.OrderBy(q => q.Id);
                    break;

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

                case OrderContentOrder.Order:
                    query = query.OrderBy(q => q.OrderId);
                    break;

                case OrderContentOrder.FoodFoodTypeMapping:
                    query = query.OrderBy(q => q.FoodFoodTypeMappingId);
                    break;

                case OrderContentOrder.Quantity:
                    query = query.OrderBy(q => q.Quantity);
                    break;

                case OrderContentOrder.Status:
                    query = query.OrderBy(q => q.StatusId);
                    break;
                }
                break;

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

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

                case OrderContentOrder.Order:
                    query = query.OrderByDescending(q => q.OrderId);
                    break;

                case OrderContentOrder.FoodFoodTypeMapping:
                    query = query.OrderByDescending(q => q.FoodFoodTypeMappingId);
                    break;

                case OrderContentOrder.Quantity:
                    query = query.OrderByDescending(q => q.Quantity);
                    break;

                case OrderContentOrder.Status:
                    query = query.OrderByDescending(q => q.StatusId);
                    break;
                }
                break;
            }
            query = query.Skip(filter.Skip).Take(filter.Take);
            return(query);
        }
コード例 #18
0
        private async Task <List <OrderContent> > DynamicSelect(IQueryable <OrderContentDAO> query, OrderContentFilter filter)
        {
            List <OrderContent> OrderContents = await query.Select(q => new OrderContent()
            {
                Id      = filter.Selects.Contains(OrderContentSelect.Id) ? q.Id : default(long),
                Code    = filter.Selects.Contains(OrderContentSelect.Code) ? q.Code : default(string),
                OrderId = filter.Selects.Contains(OrderContentSelect.Order) ? q.OrderId : default(long),
                FoodFoodTypeMappingId = filter.Selects.Contains(OrderContentSelect.FoodFoodTypeMapping) ? q.FoodFoodTypeMappingId : default(long),
                Quantity            = filter.Selects.Contains(OrderContentSelect.Quantity) ? q.Quantity : default(long),
                StatusId            = filter.Selects.Contains(OrderContentSelect.Status) ? q.StatusId : default(long),
                FoodFoodTypeMapping = filter.Selects.Contains(OrderContentSelect.FoodFoodTypeMapping) && q.FoodFoodTypeMapping != null ? new FoodFoodTypeMapping
                {
                    Id         = q.FoodFoodTypeMapping.Id,
                    FoodId     = q.FoodFoodTypeMapping.FoodId,
                    FoodTypeId = q.FoodFoodTypeMapping.FoodTypeId,
                } : null,
                Order = filter.Selects.Contains(OrderContentSelect.Order) && q.Order != null ? new Order
                {
                    Id          = q.Order.Id,
                    Code        = q.Order.Code,
                    OrderDate   = q.Order.OrderDate,
                    PayDate     = q.Order.PayDate,
                    AccountId   = q.Order.AccountId,
                    NumOfTable  = q.Order.NumOfTable,
                    NumOfPerson = q.Order.NumOfPerson,
                    Descreption = q.Order.Descreption,
                    StatusId    = q.Order.StatusId,
                } : null,
            }).AsNoTracking().ToListAsync();

            return(OrderContents);
        }
コード例 #19
0
        private IQueryable <OrderContentDAO> OrFilter(IQueryable <OrderContentDAO> query, OrderContentFilter filter)
        {
            if (filter.OrFilter == null || filter.OrFilter.Count == 0)
            {
                return(query);
            }
            IQueryable <OrderContentDAO> initQuery = query.Where(q => false);

            foreach (OrderContentFilter OrderContentFilter in filter.OrFilter)
            {
                IQueryable <OrderContentDAO> queryable = query;
                if (filter.Id != null)
                {
                    queryable = queryable.Where(q => q.Id, filter.Id);
                }
                if (filter.Code != null)
                {
                    queryable = queryable.Where(q => q.Code, filter.Code);
                }
                if (filter.OrderId != null)
                {
                    queryable = queryable.Where(q => q.OrderId, filter.OrderId);
                }
                if (filter.FoodFoodTypeMappingId != null)
                {
                    queryable = queryable.Where(q => q.FoodFoodTypeMappingId, filter.FoodFoodTypeMappingId);
                }
                if (filter.Quantity != null)
                {
                    queryable = queryable.Where(q => q.Quantity, filter.Quantity);
                }
                if (filter.StatusId != null)
                {
                    queryable = queryable.Where(q => q.StatusId, filter.StatusId);
                }
                initQuery = initQuery.Union(queryable);
            }
            return(initQuery);
        }
コード例 #20
0
 private IQueryable <OrderContentDAO> DynamicFilter(IQueryable <OrderContentDAO> query, OrderContentFilter filter)
 {
     if (filter == null)
     {
         return(query.Where(q => false));
     }
     if (filter.Id != null)
     {
         query = query.Where(q => q.Id, filter.Id);
     }
     if (filter.Code != null)
     {
         query = query.Where(q => q.Code, filter.Code);
     }
     if (filter.OrderId != null)
     {
         query = query.Where(q => q.OrderId, filter.OrderId);
     }
     if (filter.FoodFoodTypeMappingId != null)
     {
         query = query.Where(q => q.FoodFoodTypeMappingId, filter.FoodFoodTypeMappingId);
     }
     if (filter.Quantity != null)
     {
         query = query.Where(q => q.Quantity, filter.Quantity);
     }
     if (filter.StatusId != null)
     {
         query = query.Where(q => q.StatusId, filter.StatusId);
     }
     query = OrFilter(query, filter);
     return(query);
 }