Infrastructure.OrderRepository.GetAllOrdersByCustomerId C# (CSharp) Method

GetAllOrdersByCustomerId() public method

public GetAllOrdersByCustomerId ( string CustomerId ) : ICollection
CustomerId string
return ICollection
        public ICollection<Order> GetAllOrdersByCustomerId(string CustomerId)
        {
            return _context.Orders.Where(o => o.CustomerId == CustomerId).OrderByDescending(o => o.OrderDate).ToList();
        }
        public Shipment GetShipmentByOrderId(int OrderId)

Usage Example

Example #1
0
        public int GetLastOrderId()
        {
            // Add your operation implementation here
            var repo = new OrderRepository();
            var customerRepo = new CustomerRepository();

            var authCookie = System.Web.HttpContext.Current.Request.Cookies[FormsAuthentication.FormsCookieName];
            if (authCookie == null)
                throw new Exception("Not logged in.");
            var authTicket = FormsAuthentication.Decrypt(authCookie.Value);
            var customerId = customerRepo.GetCustomerByUsername(authTicket.Name).CustomerId;
            var order = repo.GetAllOrdersByCustomerId(customerId).OrderByDescending(o => o.OrderId).First();
            return order.OrderId;
        }