public OrderViewModel() { var dishRepository = new DishRepository(); Dishes = dishRepository .GetAll() .Select(d => new DishViewModel { Id = d.Id, Name = d.Name, Price = d.Price }) .ToList(); }
public static async Task Main(string[] args) { string projectRootDir = DirectoryHelper.GetProjectRootDir(); string directoryCsvResource = Path.Combine(projectRootDir, @"data\csv\resource"); const string fileCsvIngredient = "ingredient.csv"; const string fileCsvOrder = "order.csv"; const string fileCsvDish = "dish.csv"; var ingredientCsvData = await CsvFileReader.ReadData(directoryCsvResource, fileCsvIngredient); var ingredients = CsvDataProvider <Ingredient> .ProvideData(ingredientCsvData, new IngredientMapper()); var orderCsvData = await CsvFileReader.ReadData(directoryCsvResource, fileCsvOrder); var orders = CsvDataProvider <Order> .ProvideData(orderCsvData, new OrderMapper()); var dishCsvData = await CsvFileReader.ReadData(directoryCsvResource, fileCsvDish); var dishes = CsvDataProvider <Dish> .ProvideData(dishCsvData, new DishMapper()); var ingredientRepo = new IngredientRepository(ingredients); var dishRepo = new DishRepository(dishes); IRestaurant restaurant = new Restaurant( new DishService(dishRepo, ingredientRepo), new OrderService(ingredientRepo, dishRepo), new IngredientService(ingredientRepo) ); Console.WriteLine("Before:"); ingredientRepo.GetAll().ForEach(Console.WriteLine); dishRepo.GetAll().ForEach(Console.WriteLine); Console.WriteLine(); orders.ForEach(order => { var(orderId, preparedDishes) = restaurant.ProcessOrder(order); Console.WriteLine($"Order ID: {orderId}"); preparedDishes.ToList().ForEach(Console.WriteLine); }); Console.WriteLine(); Console.WriteLine("After:"); ingredientRepo.GetAll().ForEach(Console.WriteLine); }
public async Task <List <Dish> > Get() { // Get all records from the Dish table return(await _repository.GetAll()); }
public IEnumerable <IDish> GetAll() => _repository.GetAll();
public IEnumerable <Dish> Get() { return(DishRepository.GetAll()); }
public List <Dish> GetAllDishes() { List <Dish> dishes = dishRepository.GetAll().ToList(); return(dishes); }