/// <summary> /// Place orders for restaurant /// </summary> /// <param name="restaurantName">Name of restaurant</param> public void PlaceOrdersForRestaurant(string restaurantName) { switch (restaurantName) { case "Restoran pod Lipom": var lipa = _restaurantQueryRepo.Query(new RestaurantQueryModel { Name = restaurantName }) .Map(x => x.Items.FirstOrDefault()) .Reduce(_ => throw new Exception()); if (lipa != null) { var lipaOrders = _orderQueryRepo.GetAllOrdersForRestaurant(lipa.Id, 1, int.MaxValue) .Map(x => x.Items.Where(o => o.Date == DateTime.Today.Date).ToList()) .Reduce(_ => throw new Exception()); _lipaConector.PlaceOrders(lipaOrders); } break; case "Hedone": var hedone = _restaurantQueryRepo.Query(new RestaurantQueryModel { Name = restaurantName }) .Map(x => x.Items.FirstOrDefault()) .Reduce(_ => throw new Exception()); if (hedone != null) { var hedoneOrders = _orderQueryRepo.GetAllOrdersForRestaurant(hedone.Id, 1, int.MaxValue) .Map(x => x.Items.Where(o => o.Date == DateTime.Today.Date).ToList()) .Reduce(_ => throw new Exception()); _hedoneConector.PlaceOrders(hedoneOrders); } break; case "Teglas": var teglas = _restaurantQueryRepo.Query(new RestaurantQueryModel { Name = restaurantName }) .Map(x => x.Items.FirstOrDefault()) .Reduce(_ => throw new Exception()); if (teglas != null) { var teglasOrders = _orderQueryRepo.GetAllOrdersForRestaurant(teglas.Id, 1, int.MaxValue) .Map(x => x.Items.Where(o => o.Date == DateTime.Today.Date).ToList()) .Reduce(_ => throw new Exception()); _teglasConector.PlaceOrders(teglasOrders); } break; default: throw new ArgumentException("Invalid restaurant"); } }
public void PlaceOrders() { _lipaConector.PlaceOrders(_fakeDataFactory.GetOrders()); }