示例#1
0
        public OrderViewModel()
        {
            var dishRepository = new DishRepository();

            Dishes = dishRepository
                     .GetAll()
                     .Select(d => new DishViewModel
            {
                Id    = d.Id,
                Name  = d.Name,
                Price = d.Price
            })
                     .ToList();
        }
示例#2
0
        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());
 }
示例#4
0
文件: DishLogic.cs 项目: rikp777/Fit
 public IEnumerable <IDish> GetAll() => _repository.GetAll();
 public IEnumerable <Dish> Get()
 {
     return(DishRepository.GetAll());
 }
示例#6
0
        public List <Dish> GetAllDishes()
        {
            List <Dish> dishes = dishRepository.GetAll().ToList();

            return(dishes);
        }