示例#1
0
        public async Task <IEnumerable <Order> > GetOrderListAsync(Guid userId, OrderFilters filters)
        {
            if (filters.EndDate == DateTime.MinValue)
            {
                filters.EndDate = DateTime.MaxValue;
            }

            Func <OrderStatus, bool> match;

            if (filters.StatusCode == OrderStatus.None)
            {
                match = (code) => code != OrderStatus.Cancelled && code != OrderStatus.Completed && code != OrderStatus.None &&
                        code != OrderStatus.All;
            }
            else if (filters.StatusCode == OrderStatus.All)
            {
                match = (_) => true;
            }
            else
            {
                match = (code) => code == filters.StatusCode;
            }

            return(await _context.Orders
                   .Where(order => order.UserId == userId && match(order.StatusCode) &&
                          order.OrderDate >= filters.BeginDate && order.OrderDate <= filters.EndDate)
                   .Include(order => order.OrderDetails)
                   .ThenInclude(od => od.Product)
                   .OrderByDescending(order => order.OrderDate)
                   .ToArrayAsync());
        }
示例#2
0
        public static Orders GetOrders(OrderFilters Filter)
        {
            string        FilterString = "&pageRows=" + Filter.PageRows + "&startrow=" + Filter.StartRow;
            Orders        model        = null;
            XmlSerializer Serializer   = new XmlSerializer(typeof(Orders));

            foreach (PropertyInfo prop in typeof(OrderFilters).GetProperties())
            {
                FilterString = (Attribute.IsDefined(prop, typeof(FilterField)) && prop.GetValue(Filter) != null) ? FilterString + "&" + prop.Name + "=" + prop.GetValue(Filter) : FilterString;
            }

            string Url = string.Concat(BASE_URL, ENDPOINT, QUERYPARAMS, FilterString);

            //If using Http based
            var Client  = new HttpClient();
            var GetTask = Client.GetAsync(Url)
                          .ContinueWith((TaskWithResponse) =>
            {
                var Response = TaskWithResponse.Result;
                var ReadTask = Response.Content.ReadAsStreamAsync();
                ReadTask.Wait();
                model = (Orders)Serializer.Deserialize(ReadTask.Result);
            });

            GetTask.Wait();
            return(model);
        }
示例#3
0
 public async Task <IEnumerable <Order> > Get(OrderFilters filters)
 {
     return(await Query(filters)
            .AsNoTracking()
            .Include(x => x.Status)
            .ToListAsync());
 }
示例#4
0
        public List <Order> GetOrders(User user, OrderFilters filters)
        {
            var orders = context.Orders
                         .AsNoTracking()
                         .Where(o => filters.OrderStatus == null || o.Status == filters.OrderStatus)
                         .Where(o => filters.DateRange == null || (filters.DateRange.Begin < o.DatePlaced && o.DatePlaced < filters.DateRange.End))
                         .Include(o => o.Buyer)
                         .Include(o => o.Seller)
                         .Where(o => filters.OrderType == null ||
                                (filters.OrderType == OrderType.ToReceive && o.Buyer.Id == user.Id) ||
                                (filters.OrderType == OrderType.ToFulfill && o.Seller.Id == user.Id))
                         .Include(o => o.Product)
                         .Where(o => filters.ProductType == null || o.Product.Type == filters.ProductType)
                         .Where(o => filters.Search == null || o.Product.Name.ToLower().Contains(filters.Search.ToLower()) || o.Product.Description.ToLower().Contains(filters.Search.ToLower()))
                         .Include(o => o.AdditionalDetail)
                         .ThenInclude(a => a.ProductImage)
                         .ToList();

            orders.ForEach(o =>
            {
                o.Buyer.FirstName                 = protector.Unprotect(o.Buyer.FirstName);
                o.Buyer.LastName                  = protector.Unprotect(o.Buyer.LastName);
                o.Buyer.PhoneNumber               = protector.Unprotect(o.Buyer.PhoneNumber);
                o.Seller.FirstName                = protector.Unprotect(o.Seller.FirstName);
                o.Seller.LastName                 = protector.Unprotect(o.Seller.LastName);
                o.Seller.PhoneNumber              = protector.Unprotect(o.Seller.PhoneNumber);
                o.AdditionalDetail.ContactName    = protector.Unprotect(o.AdditionalDetail.ContactName);
                o.AdditionalDetail.ContactAddress = protector.Unprotect(o.AdditionalDetail.ContactAddress);
                o.AdditionalDetail.ContactPhone   = protector.Unprotect(o.AdditionalDetail.ContactPhone);
            });
            return(orders);
        }
示例#5
0
        public Task <List <OrderModel> > GetPaged(OrderFilters filters)
        {
            var orders = _db.OrderModels
                         .Include(p => p.AmputationTypeFk)
                         .Include(c => c.OrderRequestor)
                         .Include(c => c.OrderAmbassador)
                         .Include(p => p.RenderPieces)
                         .OrderByDescending(x => x.Date);

            var ordersFiltered = orders
                                 .Where(x =>
                                        (!filters.ByStatus || x.Status == filters.Status)
                                        &&
                                        (!filters.ByAmputationType || x.AmputationType == filters.AmputationType)
                                        &&
                                        (filters.SearchTerm == null || filters.SearchTerm == "" ||
                                         x.OrderRequestor.Email.Contains(filters.SearchTerm) &&
                                         x.OrderRequestor.AlternativeEmail.Contains(filters.SearchTerm) &&
                                         x.OrderRequestor.Country.Contains(filters.SearchTerm) &&
                                         x.OrderAmbassador.Email.Contains(filters.SearchTerm) &&
                                         x.OrderRequestor.AlternativeEmail.Contains(filters.SearchTerm) &&
                                         x.OrderRequestor.Country.Contains(filters.SearchTerm)));

            return(ordersFiltered.ToListAsync());
        }
示例#6
0
 public async Task <IEnumerable <Order> > GetByUser(
     Guid UserID,
     OrderFilters filters) =>
 await Query(filters)
 .AsNoTracking()
 .Include(x => x.Status)
 .Where(x => x.UserId == UserID)
 .ToListAsync();
示例#7
0
 private IQueryable <Order> Query(OrderFilters filters) =>
 _context.Order.Where(x => x.StatusId == (OrderStatus)filters.StatusId || filters.StatusId == 0)
 .Where(x => x.OrderNumber.ToString().Contains(filters.OrderNumber.NullToEmpty()))
 .Where(x => x.CompanyName.Contains(filters.CompanyName.NullToEmpty()))
 .Where(x => string.Concat(x.FirstName, x.Surname).Contains(filters.Name.NullToEmpty().RemoveWhiteSpace()))
 .Where(x => x.TemplateNumber == filters.TemplateNumber || filters.TemplateNumber == 0)
 .Where(x => x.EmailAddress.Contains(filters.EmailAddress.NullToEmpty()))
 .OrderBy(string.Concat(filters.OrderBy ?? $"{nameof(Order.CreatedDate)} descending", " ", filters.Decending ? "descending" : string.Empty))
 .Skip(filters.Skip)
 .Take(filters.Take > 0 ? filters.Take : DEFAULT_TAKE_COUNT);
示例#8
0
        public async Task <IEnumerable <Order> > GetOrdersByUser(
            Guid UserId,
            OrderFilters filters)
        {
            if (UserId == Guid.Empty)
            {
                throw new ArgumentOutOfRangeException(nameof(UserId));
            }

            return(await _orderRepository.GetByUser(UserId, filters));
        }
示例#9
0
        public IEnumerable <Order> GetOrders(DateTime fromDate, int?minimumOrderStatus = null, int?maximumOrderStatus = null)
        {
            var query = new OrderFilters
            {
                OrderStatusFrom = minimumOrderStatus,
                OrderStatusTo   = maximumOrderStatus,
                LastUpdatedFrom = fromDate
            };
            var response = _soapClient.GetOrdersByQuery(_goodsOwner.Name, _user.Name, _user.Password, query);

            return(response.Orders);
        }
示例#10
0
 public IActionResult GetOrders([FromQuery] OrderFilters filters)
 {
     try
     {
         var user   = uEngine.GetUser(this.User.FindFirst(ClaimTypes.Email).Value);
         var orders = engine.GetOrders(user, filters);
         return(Ok(orders));
     }
     catch (Exception ex)
     {
         return(StatusCode(500, ex.Message));
     }
 }
示例#11
0
        public async Task <IActionResult> Filter(OrderFilters orderFilters)
        {
            var user = await _userManager.GetUserAsync(HttpContext.User);

            var orders = await _orderService.GetOrderListAsync(Guid.Parse(user.Id), orderFilters);

            OrderListViewModel orderList = new OrderListViewModel()
            {
                Orders = orders
            };

            return(View("Index", orderList));
        }
示例#12
0
        // GET: Admin/Order
        public async Task <ActionResult> Index(OrderFilters filters)
        {
            var f         = filters ?? new OrderFilters();
            var orderList = await _os.GetPaged(f);

            var model = new OrderListViewModel
            {
                List    = Mapper.Map <IEnumerable <OrderAdminIndexViewModel> >(orderList),
                Filters = f,
            };

            return(View(model));
        }
示例#13
0
        //
        // GET: /Orders/

        public ActionResult Orders(OrderFilters Filters)
        {
            OrderPageData PageData = new OrderPageData();

            Filters.StartRow  = (Filters.StartRow == 0) ? 1 : Filters.StartRow;
            Filters.PageRows  = (Filters.PageRows == 0) ? 10 : Filters.PageRows;
            Filters.TransType = Filters.TransType ?? "Orders";

            PageData.Orders  = APIReader.GetOrders(Filters);
            PageData.Filters = Filters;

            if (Request.IsAjaxRequest())
            {
                return(PartialView("OrdersTable", PageData));
            }

            return(View(PageData));
        }
 public async Task <IViewComponentResult> InvokeAsync(OrderFilters filters)
 {
     return(await Task.Run(() => View(filters)));
 }
示例#15
0
 public async Task <IEnumerable <Order> > GetOrder(OrderFilters filters) =>
 await _orderRepository.Get(filters);