Example #1
0
        public IQueryable <Order> SearchOrders(SearchOrderOptions options)
        {
            if (options == null)
            {
                return(null);
            }

            var query = context_
                        .Set <Order>()
                        .AsQueryable();

            if (options.OrderId != null)
            {
                query = query.Where(c => c.OrderId == options.OrderId.Value);
            }
            if (options.CustomerId != null)
            {
                var customer = customerService_.SearchCustomers(new SearchCustomerOptions()
                {
                    CustomerId = options.CustomerId
                }).SingleOrDefault();
                query = query.Where(c => customer.Orders.Contains(c));
            }

            //if (options.ProductIds.Any())
            //{
            //    query = query.Where(c => !options.ProductIds.Except(c.OrderProducts.Pr).Any());
            //}

            query = query.Take(500);

            return(query);
        }
Example #2
0
        public IQueryable <Order> SearchOrders(SearchOrderOptions options)
        {
            if (options == null)
            {
                return(null);
            }

            var query = context_
                        .Set <Order>()
                        .AsQueryable();

            if (options.DeliveryAddress != null)
            {
                query = query.Where(o => o.DeliveryAddress == options.DeliveryAddress);
            }
            if (options.PriceFrom != null)
            {
                query = query.Where(o => o.TotalAmount >= options.PriceFrom);
            }
            if (options.PriceTo != null)
            {
                query = query.Where(o => o.TotalAmount <= options.PriceTo);
            }

            return(query.AsQueryable());
        }
Example #3
0
        public IQueryable <Order> SearchOrders(
            SearchOrderOptions options)
        {
            if (options == null)
            {
                return(null);
            }

            var query = context
                        .Set <Order>()
                        .AsQueryable();

            if (options.OrderId != null)
            {
                query = query.Where(ord => ord.OrderId == options.OrderId);
            }

            if (options.CreatedFrom != null)
            {
                query = query.Where(ord => ord.Created >= options.CreatedFrom);
            }

            if (options.CreatedTo != null)
            {
                query = query.Where(ord => ord.Created <= options.CreatedTo);
            }

            if (!string.IsNullOrWhiteSpace(options.DeliveryAddress))
            {
                query = query.Where(ord => ord.DeliveryAddress == options.DeliveryAddress);
            }


            return(query);
        }
Example #4
0
        // find for specific orders
        public List <Order> SearchOrders(SearchOrderOptions opt)
        {
            if (opt == null)
            {
                return(null);
            }

            var customers = db_.Set <Customer>()
                            .Where(ord => opt.CustomerId == ord.CustomerId)
                            .Include(c => c.Orders)
                            .ToList();

            if (customers.Count() > 0)
            {
                var orders = new List <Order>();

                foreach (var c in customers)
                {
                    foreach (var el in c.Orders)
                    {
                        orders.Add(el);
                    }
                }

                return(orders);
            }
            else
            {
                return(null);
            }
        }
Example #5
0
        public List <Order> SearchOrder(SearchOrderOptions options)
        {
            if (options == null)
            {
                return(null);
            }

            var oResults = context_.Set <Customer>()
                           .Where(o => o.CustomerId == options.CustomerId)
                           .Include(c => c.Orders).SingleOrDefault();

            return(oResults.Orders);
        }
Example #6
0
        public ApiResult <int> OrdersInEachStatus(
            SearchOrderOptions option)
        {
            if (option == null)
            {
                return(new ApiResult <int>(
                           StatusCode.BadRequest,
                           "null options"));
            }

            var status      = option.OrderStatus;
            var result      = order_.SearchOrder(option);
            var order       = result.Data;
            var totalOrders = order.Count();

            return(ApiResult <int> .CreateSuccessful(
                       totalOrders));
        }
Example #7
0
        public IQueryable <Order> SearchOrders(SearchOrderOptions options)
        {
            if (options == null)
            {
                return(null);
            }

            var query = context_
                        .Set <Order>()
                        .AsQueryable();

            if (!string.IsNullOrWhiteSpace(options.DeliveryAddress))
            {
                query = query.Where(c => c.DeliveryAddress.Contains(options.DeliveryAddress));
            }

            if (options.OrderId != null)
            {
                query = query.Where(c => c.OrderId == options.OrderId);
            }

            if (options.CreatedFrom != null)
            {
                query = query.Where(c => c.Created >= options.CreatedFrom);
            }

            if (options.CreatedTo != null)
            {
                query = query.Where(c => c.Created <= options.CreatedTo);
            }

            if (options.PriceFrom >= 0)
            {
                query = query.Where(c => c.TotalAmount >= options.PriceFrom);
            }

            if (options.PriceTo >= 0)
            {
                query = query.Where(c => c.TotalAmount <= options.PriceTo);
            }

            return(query);
        }
Example #8
0
        public ApiResult <IQueryable <Order> > SearchOrder(
            SearchOrderOptions options)
        {
            if (options == null)
            {
                return(ApiResult <IQueryable <Order> > .CreateUnsuccessful(
                           StatusCode.BadRequest, "Null order"));
            }

            if (options.OrderId == null &&
                options.CustomerId == null &&
                options.VatNumber == null)
            {
                return(new ApiResult <IQueryable <Order> >(
                           StatusCode.BadRequest, "Null order"));
            }

            var query = context_
                        .Set <Order>()
                        .AsQueryable();

            if (options.OrderId != null)
            {//check guid
                query = query.Where(o => o.Id.Equals(options.OrderId));
            }

            if (options.CustomerId != null)
            {
                query = query.Where(o => o.CustomerId.Equals(options.CustomerId));
            }

            if (options.VatNumber != null)
            {
                query = query.Where(o => o.Customer.VatNumber.Equals(options.VatNumber));
            }

            return(ApiResult <IQueryable <Order> > .CreateUnsuccessful(
                       StatusCode.BadRequest, "Null order"));
        }
Example #9
0
 //SearchOrder
 public IQueryable <Order> SearchOrder(SearchOrderOptions options)
 {
     throw new NotImplementedException();
 }