Пример #1
0
        public ActionResult GetFilteredSales(IEnumerable <int> customerIds, IEnumerable <SalesState> states,
                                             IEnumerable <Currency> currencies, string invoiceNo)
        {
            var salesByPerson = new SalesDataService().GetSalesBySalesPerson(User.Identity.GetUserId());

            var filteredSales = salesByPerson;

            if (customerIds != null)
            {
                filteredSales = salesByPerson.Where(x => customerIds.Contains(x.Customer.Id)).ToList();
            }
            if (states != null)
            {
                filteredSales = filteredSales.Where(x => states.Contains(x.SalesState)).ToList();
            }
            if (currencies != null)
            {
                filteredSales = filteredSales.Where(x => currencies.Contains(x.Currency)).ToList();
            }
            if (string.IsNullOrEmpty(invoiceNo) == false)
            {
                filteredSales = filteredSales.Where(x => invoiceNo == x.InvoiceNumber).ToList();
            }
            return(new JsonResult()
            {
                Data = filteredSales.Select(x => new OrderViewModel(x)),
                ContentType = "application/json",
                JsonRequestBehavior = JsonRequestBehavior.AllowGet,
                MaxJsonLength = Int32.MaxValue
            });
        }
Пример #2
0
        public ActionResult GetMyActiveOrders()
        {
            var myOrders              = new SalesDataService().GetSalesBySalesPerson(User.Identity.GetUserId());
            var myActiveOrders        = myOrders.Where(x => x.SalesState != SalesState.InvoiceDoneAndPacked);
            var myOrderedActiveOrders = myActiveOrders.OrderByDescending(x => x.SalesStartDate);
            var orderViewModel        = myOrderedActiveOrders.Select(x => new OrderViewModel(x));

            return(new JsonResult()
            {
                Data = orderViewModel,
                ContentType = "application/json",
                JsonRequestBehavior = JsonRequestBehavior.AllowGet,
                MaxJsonLength = Int32.MaxValue
            });
        }