Пример #1
0
        public async Task <ActionResult <int> > Count([FromBody] Food_FoodFilterDTO Food_FoodFilterDTO)
        {
            if (!ModelState.IsValid)
            {
                throw new BindException(ModelState);
            }

            FoodFilter FoodFilter = ConvertFilterDTOToFilterEntity(Food_FoodFilterDTO);
            int        count      = await FoodService.Count(FoodFilter);

            return(count);
        }
Пример #2
0
        public async Task <ActionResult <List <Food_FoodDTO> > > List([FromBody] Food_FoodFilterDTO Food_FoodFilterDTO)
        {
            if (!ModelState.IsValid)
            {
                throw new BindException(ModelState);
            }

            FoodFilter  FoodFilter = ConvertFilterDTOToFilterEntity(Food_FoodFilterDTO);
            List <Food> Foods      = await FoodService.List(FoodFilter);

            List <Food_FoodDTO> Food_FoodDTOs = Foods
                                                .Select(c => new Food_FoodDTO(c)).ToList();

            return(Food_FoodDTOs);
        }
Пример #3
0
        private FoodFilter ConvertFilterDTOToFilterEntity(Food_FoodFilterDTO Food_FoodFilterDTO)
        {
            FoodFilter FoodFilter = new FoodFilter();

            FoodFilter.Selects   = FoodSelect.ALL;
            FoodFilter.Skip      = Food_FoodFilterDTO.Skip;
            FoodFilter.Take      = Food_FoodFilterDTO.Take;
            FoodFilter.OrderBy   = Food_FoodFilterDTO.OrderBy;
            FoodFilter.OrderType = Food_FoodFilterDTO.OrderType;

            FoodFilter.Id           = Food_FoodFilterDTO.Id;
            FoodFilter.Name         = Food_FoodFilterDTO.Name;
            FoodFilter.PriceEach    = Food_FoodFilterDTO.PriceEach;
            FoodFilter.DiscountRate = Food_FoodFilterDTO.DiscountRate;
            FoodFilter.Image        = Food_FoodFilterDTO.Image;
            FoodFilter.StatusId     = Food_FoodFilterDTO.StatusId;
            FoodFilter.Descreption  = Food_FoodFilterDTO.Descreption;
            return(FoodFilter);
        }
Пример #4
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);
        }
Пример #5
0
        public async Task <ActionResult <List <Food_FoodFoodTypeMappingDTO> > > ListRecently([FromBody] Food_FoodFilterDTO Food_FoodFilterDTO)
        {
            if (!ModelState.IsValid)
            {
                throw new BindException(ModelState);
            }

            var         AccountId   = CurrentContext.AccountId;
            OrderFilter OrderFilter = new OrderFilter
            {
                Skip      = 0,
                Take      = 10,
                AccountId = new IdFilter {
                    Equal = AccountId
                },
                StatusId = new IdFilter {
                    Equal = Enums.OrderStatus.DONE.Id
                },
                OrderBy   = OrderOrder.OrderDate,
                OrderType = OrderType.DESC,
                Selects   = OrderSelect.ALL
            };

            List <Order> Orders = await OrderService.List(OrderFilter);

            List <OrderContent> OrderContents = Orders.SelectMany(o => o.OrderContents).Skip(0).Take(10).ToList();
            List <Food_FoodFoodTypeMappingDTO> Food_FoodFoodTypeMappingDTOs = OrderContents
                                                                              .Select(o => new Food_FoodFoodTypeMappingDTO(o.FoodFoodTypeMapping)).ToList();

            return(Food_FoodFoodTypeMappingDTOs);
        }