public async Task <IActionResult> Edit(int id, [Bind("OrderId,GuestId,FoodId,Quntity")] OrderFood orderFood) { if (id != orderFood.OrderId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(orderFood); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!OrderFoodExists(orderFood.OrderId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["FoodId"] = new SelectList(_context.Food, "FoodId", "FoodName", orderFood.FoodId); ViewData["GuestId"] = new SelectList(_context.Guest, "GuestId", "FullName", orderFood.GuestId); return(View(orderFood)); }
private void Button_Click(object sender, EventArgs e) { float totalPrice = 0; this.listView_Order_Info.Items.Clear(); OrderFood orderFood = (sender as Button).Tag as OrderFood; int idOrder = orderFood.ID; DataTable data = OrderFoodInfoDAO.Instance.GetOrderFoodInfoByID(idOrder); foreach (DataRow item in data.Rows) { ListViewItem viewItem = new ListViewItem(item["id"].ToString()); viewItem.SubItems.Add(item["UserName"].ToString()); viewItem.SubItems.Add(item["DateOrder"].ToString()); viewItem.SubItems.Add(item["name"].ToString()); viewItem.SubItems.Add(item["amount"].ToString()); viewItem.SubItems.Add(item["price"].ToString()); viewItem.SubItems.Add(item["Thành tiền"].ToString()); totalPrice = float.Parse(item["Thành tiền"].ToString()); this.textBox_User_Mess.Text = item["userMess"].ToString(); this.listView_Order_Info.Items.Add(viewItem); } CultureInfo culture = new CultureInfo("vi-VN"); //Thread.CurrentThread.CurrentCulture = culture; this.textBox_Total_Price.Text = totalPrice.ToString("c", culture); }
private void buttonAddFood_Click(object sender, EventArgs e) { if (listViewMenu.SelectedItems.Count == 0) { return; } var menuItem = (Food)listViewMenu.SelectedItems[0].Tag; var orderFood = new OrderFood { Name = menuItem.Name, Amount = (int)foodAmount.Value, Price = menuItem.Price }; _orderFood.Add(orderFood); var row = new[] { menuItem.Name, foodAmount.Text }; listViewOrder.Items.Add(new ListViewItem(row) { Tag = orderFood }); _totalPrice += menuItem.Price; totalPriceText.Text = _totalPrice + " zl"; listViewOrder.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent); listViewOrder.AutoResizeColumns(ColumnHeaderAutoResizeStyle.HeaderSize); }
private void btnDeleteOrderFood_Click(object sender, RoutedEventArgs e) { Button btnDeleteOrderFood = (Button)sender; OrderFood orderFood = (OrderFood)btnDeleteOrderFood.DataContext; orderFoodViewModel.RemoveOrderFood(orderFood); }
public char MealOrderByUser(List <FoodMenuModel> selectedMealItems, double totalCost, string RestaurantID, out string OrderID, out UserModel user) { Console.WriteLine(string.Empty); Console.WriteLine("Do you want to place your order(y/n)...?"); var wantsOrder = Console.ReadKey().KeyChar; Console.WriteLine(string.Empty); OrderID = string.Empty; user = new UserModel(); if (wantsOrder == 'y') { Console.WriteLine("_________________________"); Food food = new Food(); OrderFood orderFood = new OrderFood(food); orderFood.FoodItems = selectedMealItems; orderFood.User = user.GetUser(); orderFood.User.Amount = totalCost; orderFood.RestaurantID = RestaurantID; user = orderFood.User; Customer customer = new Customer(); customer.TakeOrder(orderFood); customer.PlaceOrders(); OrderID = orderFood.OrderID; Console.WriteLine(string.Empty); } else { if (wantsOrder == 'n') { Console.WriteLine("Order declined."); } throw new Exception("Something is wrong!!!"); } //Order Cancellation. char cancel = 'n'; if (!string.IsNullOrEmpty(OrderID)) { Console.WriteLine("Do you want to cancel your order(y/n)...?"); cancel = Console.ReadKey().KeyChar; Console.WriteLine(string.Empty); if (cancel == 'y') { Console.WriteLine(String.Empty); Food food = new Food(); CancelFood cancelOrder = new CancelFood(food); cancelOrder.OrderID = OrderID; Customer customer = new Customer(); customer.TakeOrder(cancelOrder); customer.PlaceOrders(); } } return(cancel); }
/// <summary> /// This driver called Command Design Pattern /// </summary> /// <param name="selectedMealItems"></param> /// <param name="totalCost"></param> /// <param name="restaurantId"></param> /// <param name="orderId"></param> /// <param name="user"></param> /// <returns></returns> public char MealOrderByUser(List <FoodMenuModel> selectedMealItems, double totalCost, string restaurantId, out string orderId, out UserModel user) { Console.WriteLine(string.Empty); Console.WriteLine("Do you want to place order(y/n)...?"); var wantsOrder = Console.ReadKey().KeyChar; Console.WriteLine(string.Empty); orderId = string.Empty; user = null; if (wantsOrder == 'y') { Console.WriteLine("_________________________"); Food food = new Food(); OrderFood orderFood = new OrderFood(food); orderFood.FoodItems = selectedMealItems; orderFood.User = new UserModel(); orderFood.User.UserId = "gul123"; orderFood.User.UserName = "******"; orderFood.User.Address = "JP Nangar, Bangalore - 5600076"; orderFood.User.PhoneNumber = "99998987"; orderFood.User.Amount = totalCost; orderFood.RestaurantId = restaurantId; user = orderFood.User; Customer customer = new Customer(); customer.TakeOrder(orderFood); customer.PlaceOrders(); orderId = orderFood.OrderId; Console.WriteLine(string.Empty); } //Order Cancellation. char cancel = 'n'; if (!string.IsNullOrEmpty(orderId)) { Console.WriteLine("Do you want to cancel order(y/n)...?"); cancel = Console.ReadKey().KeyChar; Console.WriteLine(string.Empty); if (cancel == 'y') { Console.WriteLine(String.Empty); Food food = new Food(); CancelFood cancelOrder = new CancelFood(food); cancelOrder.OrderId = orderId; Customer customer = new Customer(); customer.TakeOrder(cancelOrder); customer.PlaceOrders(); } } return(cancel); }
/// <summary> /// This driver called Command Design Pattern /// </summary> /// <param name="selectedMealItems"></param> /// <param name="totalCost"></param> /// <param name="restaurantId"></param> /// <param name="orderId"></param> /// <param name="user"></param> /// <returns></returns> public char MealOrderByUser(List <FoodMenuModel> selectedMealItems, double totalCost, string restaurantId, out string orderId, out UserModel user) { Console.WriteLine(string.Empty); Console.WriteLine("Do you want to place order(y/n)...?"); var wantsOrder = Console.ReadKey().KeyChar; Console.WriteLine(string.Empty); orderId = string.Empty; user = null; if (wantsOrder == 'y') { Console.WriteLine("_________________________"); Food food = new Food(); OrderFood orderFood = new OrderFood(food); orderFood.FoodItems = selectedMealItems; orderFood.User = new UserModel(); orderFood.User.UserId = "18110013"; orderFood.User.UserName = "******"; orderFood.User.Address = "10/9, phuong Binh Tho, Thanh Pho Thu Duc"; orderFood.User.PhoneNumber = "0975770921"; //orderFood.User.Amount = totalCost; orderFood.RestaurantId = restaurantId; user = orderFood.User; Customer customer = new Customer(); customer.TakeOrder(orderFood); customer.PlaceOrders(); orderId = orderFood.OrderId; Console.WriteLine(string.Empty); } //Order Cancellation. char cancel = 'n'; if (!string.IsNullOrEmpty(orderId)) { Console.WriteLine("Do you want to cancel order(y/n)...?"); cancel = Console.ReadKey().KeyChar; Console.WriteLine(string.Empty); if (cancel == 'y') { Console.WriteLine(String.Empty); Food food = new Food(); CancelFood cancelOrder = new CancelFood(food); cancelOrder.OrderId = orderId; Customer customer = new Customer(); customer.TakeOrder(cancelOrder); customer.PlaceOrders(); } } return(cancel); }
public async Task AddOrderFoodAsync(OrderFood orderFood) { string jsonOrderFood = JsonSerializer.Serialize(orderFood); Console.WriteLine(jsonOrderFood); HttpResponseMessage response = await _client.PostAsync("http://*****:*****@"Error:{responseMessage.StatusCode},{responseMessage.ReasonPhrase}"); } }
//Json Result GetFoodById public JsonResult GetFoodById(int?id) { OrderFood aOrderFood1 = new OrderFood(); FoodItem aFoodItem = null; if (id != null) { aFoodItem = db.FoodItems.FirstOrDefault(c => c.Id == id); aOrderFood1.UnitPrice = aFoodItem.UnitPrice; } return(Json(aOrderFood1, JsonRequestBehavior.AllowGet)); }
public ActionResult Order(OrderFood aOrder) { if (ModelState.IsValid) { db.OrderFoods.Add(aOrder); db.SaveChanges(); ViewBag.Message = "Successfully Added."; return(RedirectToAction("Index", "Entry")); } aOrder = null; return(View()); }
public async Task <IActionResult> Create([Bind("OrderId,GuestId,FoodId,Quntity")] OrderFood orderFood) { if (ModelState.IsValid) { _context.Add(orderFood); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["FoodId"] = new SelectList(_context.Food, "FoodId", "FoodName", orderFood.FoodId); ViewData["GuestId"] = new SelectList(_context.Guest, "GuestId", "FullName", orderFood.GuestId); return(View(orderFood)); }
/// <summary> /// A megadott adatok alapján a rendelés létrehozása. /// A rendelés létrehozása során ellenőrizzük, hogy tartalmaz-e egyátalán tételeket a rendelés, /// és, hogy a tételben szereplő ételek léteznek-e, mert ha nem akkor ezt kivételben jelezzük. /// Ha pedig minden rendben ment létrehozzuk a rendeléshez tartozó számlát és visszatérünk a /// reészletes adatokkal. /// </summary> /// <param name="userId">A felhasználó azonosítója.</param> /// <param name="order">A rendelés adatait tartalmazó objektum.</param> /// <returns>A rendelés részletes adatai.</returns> public async Task <OrderDetailsDto> CreateOrder(string userId, CreateOrderDto order) { if (!order.OrderFoods.Any()) { throw new EntityNotFoundException("A rendelésben egyetlen tétel sem szerepel."); } var dbOrder = new Order { CreatedAt = DateTime.Now, PreferredDeliveryDate = order.PreferredDeliveryDate, Status = OrderStatus.PROCESSING, UserId = userId }; using (var transaction = new TransactionScope(TransactionScopeOption.Required, new TransactionOptions() { IsolationLevel = IsolationLevel.RepeatableRead }, TransactionScopeAsyncFlowOption.Enabled)) { await dbContext.Orders.AddAsync(dbOrder); foreach (var orderFood in order.OrderFoods) { var dbFood = (await dbContext.Foods .SingleOrDefaultAsync(f => f.Id == orderFood.FoodId && f.RestaurantId == order.RestaurantId)) .CheckIfFoodNull("A rendelésben szereplő étteremhez a megadott ételek közül egy vagy több nem található."); var newOrderFood = new OrderFood { Amount = orderFood.Amount, Price = dbFood.Price, Order = dbOrder, Food = dbFood, }; await dbContext.OrderFoods.AddAsync(newOrderFood); } await dbContext.SaveChangesAsync(); await invoiceRepository.CreateInvoice(dbOrder.Id, order.RestaurantId, order.AddressId); transaction.Complete(); } return(await dbContext.Entry(dbOrder).ToOrderDetailsDto()); }
//Billing Information and other details about date and time public ActionResult CheckOut() { try { ViewBag.listProduct = db.FoodItems.ToList(); Order order = new Order(); order.Order_Date = DateTime.Now; order.Status = "Not-Deliver"; order.Bill = 1000; List <Cart> cart = (List <Cart>)Session["cart"]; order.Items = cart.ToArray().Length; db.Orders.Add(order); db.SaveChanges(); int r = order.OrderID; for (int j = 0; j < cart.Count; j++) { FoodItem F = db.FoodItems.Find(cart[j].NewFood1.FoodID); OrderFood orderProduct = new OrderFood(); orderProduct.OrderID = r; orderProduct.ProductName = F.Name; orderProduct.Quantity = cart[j].Quantity; orderProduct.Price = F.Price; orderProduct.Category = F.Category; db.OrderFoods.Add(orderProduct); db.SaveChanges(); } Session["cart"] = null; return(View()); } catch (System.Data.Entity.Validation.DbEntityValidationException dbEx) { Exception raise = dbEx; foreach (var validationErrors in dbEx.EntityValidationErrors) { foreach (var validationError in validationErrors.ValidationErrors) { string message = string.Format("{0}:{1}", validationErrors.Entry.Entity.ToString(), validationError.ErrorMessage); raise = new InvalidOperationException(message, raise); } } throw raise; } }
//JSON Calling GetUserById public JsonResult GetUserById(int?id) { OrderFood aOrderFood = new OrderFood(); User aUser = null; if (id != null) { aUser = db.Users.FirstOrDefault(c => c.Id == id); MemberType userType = null; userType = db.MemberTypes.FirstOrDefault(c => c.Id == aUser.MemberTypeId); aOrderFood.Name = aUser.Name; aOrderFood.Email = aUser.Email; aOrderFood.ContactNo = aUser.ContactNo; aOrderFood.Type = userType.TypeName; } return(Json(aOrderFood, JsonRequestBehavior.AllowGet)); }
public async Task <ActionResult> ConfirmReserveAddMeal(FormCollection collection) { try { OrderFood LOF = new OrderFood(); string Id = Request.Form["Id"]; string value = Request.Form["value"]; TempData.Add("Food" + Id, "" + Id); TempData.Add("Value" + Id, "" + Id); //RestaurantDataManagerCreator factory = new DefaultDataManagerCreator(); //IDataManager manager = factory.GetRestaurantDataManager(); //LOF = manager.GetOrderFood(Convert.ToInt32(Id), Convert.ToInt32(value)); return(PartialView(LOF)); } catch { return(PartialView(new List <OrderFood>())); } }
public ActionResult DetailsOrder(int Id) { List <OrderFood> list = new List <OrderFood>(); foreach (OrderFood p in db.OrderFoods) { if (p.OrderID == Id) { OrderFood p1 = new OrderFood(); p1.OrderID = p.OrderID; p1.ProductID = p.ProductID; p1.ProductName = p.ProductName; p1.Price = p.Price; p1.Quantity = p.Quantity; list.Add(p1); } } ViewBag.ListProduct = list; return(View()); }
//Thêm món ăn vào thực đơn public ActionResult AddMenu(long foodId, int quantity) { var food = new FoodSVClient().FindID(foodId); var or = Session[BookFoodSesstion]; if (or != null) { var list = (List <OrderFood>)or; if (list.Exists(x => x.food.ID == foodId)) { foreach (var item in list) { if (item.food.ID == foodId) { item.quantity += quantity; } } } else { var item = new OrderFood(); item.food = food; item.quantity = quantity; list.Add(item); } } else { var item = new OrderFood(); var list = new List <OrderFood>(); item.food = food; item.quantity = quantity; list.Add(item); Session[BookFoodSesstion] = list; } return(RedirectToAction("Index")); }
public IActionResult CreateOrder([FromBody] Order order) { Order _order = new Order() { Timestamp = order.Timestamp, FirstName = order.FirstName, LastName = order.LastName, City = order.City, Street = order.Street, PhoneNumber = order.PhoneNumber, PaymentType = order.PaymentType, OrderSum = order.OrderSum, RestaurantId = order.RestaurantId, UserId = order.UserId, DeliveryTime = order.DeliveryTime }; _order.OrderFoods = new List <OrderFood>(); List <Food> foods = GetFoodListFromFc(order.RestaurantId, order.FoodIds); foreach (var food in foods) { OrderFood of = new OrderFood() { FoodId = food.Id, OrderId = _order.Id, Order = _order, Food = food, UserId = _order.UserId }; _order.OrderFoods.Add(of); } _db.Orders.Add(_order); _db.SaveChanges(); return(Ok()); }
Task BuildTask() { List <Task> taskList = new List <Task>(); Task isOutOfFood = new IsTrue(OutOfFood); Task machineBroken = new IsTrue(MachineBroken); Task walkToCounter = new MoveKinematicToObject(this.GetComponent <Kinematic>(), stopPoint.gameObject, text); Task walkFromCounter = new MoveKinematicToObject(this.GetComponent <Kinematic>(), startPoint.gameObject, text); Task walkFromCounterMid = new MoveKinematicToObject(this.GetComponent <Kinematic>(), midPoint.gameObject, text); Task wait = new Wait(1.5f); Task orderFood = new OrderFood(text); Task giveFood = new GiveFood(textEmp); Task takeSlurpie = new TakeSlurpie(text); Task takingLong = new TakingLong(text); Task outOfFood = new OutOfFood(textEmp); Task outOfSlurpie = new OutOfSlurpie(textEmp); Task hulkOut = new HulkOut(text, this.gameObject); Task enterManager = new EnterManager(managerRb); Task killKaren = new KillKaren(this.gameObject, karenAnim); //if out of food, yell and get slurpie taskList.Add(isOutOfFood); taskList.Add(walkToCounter); taskList.Add(wait); taskList.Add(orderFood); taskList.Add(wait); taskList.Add(outOfFood); taskList.Add(wait); taskList.Add(takeSlurpie); taskList.Add(wait); taskList.Add(walkFromCounter); Sequence sequenceSlurpie = new Sequence(taskList); taskList = new List <Task>(); //if slurpie machine broken taskList.Add(machineBroken); taskList.Add(walkToCounter); taskList.Add(wait); taskList.Add(orderFood); taskList.Add(wait); taskList.Add(outOfSlurpie); taskList.Add(wait); taskList.Add(hulkOut); taskList.Add(wait); taskList.Add(wait); taskList.Add(takingLong); taskList.Add(enterManager); taskList.Add(walkFromCounterMid); taskList.Add(killKaren); Sequence sequenceKaren = new Sequence(taskList); taskList = new List <Task>(); //if else walk and get food taskList.Add(walkToCounter); taskList.Add(wait); taskList.Add(orderFood); taskList.Add(wait); taskList.Add(giveFood); taskList.Add(wait); taskList.Add(walkFromCounter); Sequence sequenceNormal = new Sequence(taskList); taskList = new List <Task>(); taskList.Add(sequenceSlurpie); taskList.Add(sequenceKaren); taskList.Add(sequenceNormal); Selector selector = new Selector(taskList); return(selector); }
public OrderFoodDto(OrderFood orderFood) { this.FoodName = orderFood.Food.Name; this.Price = orderFood.Price; this.Amount = orderFood.Amount; }
public ActionResult TrackOrder(string id) { try { if (id == "") { return(HttpNotFound()); } else { CurrentOrderTrackID = Convert.ToInt32(id); Order order = new Order(); List <OrderFood> productlist = new List <OrderFood>(); foreach (OrderFood Order in db.OrderFoods) { if (Order.OrderID == Convert.ToInt32(id)) { OrderFood Oproduct = new OrderFood(); //Oproduct.Order.Status = Order.Order.Status; Oproduct.OrderID = Order.OrderID; Oproduct.ProductID = Order.ProductID; Oproduct.Price = Order.Price; Oproduct.Category = Order.Category; Oproduct.ProductName = Order.ProductName; Oproduct.Quantity = Order.Quantity; productlist.Add(Oproduct); cancelview can = new cancelview(); can.OrderID = Order.OrderID; can.FoodID = Order.ProductID; can.Quantity = Order.Quantity; db.SaveChanges(); } } int r = Convert.ToInt32(id); order = db.Orders.Find(Convert.ToInt32(id)); if (order == null) { ViewBag.NULL = true; } else { ViewBag.orderStatus = order.Status; } ViewBag.Filterthroughid = productlist; return(View(productlist.ToList())); } } catch (System.Data.Entity.Validation.DbEntityValidationException dbEx) { Exception raise = dbEx; foreach (var validationErrors in dbEx.EntityValidationErrors) { foreach (var validationError in validationErrors.ValidationErrors) { string message = string.Format("{0}:{1}", validationErrors.Entry.Entity.ToString(), validationError.ErrorMessage); raise = new InvalidOperationException(message, raise); } } throw raise; } }