public ActionResult AddFoods(int ItemCode) { try { Food_Items item = db.Food_Items.FirstOrDefault(i => i.Item_Code == ItemCode); OrderItemViewModel cvm = new OrderItemViewModel(); cvm.Item = item; cvm.Qty = 1; cvm.SubTotal = (item.Portion_Price ?? 0 * 1); if (Session["FoodItems"] == null) { Session["FoodItems"] = new List <OrderItemViewModel>(); } ((List <OrderItemViewModel>)Session["FoodItems"]).Add(cvm); //if (Session["Total"] == null) // Session["Total"] = cvm.SubTotal; //else // Session["Total"] = ((int)Session["Total"]) + cvm.SubTotal; //ViewBag.Total = Session["Total"]; return(RedirectToAction("OrderIndex")); } catch (Exception ex) { return(View()); } }
public async Task <ActionResult <Food_Items> > PostFood_Items(Food_Items food_Items) { _context.Food_Items.Add(food_Items); await _context.SaveChangesAsync(); return(CreatedAtAction("GetFood_Items", new { id = food_Items.Id }, food_Items)); }
public IHttpActionResult getFoodItemByName(getFoodItemByCategoryObj obj) { try { if (obj.name == null) { throw new Exception("name not set"); } Food_Items result = foodItemObj.getItemByName(obj.name); if (result == null) { return(Content(HttpStatusCode.NoContent, "No content found under this name")); } resObj.Status = HttpStatusCode.OK; resObj.Data = result; resObj.Message = "Content found"; return(Ok(resObj)); } catch (Exception e) { return(Content(HttpStatusCode.BadRequest, "Some error has occured. Error message : " + e.Message)); } }
public async Task <IActionResult> PutFood_Items(int id, Food_Items food_Items) { if (id != food_Items.Id) { return(BadRequest()); } _context.Entry(food_Items).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!Food_ItemsExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
protected void btnInsert_Click(object sender, EventArgs e) { int Id = Convert.ToInt32(txtId.Text); string Food_name = txtName.Text; string Ingrediants = txtIngrediants.Text; string SplNotes = txtSplNotes.Text; string Catagory = txtCatageory.Text; int Price = Convert.ToInt32(txtPrice.Text); Food_Items foods = new Food_Items() { id = Id, Food_Name = Food_name, Ingrediants = Ingrediants, Special_Notes = SplNotes, Catageory = Catagory, Price = Price }; KitchenProjectEntities db = new KitchenProjectEntities(); db.Food_Items.Add(foods); db.SaveChanges(); List <Food_Items> users = db.Food_Items.ToList(); grdFoodItem.DataSource = users; grdFoodItem.DataBind(); }
public async Task <ActionResult> DeleteConfirmed(int id) { Food_Items food_Items = await db.Food_Items.FindAsync(id); db.Food_Items.Remove(food_Items); await db.SaveChangesAsync(); return(RedirectToAction("Index")); }
public async Task <ActionResult> Edit([Bind(Include = "Id,Item_Category_ID,Item_Name,Item_Code,Description,Portion_Price,Image_URL")] Food_Items food_Items) { if (ModelState.IsValid) { db.Entry(food_Items).State = EntityState.Modified; await db.SaveChangesAsync(); return(RedirectToAction("Index")); } ViewBag.Item_Category_ID = new SelectList(db.Food_Categories, "Food_category_Id", "Category", food_Items.Item_Category_ID); return(View(food_Items)); }
// GET: Admin/Food_Items/Details/5 public async Task <ActionResult> Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Food_Items food_Items = await db.Food_Items.FindAsync(id); if (food_Items == null) { return(HttpNotFound()); } return(View(food_Items)); }
// GET: Admin/Food_Items/Edit/5 public async Task <ActionResult> Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Food_Items food_Items = await db.Food_Items.FindAsync(id); if (food_Items == null) { return(HttpNotFound()); } ViewBag.Item_Category_ID = new SelectList(db.Food_Categories, "Food_category_Id", "Category", food_Items.Item_Category_ID); return(View(food_Items)); }
public void insert(Food_Items foodItem) { db.foodItems.Add(foodItem); save(); }