public void CreateFoodMenuIterator_WithValidInput_ReturnsNotNullableVAlue() { FoodMenu foodMenu = new FoodMenu("1"); var foodMenuIterator = foodMenu.CreateFoodMenuIterator(); Assert.IsNotNull(foodMenuIterator); }
public async Task <IActionResult> Products() { ShoppingCart cart; if (HttpContext.Session.GetString("varukorg") == null) { cart = new ShoppingCart { Products = new List <Matratt>() }; } else { var serializedValue = (HttpContext.Session.GetString("varukorg")); cart = JsonConvert.DeserializeObject <ShoppingCart>(serializedValue); } var allDishes = await _dishService.GetAllDishesAsync(); var model = new FoodMenu { PizzaDishes = allDishes.Where(d => d.MatrattTyp == 1), PastaDishes = allDishes.Where(d => d.MatrattTyp == 2), SaladDishes = allDishes.Where(d => d.MatrattTyp == 3), ShoppingCart = cart }; return(View(model)); }
public void CreateFoodMenuIterator_WithValidInput_ReturnsExpectedObject() { FoodMenu foodMenu = new FoodMenu("1"); var foodMenuIterator = foodMenu.CreateFoodMenuIterator(); Assert.IsInstanceOf(typeof(RestaurantFoodMenuIterator), foodMenuIterator); }
private void ValidItem(FoodMenu foodMenu) { foreach (var i in foodMenu.FoodItemsId) { foodMenu.FoodItems.Add(_context.FoodItems.SingleOrDefault(f => f.Id == i)); } }
public async Task Delete(int menuId) { FoodMenu menu = await _db.FoodMenu.FindAsync(menuId); _db.Entry(menu).State = EntityState.Deleted; await _db.SaveChangesAsync(); }
// Constructor for AllergensViewModel public AllergensViewModel(MenuManager menuManager, FoodMenu menu, Dish dish) { this.SelectedDish = dish; this.SelectedMenu = menu; this.SelectedMenuManager = menuManager; this.AllergenBoolCombinations = new BindableCollection <AllergenBoolCombination>(DataHandler.CombineAllergenAndBool(SelectedMenuManager, SelectedDish.Allergens)); }
public int AddFoodMenu(FoodMenuDto food) { if (food.Id > 0) { var model = _dataContext.FoodMenus.FirstOrDefault(x => x.Id == food.Id); if (model == null) { return(0); } model.ImgUrl = food.ImgUrl; model.Name = food.Name; model.Description = food.Description; model.Type = food.Type; model.Price = food.Price; model.StockCount = food.StockCount; } else { var foodModel = new FoodMenu() { Name = food.Name, Description = food.Description, Type = food.Type, ImgUrl = food.ImgUrl, Price = food.Price, StockCount = food.StockCount, CreateTime = DateTime.Now }; _dataContext.FoodMenus.Add(foodModel); } return(_dataContext.SaveChanges()); }
public PickItemsWindow(OrderDetails orderDetails, ObservableCollection <MenuCategory> menuCategories) { this.orderDetails = orderDetails; menu = new FoodMenu(menuCategories); InitializeComponent(); MainGrid.Children.Add(menu.Grid); }
public async Task <IActionResult> Edit(int id, [Bind("Id,Starter,Main,Dessert,Cost")] FoodMenu foodMenu) { if (id != foodMenu.Id) { return(NotFound()); } if (ModelState.IsValid) { try { HttpClient client = getClient("32824"); HttpResponseMessage response = await client.PutAsJsonAsync("api/foodmenus/" + id, foodMenu); } catch (DbUpdateConcurrencyException) { if (!FoodMenuExists(foodMenu.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(foodMenu)); }
public void CreatesFoodMenu() { FoodMenu foodMenu = new FoodMenu(); foodMenu.AddMenuItem("Fries", "Potatoe chips", 5.0); Assert.AreEqual("Fries", foodMenu.items[0].Title); }
public override void btnSave_Click(object sender, EventArgs e) { try { if (Main.CheckControls(leftpanel).Count == 0) { short Status = cmbStatus.SelectedItem.ToString() == "Available" ? Convert.ToInt16(1) : Convert.ToInt16(0); if (base.edit == 0)//save { FoodMenu.FoodMenuInsert(txtMenuItem.Text, Convert.ToSingle(txtPrice.Text), Convert.ToInt32(cmbCategories.SelectedValue), Status, pbItem.Image); Main.resetDisable(leftpanel); FoodMenu.FoodMenuSelectAll(grvFoodMenu, MenuIDGV, MenuItemGV, PriceGV, StatusGV, CategoryIDGV, CategoryGV, ImageGV); } else if (edit == 1)//update { FoodMenu.FoodMenuUpdate(_menuID, txtMenuItem.Text, Convert.ToSingle(txtPrice.Text), Convert.ToInt32(cmbCategories.SelectedValue), Status, pbItem.Image); Main.resetDisable(leftpanel); FoodMenu.FoodMenuSelectAll(grvFoodMenu, MenuIDGV, MenuItemGV, PriceGV, StatusGV, CategoryIDGV, CategoryGV, ImageGV); } } } catch (Exception ex) { Main.showMessage(ex.Message, "error"); } }
private void dataGridFoodMenus_SelectionChanged(object sender, EventArgs e) { if (dataGridFoodMenus.RowCount > 0) { try { //keeps track of what row is selected for editing their record int selectedMenuId = Convert.ToInt32(dataGridFoodMenus.CurrentRow.Cells[0].Value); FoodMenu selectedMenu = FoodMenu.RetrieveById(selectedMenuId); txtMenuId.Text = selectedMenu.ID.ToString(); txtMenuMeat.Text = selectedMenu.Meat; txtMenuVeg1.Text = selectedMenu.Vegetable_1; txtMenuVeg2.Text = selectedMenu.Vegetable_2; txtMenuDrink.Text = selectedMenu.Drink; txtMenuPrice.Text = selectedMenu.Price.ToString(); } catch { //should never happen Console.WriteLine("ERROR: Cannot convert current row[0] to int32"); } } }
private void btnAddMenu_Click(object sender, EventArgs e) { string validInputRegex = @"^\£?([0-9]{1,3},([0-9]{3},)*[0-9]{3}|[0-9]+)(.[0-9][0-9])?$"; Match match = Regex.Match(txtNMenuPrice.Text, validInputRegex, RegexOptions.IgnoreCase); if (!match.Success) { MessageBox.Show("Incorrect price format!", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (Meat != null & Veg1 != null && Veg2 != null && Drink != null) { if (FoodMenu.Add(Meat, Veg1, Veg2, Drink, Convert.ToDecimal(txtNMenuPrice.Text))) { MessageBox.Show("Menu Added!", "SUCCESS", MessageBoxButtons.OK); LoadFoodMenus(); } else { MessageBox.Show("Failed to add Menu!", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { MessageBox.Show("Please select one of each item!", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } }
public override void Awake() { base.Awake(); _foodMenu = GetComponent <FoodMenu>(); foodSpaces = transform.GetComponentsInChildren <ItemLocation>(); door = GameObject.Find("Door").GetComponent <Door>(); }
public async Task <string> SaveTitle(int menuId, [FromBody][Required] string title) { FoodMenu menu = await _db.FoodMenu.FindAsync(menuId); menu.Title = title; await _db.SaveChangesAsync(); return(title); }
public async Task <decimal> SavePrice(int menuId, [Required] decimal price) { FoodMenu menu = await _db.FoodMenu.FindAsync(menuId); menu.Price = price; await _db.SaveChangesAsync(); return(price); }
public async Task <string> SaveContent(int menuId, [FromBody][Required] string content) { FoodMenu menu = await _db.FoodMenu.FindAsync(menuId); menu.Details = content; await _db.SaveChangesAsync(); return(content); }
public async Task <bool> ToggleStatus(int menuId) { FoodMenu menu = _db.FoodMenu.Find(menuId); menu.Enabled = !menu.Enabled; await _db.SaveChangesAsync(); return(menu.Enabled); }
public void is_totals_for_0_items_correct() { IFoodMenu menu = new FoodMenu(); List <IItem> items = new List <IItem>(); IBill bill = new Bill(); Assert.IsTrue(bill.Total(items) == 0m); }
public async Task <int> Create([FromBody] MenuCreateDto menuCreateDto) { FoodMenu foodMenu = menuCreateDto.ToFoodMenu(); _db.Entry(foodMenu).State = EntityState.Added; await _db.SaveChangesAsync(); return(foodMenu.Id); }
public ActionResult AddToCart(int id) { FoodMenu _foodmenu = db.FoodMenus.Find(id); Response.Cookies["FoodItem"].Value = _foodmenu.FoodItem; Response.Cookies["Price"].Value = _foodmenu.Price.ToString(); return(RedirectToAction("GetMenuData")); }
public void Constructing_a_menu_with_items() { IFoodMenu menu = new FoodMenu(); Assert.IsInstanceOf <Item>(menu.GetItem(Item.COKE)); Assert.IsInstanceOf <Item>(menu.GetItem(Item.COFFEE)); Assert.IsInstanceOf <Item>(menu.GetItem(Item.CHEESE_SANDWICH)); Assert.IsInstanceOf <Item>(menu.GetItem(Item.STEAK_SANDWICH)); }
public async Task <ActionResult> Create(FoodMenuViewModel model) { if (!ModelState.IsValid) { return(View(model)); } var existed = await _db.FoodMenus.AnyAsync(x => x.MenuName == model.MenuName); if (existed) { ModelState.AddModelError("", "Tên thực đơn đã tồn tại hãy cung cấp tên khác"); return(View(model)); } var foodIdList = (List <string>)Session["FoodIdList"]; if (foodIdList == null || !foodIdList.Any()) { ModelState.AddModelError("", "Chưa thêm món ăn vào thực đơn"); return(View(model)); } model.FoodIdList = string.Join(";", foodIdList.ToArray()); var menu = new FoodMenu { Id = Guid.NewGuid(), MenuName = model.MenuName, Price = model.Price, FoodIdList = model.FoodIdList, Activated = model.Activated, CreateTime = DateTime.Now }; if (!Directory.Exists(Server.MapPath(Path))) { Directory.CreateDirectory(Server.MapPath(Path)); } var avatar = Request.Files["Avatar"]; if (avatar != null && avatar.ContentLength > 0) { if (avatar.ContentLength > 2048000) { ModelState.AddModelError("", "Hình ảnh có dung lượng không quá 2Mb"); return(View(model)); } var fileInfo = new FileInfo(avatar.FileName); var fileExt = fileInfo.Extension; var newFileName = $"{menu.Id}{fileExt}"; avatar.SaveAs($"{Server.MapPath(Path)}/{newFileName}"); menu.Avatar = newFileName; } _db.FoodMenus.Add(menu); await _db.SaveChangesAsync(); Session["FoodIdList"] = null; return(RedirectToAction("index")); }