Esempio n. 1
0
        public IQueryable <RestaurantMenu> GetRestaurantMenus(int restaurantID)
        {
            IQueryable <MenuDetails> menuDetails;
            List <RestaurantMenu>    restaurant_Menu = new List <RestaurantMenu>();

            try
            {
                menuDetails = search_Repository.GetRestaurantMenu(restaurantID);
                foreach (var menu in menuDetails)
                {
                    RestaurantMenu menuInfo = new RestaurantMenu
                    {
                        menu_ID       = menu.tbl_Offer.Id,
                        dish_Name     = menu.tbl_Menu.Item,
                        price         = menu.tbl_Offer.Price,
                        running_Offer = menu.tbl_Offer.Discount,
                        cuisine       = menu.tbl_Cuisine.Cuisine
                    };
                    restaurant_Menu.Add(menuInfo);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(restaurant_Menu.AsQueryable());
        }
Esempio n. 2
0
 public JsonResult AddMenuItem(ItemMenuV item)
 {
     if (item != null)
     {
         var menuItemView = new RestaurantMenu()
         {
             Id           = item._Id,
             availability = true,
             category     = Convert.ToInt32(item._category),
             name         = item._name,
             information  = item._information,
             price        = item._price,
             picture      = "..\\images\\" + item._picture,
             novelty      = true,
             hit          = false
         };
         db.RestaurantMenu.InsertOnSubmit(menuItemView);
         db.SubmitChanges();
         return(Json("MenuItem ADD OK"));
     }
     else
     {
         return(Json("Invalid Item"));
     }
 }
Esempio n. 3
0
        public RestaurantMenu CreateNewMenu()
        {
            RestaurantMenu restaurantMenu = new RestaurantMenu();

            restaurantMenu.MenuName = GetMenuName();
            return(restaurantMenu);
        }
        public void RestauranMenu_RemoveFromMenu()
        {
            // Create the object for a test
            Dictionary <RestaurantMeal.MealType, int> menuContent =
                new Dictionary <RestaurantMeal.MealType, int>
            {
                { RestaurantMeal.MealType.Vegetarian, 5 },
                { RestaurantMeal.MealType.GlutenFree, 10 }
            };

            RestaurantMenu restaurantMenu = new RestaurantMenu();

            restaurantMenu.MenuContent = menuContent;

            //Remove 5 gluten free meals
            restaurantMenu.RemoveFromMenu(RestaurantMeal.MealType.GlutenFree, 5);

            // Create expected dictionary
            Dictionary <RestaurantMeal.MealType, int> expectMenuContent =
                new Dictionary <RestaurantMeal.MealType, int>
            {
                { RestaurantMeal.MealType.Vegetarian, 5 },
                { RestaurantMeal.MealType.GlutenFree, 5 }
            };

            // Test if they are the same
            Assert.IsTrue(Verifier.DictionariesAreEq(menuContent, expectMenuContent));
        }
Esempio n. 5
0
        public Response AddMenuToRestaurant(string id, [FromBody] RestaurantMenu model)
        {
            var isValidateData = model != null && !string.IsNullOrWhiteSpace(model.Name);

            if (!isValidateData)
            {
                return new Response {
                           IsSuccess = false, ErrorMessage = "Data can not be empty"
                }
            }
            ;

            var restaurant = _collectionRestaurants.Find(it => it.Id == id).FirstOrDefault();

            if (restaurant == null)
            {
                return(new Response {
                    IsSuccess = false, ErrorMessage = "Restaurant not found"
                });
            }

            model.Id = Guid.NewGuid().ToString();
            var menus = restaurant.Menus.ToList();

            menus.Add(model);
            restaurant.Menus = menus;
            _collectionRestaurants.ReplaceOne(it => it.Id == id, restaurant);
            return(new Response {
                IsSuccess = true
            });
        }
    }
        public async Task Consume(ConsumeContext <OrderConfirmedEvent> context)
        {
            try
            {
                _logger.LogInformation("Delivery Message received");

                var menus = await _restaurantRepository.GetAllMenuAsync();

                var restaurant = _restaurantRepository.GetAllRestaurantAsync().Result.ToList()
                                 .Find(x => x.RestaurantId == context.Message.RestaurantId);

                foreach (var item in context.Message.OrderItems)
                {
                    foreach (var menu in menus)
                    {
                        if (menu.MenuId == item.MenuId)
                        {
                            var restaurantMenu = new RestaurantMenu();
                            restaurantMenu.RestaurantId = context.Message.RestaurantId;
                            item.Quantity       = menu.Quantity - item.Quantity;
                            restaurantMenu.Menu = item;
                            await _restaurantRepository.UpdateRestaurantMenu(restaurantMenu);
                        }
                    }
                }

                await _bus.Publish(new OrderReadyEvent(restaurant.Address, context.Message.Address, context.Message.OrderId));
            }
            catch (Exception ex)
            {
                _logger.LogError("An error has occured during delivery", ex.Message);
                throw ex;
            }
        }
Esempio n. 7
0
        public void testi()
        {
            Restaurant     r  = SelectRestaurantFromAllRestaurantsList();
            RestaurantMenu rm = SelectMenuFromRestaurant(r);
            Category       c  = SelectCategoryFromMenu(rm);

            ShowCategoryWithNumbers(c);
        }
Esempio n. 8
0
        public int ItemInStock(int restaurantID, int menuID)
        {
            RestaurantMenu menuObj = new RestaurantMenu();
            TblMenu        menu    = search_Repository.ItemInStock(restaurantID, menuID);

            menuObj.quantity = menu.quantity;
            return(0);
        }
Esempio n. 9
0
 public void ShowMenuWithCategoryNumbers(RestaurantMenu menu)
 {
     Console.WriteLine($"Categories in menu: {menu.MenuName}");
     for (int i = 0; i < menu.menus.Count; i++)
     {
         Console.WriteLine();
         Console.WriteLine($"{i+1}. {menu.menus[i].categoryName}");
     }
 }
Esempio n. 10
0
 public void ShowRestaurantMenu(RestaurantMenu menu)
 {
     Console.WriteLine(menu.MenuName);
     foreach (Category category in menu.menus)
     {
         Console.WriteLine();
         ShowCategory(category);
     }
 }
        public async Task <ActionResult> DeleteConfirmed(int id)
        {
            RestaurantMenu restaurantMenu = await db.RestaurantMenus.FindAsync(id);

            db.RestaurantMenus.Remove(restaurantMenu);
            await db.SaveChangesAsync();

            return(RedirectToAction("Index"));
        }
Esempio n. 12
0
        public int ItemInStock(int menuID)
        {
            RestaurantMenu menuObj = new RestaurantMenu();
            TblMenu        menu    = search_Repository.ItemInStock(menuID);

            menuObj.quantity = menu.quantity;
            menuObj.price    = menu.price;
            return(menuObj.quantity);
        }
        public async Task <ActionResult> Edit([Bind(Include = "id,item,price,qty")] RestaurantMenu restaurantMenu)
        {
            if (ModelState.IsValid)
            {
                db.Entry(restaurantMenu).State = EntityState.Modified;
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            return(View(restaurantMenu));
        }
Esempio n. 14
0
        static void AddRestaurantMenu(HambusDbContext ctx)
        {
            RestaurantMenu restarantMenu = new RestaurantMenu
            {
                RestaurantMenuId = 1,
                MenuVersion      = "v2",
                Categories       = new List <MenuCategory>
                {
                    new MenuCategory {
                        MenuCategoryId   = "BURG",
                        MenuCategoryName = "Hamburgesas",
                        MenuProducts     = new List <MenuItem>
                        {
                            new MenuItem
                            {
                                MenuItemId      = 1,
                                ItemName        = "Pilungosa",
                                ItemDescripcion = "Hamburgesa con queso",
                                MenuCategoryId  = "BURG",

                                MenuItemSupplies = new List <MenuItemSupplies>()
                            },
                            new MenuItem
                            {
                                MenuItemId      = 2,
                                ItemName        = "Hulk",
                                ItemDescripcion = "Hamburgesa con queso",
                                MenuCategoryId  = "BURG"
                            },
                        },
                        RestaurantMenuId = 1
                    },
                    new MenuCategory {
                        MenuCategoryId   = "ASA",
                        MenuCategoryName = "Asados",
                        RestaurantMenuId = 1
                    },
                    new MenuCategory {
                        MenuCategoryId   = "APE",
                        MenuCategoryName = "Aperitivos",
                        RestaurantMenuId = 1
                    },
                    new MenuCategory {
                        MenuCategoryId   = "BEB",
                        MenuCategoryName = "Bebidas",
                        RestaurantMenuId = 1
                    },
                }
            };

            ctx.RestaurantMenus.Add(restarantMenu);

            ctx.SaveChanges();
        }
        public async Task <ActionResult> Create([Bind(Include = "id,item,price,qty")] RestaurantMenu restaurantMenu)
        {
            if (ModelState.IsValid)
            {
                db.RestaurantMenus.Add(restaurantMenu);
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }

            return(View(restaurantMenu));
        }
 public void InitializeReadingTest()
 {
     RedoFiles();
     /// Read Stock file elements
     stock = fileInterface.ReadStockFile(TestStockCsv);
     Assert.AreEqual(5, stock.GetElementCount());
     /// Read Menu file elements
     menu = fileInterface.ReadMenuFile(TestMenuCsv);
     Assert.AreEqual(3, menu.GetElementCount());
     orders = fileInterface.ReadOrdersFile(TestOrdersCsv, menu);
     Assert.AreEqual(5, orders.GetElementCount());
 }
        public RestaurantMenu GetCurrentMenu()
        {
            //Instantiates new RestaurantMenu object and
            //sorts MeuItem objects by byDescription using LINQ
            var menuToReturn = new RestaurantMenu();

            var menuToReturnOrdered = (
                from items in menuToReturn
                orderby items.Description
                select items).ToList();

            menuToReturn = new RestaurantMenu(menuToReturnOrdered);
            return(menuToReturn);
        }
        public RestaurantMenu GetCurrentMenu()
        {
            //Instantiates new RestaurantMenu object and
            //sorts MeuItem objects by byDescription using LINQ
            var menuToReturn = new RestaurantMenu();

            var menuToReturnOrdered = (
                from items in menuToReturn
                orderby items.Description
                select items).ToList();

            menuToReturn = new RestaurantMenu(menuToReturnOrdered);
            return menuToReturn;
        }
        public void RemoveMenuItem_Successful()
        {
            /// Read elements from list
            InitializeReadingTest();
            MenuItem removableItem = menu.GetItemByID(1);
            int      removableId   = removableItem.GetId();

            /// Remove item from list
            Program.RemoveElement(TestMenuCsv, menu, removableId, orders);
            Assert.IsFalse(menu.DoesItemExistsByID(removableId));
            RestaurantMenu newMenu = fileInterface.ReadMenuFile(TestMenuCsv);

            Assert.IsFalse(newMenu.DoesItemExistsByID(removableId));
        }
        // GET: RestaurantMenu/Edit/5
        public ActionResult Edit(string id, string ownerType = null, string ownerId = null)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            RestaurantMenu restaurantMenu = db.RestaurantMenu.Find(int.Parse(DataSecurityTripleDES.GetPlainText(id)));

            if (restaurantMenu == null)
            {
                return(HttpNotFound());
            }
            return(View(restaurantMenu));
        }
        // GET: RestaurantMenus/Delete/5
        public async Task <ActionResult> Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            RestaurantMenu restaurantMenu = await db.RestaurantMenus.FindAsync(id);

            if (restaurantMenu == null)
            {
                return(HttpNotFound());
            }
            return(View(restaurantMenu));
        }
Esempio n. 22
0
        internal static bool AddOrUpdateRestaurantMenu(RestaurantMenu menu)
        {
            var restaurant = GetRestaurantById(menu.RestaurantId);

            if (restaurant != null)
            {
                restaurant.Menu = menu.Menu;
                return(restaurantCollection.UpdateOne(menu.RestaurantId, restaurant));
            }
            else
            {
                return(false);
            }
        }
Esempio n. 23
0
        public Category SelectCategoryFromMenu(RestaurantMenu menu)
        {
            if (menu.menus.Count == 0)
            {
                Console.WriteLine("There are currently no categorie in this menu.");
                Console.WriteLine("\nPress any key to continue");
                Console.ReadKey();
                return(null);
            }
            ShowMenuWithCategoryNumbers(menu);
            Console.WriteLine("\nChoose your category.");
            int selection = int.Parse(Console.ReadLine());

            return(menu.menus[selection - 1]);
        }
Esempio n. 24
0
        public List <RestaurantMenu> GetListMenubyTable(int id)
        {
            List <RestaurantMenu> listMenu = new List <RestaurantMenu>();
            //Import data from database.
            string    query = "USerProc_GetMenu @IDTable";
            DataTable data  = DataProvider.Instance.ExecuteQuery(query, new object[] { id });

            //Add to list.
            foreach (DataRow item in data.Rows)
            {
                RestaurantMenu menu = new RestaurantMenu(item);
                listMenu.Add(menu);
            }
            return(listMenu);
        }
Esempio n. 25
0
        public IActionResult AddMenu(int id)
        {
            var restaurant = _Repository.GetRestaurant(id).Result;

            if (restaurant != null)
            {
                var NewMenu = new RestaurantMenu
                {
                    RestaurantId   = restaurant.Id,
                    RestaurantName = restaurant.Name
                };
                return(View(NewMenu));
            }

            return(View("Not Found"));
        }
        public void ProcessOrder_Test_4()
        {
            string        options    = "morning, 1, 2, 3, 3, 3";
            string        result     = "";
            string        Exp_result = "Eggs,Toast,Coffee(x3)";
            List <Period> lstPeriod  = new List <Period>();
            List <Dish>   lstDish    = new List <Dish>();

            lstPeriod = Period.setPeriods();
            lstDish   = Dish.setDish();

            IEnumerable <RestaurantMenu.OptionsSelected> distinctOptions = RestaurantMenu.ProcessOrder(Regex.Replace(options, @"\s", "").ToUpper(), lstPeriod, lstDish);

            result = RestaurantMenu.ResumeOrder(distinctOptions);

            Assert.AreEqual(Exp_result, result);
        }
        public void ProcessOrder_Test_5()
        {
            string        options    = "night, 1, 2, 3, 4";
            string        result     = "";
            string        Exp_result = "Steak,Potato,Wine,Cake";
            List <Period> lstPeriod  = new List <Period>();
            List <Dish>   lstDish    = new List <Dish>();

            lstPeriod = Period.setPeriods();
            lstDish   = Dish.setDish();

            IEnumerable <RestaurantMenu.OptionsSelected> distinctOptions = RestaurantMenu.ProcessOrder(Regex.Replace(options, @"\s", "").ToUpper(), lstPeriod, lstDish);

            result = RestaurantMenu.ResumeOrder(distinctOptions);

            Assert.AreEqual(Exp_result, result);
        }
Esempio n. 28
0
        //=============================================================//

        public ActionResult CateRecord()
        {
            BindListCate();

            var menus = new Menus()
            {
                Menu = new List <RestaurantMenu>()
            };
            var menu = new RestaurantMenu()
            {
                Name = "",
                Type = "", Unit = "", Remark = ""
            };

            menus.Menu.Add(menu);
            return(View(menus));
        }
        public void AddNewMenuItem()
        {
            /// Read elements from list
            InitializeReadingTest();
            /// Addable elements
            MenuItem addableMenuItem = new MenuItem(4, "Grilled Chicken Wings with fries",
                                                    new List <int> {
                6, 1, 3
            });

            /// Check if items are added in array
            Program.AddElement(menu, addableMenuItem, TestMenuCsv);
            Assert.AreEqual(4, menu.GetElementCount());
            /// Check if items are stored in csv file
            RestaurantMenu newMenu = fileInterface.ReadMenuFile(TestMenuCsv);

            Assert.AreEqual(4, newMenu.GetElementCount());
        }
        public ActionResult Create([Bind(Include = "Name, Brief, Detail, UnitPrice")] RestaurantMenu restaurantMenu, string ownerType = null, string ownerId = null)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    //int.Parse(DataSecurityTripleDES.GetPlainText(SessionManager.GetContextSessionLoggedUserID()));
                    db.RestaurantMenu.Add(restaurantMenu);
                    db.SaveChanges();

                    restaurantMenu.DateAdded = DateTime.Now;
                    db.SaveChanges();

                    restaurantMenu.ServiceStatus = (int?)Common.ServiceStatusEnum.Active;
                    restaurantMenu.OwnerId       = int.Parse(
                        DataSecurityTripleDES.GetPlainText(
                            ownerId));
                    restaurantMenu.OwnerType   = (int)Common.OwnerTypeEnum.ServiceProvider;
                    restaurantMenu.IsTaxable   = true;
                    restaurantMenu.TaxRate     = 13m;
                    restaurantMenu.LastUpdated = DateTime.Now;
                    db.SaveChanges();

                    Restaurant ownerRestaurant = db.Restaurant.FirstOrDefault(u => u.Id == restaurantMenu.OwnerId &&
                                                                              (u.ServiceProviderStatus.HasValue &&
                                                                               u.ServiceProviderStatus.Value == (int)Common.ServiceProviderStatusEnum.Inactive) &&
                                                                              u.AddressId.HasValue);
                    if (ownerRestaurant != null)
                    {
                        ownerRestaurant.ServiceProviderStatus = (int)Common.ServiceProviderStatusEnum.Active;
                        db.SaveChanges();
                    }

                    return(RedirectToAction("Index", new { ownerType = ownerType, ownerId = ownerId }));
                }
            }
            catch (RetryLimitExceededException /* dex */)
            {
                //Log the error (uncomment dex variable name and add a line here to write a log.
                ModelState.AddModelError("", "Unable to save changes. Try again, and if the problem persists see your system administrator.");
            }
            return(View(restaurantMenu));
        }
        public ActionResult EditPost([Bind(Include = "Name, Brief, Detail, UnitPrice")] RestaurantMenu restaurantMenu,
                                     string id        = null,
                                     string ownerId   = null,
                                     string ownerType = null)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            if (restaurantMenu == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            if ((restaurantMenu.Brief ?? string.Empty) == string.Empty ||
                (restaurantMenu.Name ?? string.Empty) == string.Empty ||
                (restaurantMenu.Detail ?? string.Empty) == string.Empty ||
                (restaurantMenu.UnitPrice ?? 0) <= 0)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            var RestaurantMenuToUpdate = db.RestaurantMenu.Find(int.Parse(DataSecurityTripleDES.GetPlainText(id)));

            try
            {
                RestaurantMenuToUpdate.UnitPrice = restaurantMenu.UnitPrice;
                RestaurantMenuToUpdate.Name      = restaurantMenu.Name;
                RestaurantMenuToUpdate.Detail    = restaurantMenu.Detail;
                RestaurantMenuToUpdate.Brief     = restaurantMenu.Brief;

                db.SaveChanges();

                return(RedirectToAction("Index", new { ownerType = ownerType, ownerId = ownerId }));
            }
            catch (RetryLimitExceededException /* dex */)
            {
                //Log the error (uncomment dex variable name and add a line here to write a log.
                ModelState.AddModelError("", "Unable to save changes. Try again, and if the problem persists, see your system administrator.");
            }

            return(View(RestaurantMenuToUpdate));
        }