public CustomerOrderEntity GetCustomerOrderById(string id, CustomerOrderResponseGroup responseGroup) { var query = CustomerOrders.Where(x => x.Id == id) .Include(x => x.Discounts) .Include(x => x.TaxDetails); if ((responseGroup & CustomerOrderResponseGroup.WithAddresses) == CustomerOrderResponseGroup.WithAddresses) { var addresses = Addresses.Where(x => x.CustomerOrderId == id).ToArray(); } if ((responseGroup & CustomerOrderResponseGroup.WithInPayments) == CustomerOrderResponseGroup.WithInPayments) { var inPayments = InPayments.Where(x => x.CustomerOrderId == id).ToArray(); var paymentsIds = inPayments.Select(x => x.Id).ToArray(); var paymentAddresses = Addresses.Where(x => paymentsIds.Contains(x.PaymentInId)).ToArray(); } if ((responseGroup & CustomerOrderResponseGroup.WithItems) == CustomerOrderResponseGroup.WithItems) { var lineItems = LineItems.Include(x => x.TaxDetails) .Include(x => x.Discounts) .Where(x => x.CustomerOrderId == id).ToArray(); } if ((responseGroup & CustomerOrderResponseGroup.WithShipments) == CustomerOrderResponseGroup.WithShipments) { var shipments = Shipments.Include(x => x.TaxDetails) .Include(x => x.Discounts) .Include(x => x.Items) .Include(x => x.Packages.Select(y => y.Items)) .Where(x => x.CustomerOrderId == id).ToArray(); var shipmentIds = shipments.Select(x => x.Id).ToArray(); var addresses = Addresses.Where(x => shipmentIds.Contains(x.ShipmentId)).ToArray(); } return(query.FirstOrDefault()); }
/// <summary> /// 根据订单id查找物流 /// </summary> /// <param name="orderId"></param> /// <param name="readOnly"></param> /// <returns></returns> public virtual IList <Shipment> FindByOrderId(long orderId, bool readOnly = false) { if (!readOnly) { return(ShipmentRepository.GetAllIncluding(s => s.Items).Where(s => s.OrderId == orderId).ToList()); } else { return(Shipments.Include(s => s.Items).Where(s => s.OrderId == orderId).ToList()); } }
public Shipment ReleaseShipment(Guid id) { var shipment = Shipments.Include(s => s.Driver).Include(s => s.From).Include(s => s.To).Where(s => s.ShipmentID == id).First(); if ((shipment.Driver == null) || (shipment.Driver.DriverID != this.driverID)) { throw new InvalidOperationException("This shipment is not reserved for the current driver."); } shipment.Driver = null; SaveChanges(); return(shipment); }
public Shipment ReserveShipment(Guid id) { var shipment = Shipments.Include(s => s.Driver).Where(s => s.ShipmentID == id).First(); //Check to make sure it is not already reserved if (shipment.Driver != null) { throw new InvalidOperationException("This shipment is already reserved"); } var driver = Drivers.First(d => d.DriverID == this.driverID); shipment.Driver = driver; SaveChanges(); return(shipment); }
public virtual CustomerOrderEntity[] GetCustomerOrdersByIds(string[] ids, CustomerOrderResponseGroup responseGroup) { var query = CustomerOrders.Where(x => ids.Contains(x.Id)) .Include(x => x.Discounts) .Include(x => x.TaxDetails); if ((responseGroup & CustomerOrderResponseGroup.WithAddresses) == CustomerOrderResponseGroup.WithAddresses) { var addresses = Addresses.Where(x => ids.Contains(x.CustomerOrderId)).ToArray(); } if ((responseGroup & CustomerOrderResponseGroup.WithInPayments) == CustomerOrderResponseGroup.WithInPayments) { var inPayments = InPayments.Include(x => x.TaxDetails) .Include(x => x.Discounts) .Where(x => ids.Contains(x.CustomerOrderId)).ToArray(); var paymentsIds = inPayments.Select(x => x.Id).ToArray(); var paymentAddresses = Addresses.Where(x => paymentsIds.Contains(x.PaymentInId)).ToArray(); var transactions = Transactions.Where(x => paymentsIds.Contains(x.PaymentInId)).ToArray(); } if ((responseGroup & CustomerOrderResponseGroup.WithItems) == CustomerOrderResponseGroup.WithItems) { var lineItems = LineItems.Include(x => x.TaxDetails) .Include(x => x.Discounts) .Where(x => ids.Contains(x.CustomerOrderId)).ToArray(); } if ((responseGroup & CustomerOrderResponseGroup.WithShipments) == CustomerOrderResponseGroup.WithShipments) { var shipments = Shipments.Include(x => x.TaxDetails) .Include(x => x.Discounts) .Include(x => x.Items) .Include(x => x.Packages.Select(y => y.Items)) .Where(x => ids.Contains(x.CustomerOrderId)).ToArray(); var shipmentIds = shipments.Select(x => x.Id).ToArray(); var addresses = Addresses.Where(x => shipmentIds.Contains(x.ShipmentId)).ToArray(); } return(query.ToArray()); }
public Shipment GetShipment(Guid id) { return(Shipments.Include(s => s.Driver).Include(s => s.From).Include(s => s.To).Where(s => s.ShipmentID == id).First()); }
public List <Shipment> GetMyShipments() { return(Shipments.Include(s => s.Driver).Include(s => s.From).Include(s => s.To).Where(s => (s.Driver != null) && (s.Driver.DriverID == this.driverID)).ToList()); }
public List <Shipment> GetOpenShipments() { return(Shipments.Include(s => s.Driver).Include(s => s.From).Include(s => s.To).Where(s => s.Driver == null).ToList()); }
public List <Shipment> GetMyShipments() { return(Shipments.Include(s => s.Driver).Include(s => s.From).Include(s => s.To).Where(s => (s.Driver != null) && (s.Driver.ContractorID == WebApiApplication.CurrentUser)).ToList()); }