Пример #1
0
        public MenuModel GetMenuByDate(DateTime date)
        {
            var menuRepo       = new MenuRepo();
            var menuDetailRepo = new MenuDetailRepo();
            var foodRepo       = new FoodRepo();
            var menu           = menuRepo.GetMenuByDate(date);
            var menuModel      = new MenuModel()
            {
                Id          = menu.Id,
                Name        = menu.Name,
                Date        = menu.Date,
                MenuDetails = menuDetailRepo.GetMenuDetailByMenu(menu.Id)
                              .Select(md => new MenuDetailModel()
                {
                    Id   = md.Id,
                    Food = foodRepo.GetFoodsById(md.FoodId).Select(f => new FoodModel()
                    {
                        Id   = f.Id,
                        Name = f.Name,
                        Type = f.Type
                    }).First()
                })
            };

            return(menuModel);
        }
Пример #2
0
        public void RemoveMenuDetails(int menuId)
        {
            var menudetailRepo = new MenuDetailRepo();
            var menuDetails    = menudetailRepo.GetMenuDetailByMenu(menuId);

            foreach (var detail in menuDetails)
            {
                menudetailRepo.RemoveMenuDetail(detail);
            }
        }