IEnumerable <lib.Orders> IOrderRepository.GetOrderHistoryofLocation(lib.Location location)
        {
            var entities = _dbContext.OrderHistory
                           .Include(o => o.Location)
                           .Include(o => o.Customer)
                           .Where(o => o.LocationId == location.Id);
            var orders = entities.Select(e => new lib.Orders
                                         (
                                             e.OrderId,
                                             e.Date,
                                             new lib.Location
            {
                Id   = e.LocationId,
                Name = e.Location.LocationName,
            },
                                             new lib.Customer(e.Customer.FirstName, e.Customer.LastName)
            {
                customerID = e.Customer.CustomerId,
            },
                                             e.TotalCost
                                         ));

            foreach (var order in orders.ToList())
            {
                order.OrderLine = GetAllProducts(order.OrderId);
            }
            return(orders);
        }
示例#2
0
        public void Add(lib.Location location)
        {
            _logger.Info("Adding Location");

            Location entity = Mapper.MapLibLocation(location);

            _dbContext.Add(entity);
        }
示例#3
0
        public void Update(lib.Location location)
        {
            var entity = _dbContext.Location
                         .First(s => s.LocationId == location.Id);

            foreach (var item in location.Inventory.Keys)
            {
                entity.Inventory.First(i => i.ProductId == item.ProductId).Amount = location.Inventory[item];
            }
            _dbContext.SaveChanges();
        }