public IList <Dto.OrderMaster> All() { var orders = _orderRepository.All(); var itemIDs = orders.SelectMany(s => s.OrderDetails.Select(o => o.ItemId)); var items = _itemRepository.All().Where(i => itemIDs.Contains(i.Id)); var orderDto = from o in orders select new Dto.OrderMaster() { Id = o.Id, OrderAt = o.OrderAt, OrderBy = o.OrderBy, OrderDetails = (from od in o.OrderDetails select new Dto.OrderDetail { Id = od.Id, ItemId = od.ItemId, OrderMasterId = od.OrderMasterId, Quantity = od.Quantity, Item = (from i in items where i.Id == od.ItemId select new Dto.Item { Id = i.Id, Name = i.Name, Description = i.Description, Price = i.Price, Quantity = i.Quantity }).FirstOrDefault() }).ToList() }; return(orderDto.ToList()); }
public IEnumerable <Dto.Item> All() { var items = _itemRepository.All(); var itemDto = from i in items select new Dto.Item { Id = i.Id, Name = i.Name, Description = i.Description, Price = i.Price, Quantity = i.Quantity }; return(itemDto); }
public IQueryable <IItem> Items([Service] IItemRepository data) => data.All();