Ejemplo n.º 1
0
        public IActionResult Filter([FromQuery] OrderFilterViewModel filterModel)
        {
            try
            {
                var ordersEntity = _orderRepository.ListOrder(x => (!filterModel.OrderDateTo.HasValue || x.OrderDate < filterModel.OrderDateTo.Value.AddDays(1)) &&
                                                              (!filterModel.OrderDateFrom.HasValue || x.OrderDate >= filterModel.OrderDateFrom.Value) &&
                                                              (!filterModel.PaymentStatusId.HasValue || x.PaymentStatusId == filterModel.PaymentStatusId.Value) &&
                                                              (!filterModel.ProductId.HasValue || x.Items.Where(y => y.ProductId == filterModel.ProductId.Value).Any()) &&
                                                              (!filterModel.OrderId.HasValue || x.Id == filterModel.OrderId.Value)
                                                              );

                if (ordersEntity.Count == 0)
                {
                    return(NotFound());
                }

                var orderViewModel = _mapper.Map <List <OrderViewModel> >(ordersEntity);

                return(Ok(orderViewModel));
            }
            catch (Exception ex)
            {
                return(StatusCode(500, ex.Message));
            }
        }
Ejemplo n.º 2
0
        public ActionResult OrderNew(OrderFilterViewModel orderFilterViewModel, int page = 1,
                                     PageEnum pageSize = PageEnum.Ten)
        {
            var orderListViewModel = GetOrderFilter(orderFilterViewModel, false, page, pageSize);

            return(View(orderListViewModel));
        }
Ejemplo n.º 3
0
        public ActionResult Filter(OrderFilterViewModel orderFilterViewModel)
        {
            TempData["productTypeId"] = orderFilterViewModel.ProductTypeId;
            TempData["restaurantId"]  = orderFilterViewModel.RestaurantId;

            return(RedirectToAction("Filter"));
        }
Ejemplo n.º 4
0
        private OrderFilteringViewModel GetOrderFilter(OrderFilterViewModel orderFilterViewModel, bool isHistory,
                                                       int page = 1, PageEnum pageSize = PageEnum.Ten)
        {
            var filterDto    = Mapper.Map <OrderFilterDTO>(orderFilterViewModel);
            var filterResult = _service.GetOrdersByFilter(filterDto, isHistory, page, pageSize);

            var ordersViewModel    = Mapper.Map <IEnumerable <OrderViewModel> >(filterResult.Orders);
            var orderListViewModel = new OrderFilteringViewModel
            {
                Orders          = ordersViewModel,
                Filter          = orderFilterViewModel,
                Page            = page,
                PageSize        = pageSize,
                TotalItemsCount = filterResult.Count
            };

            return(orderListViewModel);
        }
Ejemplo n.º 5
0
        public IActionResult GetOrderUsingFilter([FromQuery] OrderFilterViewModel model)
        {
            var filter = _orderService.GetFilterToDashBoard(model);

            if (!filter.Valid)
            {
                return(ValidationProblem(filter.GetNotification()));
            }

            var orders = _orderService.GetOrdersUsingFilter(filter);

            if (orders.Any())
            {
                return(Ok(orders));
            }

            return(NotFound());
        }
Ejemplo n.º 6
0
        public IActionResult PostFilter([FromBody] OrderFilterViewModel orderFilterViewModel)
        {
            try
            {
                var result = orderFilterViewModel.FilteredList(_bl).Select(i => new OrderViewModel(i)).ToList();
                var count  = result.Count;

                return(Ok(new OrderListViewModel(result.Skip(orderFilterViewModel.Offset).Take(orderFilterViewModel.Limit), orderFilterViewModel.Limit, count)));
            }
            catch (SecurityException)
            {
                _log.LogWarning("'{0}' tried to list Admin/Verwalter View from Orders", _bl.GetCurrentUid());
                return(Unauthorized());
            }
            catch (Exception ex)
            {
                _log.LogError("Exception: {0}", ex);
                return(StatusCode(500));
            }
        }
Ejemplo n.º 7
0
        //
        // GET: /OrderPaids/

        public ViewResult Filter()
        {
            Guid?productTypeId = null;
            Guid?restaurantId  = null;

            if (TempData["productTypeId"] != null)
            {
                productTypeId = TempData["productTypeId"] as Guid?;
            }

            if (TempData["restaurantId"] != null)
            {
                restaurantId = TempData["restaurantId"] as Guid?;
            }

            var query = orderpaidRepository.AllIncluding(orderpaid => orderpaid.Waiter, orderpaid => orderpaid.Restaurant, orderpaid => orderpaid.Menus);

            var vm = new OrderFilterViewModel();

            if (restaurantId.HasValue)
            {
                vm.RestaurantId = restaurantId.Value;
                query           = query.Where(p => p.RestaurantId == restaurantId.Value);
            }

            if (productTypeId.HasValue)
            {
                vm.ProductTypeId = productTypeId.Value;
                query            = query.Where(p => p.Menus.Count(m => m.ProductTypeId == productTypeId.Value) > 0);
            }

            vm.Orders = query;

            ViewBag.PossibleRestaurants  = restaurantRepository.All;
            ViewBag.PossibleProductTypes = producttypeRepository.All;

            return(View(vm));
        }
Ejemplo n.º 8
0
 public PartialViewResult Filters(OrderFilterViewModel model)
 {
     return(PartialView("Filter", model));
 }
Ejemplo n.º 9
0
        public IActionResult Index(int page = 1)
        {
            try
            {
                int                   pageSize     = 5;
                HomeViewModel         entryCache   = memoryCache.Get <HomeViewModel>("Workshop");
                List <OrderViewModel> list         = new List <OrderViewModel>();
                var                   orders       = entryCache.Orders;
                var                   sessionOrder = HttpContext.Session.Get("OrderFilters");
                OrderFilterViewModel  filterOrder  = null;
                if (sessionOrder != null)
                {
                    filterOrder = Transformations.DictionaryToObject <OrderFilterViewModel>(sessionOrder);
                }
                foreach (var order in orders)
                {
                    list.Add(new OrderViewModel
                    {
                        Id             = order.orderID,
                        dateCompletion = order.dateCompletion,
                        dateReceipt    = order.dateReceipt,
                        fioOwner       = order.Car.Owner.fioOwner,
                        fioWorker      = order.Worker.fioWorker,
                        stateNumber    = order.Car.stateNumber,
                        workerID       = order.Worker.workerID,
                        price          = order.Breakdowns.Sum(p => p.Part.price)
                    });
                }
                IQueryable <OrderViewModel> filterList = list.AsQueryable();
                if (filterOrder != null)
                {
                    if (!string.IsNullOrEmpty(filterOrder.Car))
                    {
                        filterList = filterList.Where(p => p.stateNumber == filterOrder.Car);
                    }
                    if (filterOrder.SelectedWorker != null && filterOrder.SelectedWorker != -1)
                    {
                        filterList = filterList.Where(p => p.workerID == filterOrder.SelectedWorker);
                    }
                    switch (filterOrder._selectedType)
                    {
                    case "Отремонтированные":
                    {
                        if (filterOrder._date1 != null)
                        {
                            filterList = filterList.Where(p => p.dateCompletion != null &&
                                                          p.dateCompletion >= filterOrder._date1);
                        }
                        if (filterOrder._date2 != null)
                        {
                            filterList = filterList.Where(p => p.dateCompletion != null &&
                                                          p.dateCompletion <= filterOrder._date2);
                        }
                        break;
                    }

                    case "Поступившие":
                    {
                        if (filterOrder._date1 != null)
                        {
                            filterList = filterList.Where(p => p.dateReceipt >= filterOrder._date1);
                        }
                        if (filterOrder._date2 != null)
                        {
                            filterList = filterList.Where(p => p.dateReceipt <= filterOrder._date2);
                        }
                        break;
                    }
                    }
                }
                var count = filterList.Count();
                var items = filterList.Skip((page - 1) * pageSize).
                            Take(pageSize).ToList();
                if (filterOrder != null)
                {
                    filterOrder.Workers = new SelectList(entryCache.Workers, "workerID", "fioWorker");
                }
                OrdersListViewModel model = new OrdersListViewModel
                {
                    PageViewModel        = new PageViewModel(count, page, pageSize),
                    OrderFilterViewModel = filterOrder == null ? new OrderFilterViewModel(null, entryCache.Workers, null, DateTime.Now, DateTime.Now, null) : filterOrder,
                    Orders = items
                };
                return(View(model));
            }
            catch (Exception ex)
            {
            }
            return(View("Error"));
        }
Ejemplo n.º 10
0
        public IActionResult Index(OrderFilterViewModel filterOrder)
        {
            int                   pageSize   = 5;
            HomeViewModel         entryCache = memoryCache.Get <HomeViewModel>("Workshop");
            List <OrderViewModel> list       = new List <OrderViewModel>();
            var                   orders     = entryCache.Orders;

            foreach (var order in orders)
            {
                list.Add(new OrderViewModel
                {
                    Id             = order.orderID,
                    dateCompletion = order.dateCompletion,
                    dateReceipt    = order.dateReceipt,
                    fioOwner       = order.Car.Owner.fioOwner,
                    fioWorker      = order.Worker.fioWorker,
                    stateNumber    = order.Car.stateNumber,
                    workerID       = order.Worker.workerID,
                    price          = order.Breakdowns.Sum(p => p.Part.price)
                });
            }
            IQueryable <OrderViewModel> filterList = list.AsQueryable();

            if (filterOrder.Car != null)
            {
                filterList = filterList.Where(p => p.stateNumber == filterOrder.Car);
            }
            if (filterOrder.SelectedWorker != null && filterOrder.SelectedWorker != -1)
            {
                filterList = filterList.Where(p => p.workerID == filterOrder.SelectedWorker);
            }
            switch (filterOrder._selectedType)
            {
            case "Отремонтированные":
            {
                if (filterOrder._date1 != null)
                {
                    filterList = filterList.Where(p => p.dateCompletion != null &&
                                                  p.dateCompletion >= filterOrder._date1);
                }
                if (filterOrder._date2 != null)
                {
                    filterList = filterList.Where(p => p.dateCompletion != null &&
                                                  p.dateCompletion <= filterOrder._date2);
                }
                break;
            }

            case "Поступившие":
            {
                if (filterOrder._date1 != null)
                {
                    filterList = filterList.Where(p => p.dateReceipt >= filterOrder._date1);
                }
                if (filterOrder._date2 != null)
                {
                    filterList = filterList.Where(p => p.dateReceipt <= filterOrder._date2);
                }
                break;
            }
            }
            var count = filterList.Count();
            var items = filterList.Take(pageSize).ToList();
            OrdersListViewModel model = new OrdersListViewModel
            {
                PageViewModel        = new PageViewModel(count, 1, pageSize),
                OrderFilterViewModel = new OrderFilterViewModel(filterOrder.Car,
                                                                db.Workers.ToList(), filterOrder.SelectedWorker, filterOrder._date1, filterOrder._date2, filterOrder._selectedType),
                Orders = items
            };

            return(View(model));
        }