protected async Task AddToCart(FoodOrder food) { await CartService.Add(FoodOrderService.GetFoodOrder(food.FoodNavigation, food.FoodOrderIngredient.Select(ingredient => ingredient.IngredientNavigation).ToList())); UriHelper.NavigateTo("/cart"); }
public bool PlaceOrder(string items, string customerName) { List <string> order = items.Split(',').ToList(); var orderList = restContext.FoodOrder.Include(f => f.NameNavigation); int orderNum = orderList.ToList().Count + 1; var ordered = new FoodOrder { Name = customerName, Ordernum = orderNum, Ordertime = DateTime.Now }; using (var context = new restaurantContext()) { context.FoodOrder.Add(ordered); context.SaveChanges(); } foreach (string item in order) { var itemList = new OrderItem { Item = item, Ordernum = orderNum }; using (var context = new restaurantContext()) { context.OrderItem.Add(itemList); context.SaveChanges(); } } return(true); }
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow && (e.Row.RowState & DataControlRowState.Edit) > 0) { FoodOrder order = (FoodOrder)e.Row.DataItem; DropDownList dp = (DropDownList)e.Row.FindControl("DropDownList2"); if (dp != null) { dp.DataSource = DropDownList1.Items; dp.DataTextField = "Text"; dp.DataValueField = "Value"; dp.DataBind(); dp.SelectedValue = order.Dish; } DropDownList dp2 = (DropDownList)e.Row.FindControl("DropDownList3"); if (dp2 != null) { dp2.DataSource = RadioButtonList1.Items; dp2.DataTextField = "Text"; dp2.DataValueField = "Value"; dp2.DataBind(); dp2.SelectedValue = order.Size; } } }
public static OrderOwner GetOrderOwner(FoodOrder foodOrder) { var orderOwner = new OrderOwner(foodOrder.OwnerName, foodOrder.Street, foodOrder.HouseNumber, foodOrder.ContactNumber, string.Empty); return(orderOwner); }
public void SellFoodToUser(int foodId, int userId) { if (!this.Exists(foodId)) { throw new ArgumentException("There is no such food with given id in the database!"); } if (!this.userService.Exists(userId)) { throw new ArgumentException("There is no such user with given id in the database!"); } Order order = new Order() { PurchaseDate = DateTime.Now, Status = OrderStatus.Done, UserId = userId, }; FoodOrder foodOrder = new FoodOrder() { FoodId = foodId, Order = order, }; this.context.Orders.Add(order); this.context.FoodOrders.Add(foodOrder); this.context.SaveChanges(); }
public async Task <IActionResult> Edit(int id, [Bind("Name,Ordernum,Ordertime")] FoodOrder foodOrder) { if (id != foodOrder.Ordernum) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(foodOrder); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!FoodOrderExists(foodOrder.Ordernum)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["Name"] = new SelectList(_context.Customer, "Name", "Name", foodOrder.Name); return(View(foodOrder)); }
public async Task <bool> AddAsync(FoodOrder foodOrder) { _context.FoodOrders.Add(foodOrder); int response = _context.SaveChanges(); return(response >= 1 ? true : false); }
public void SellFoodToUser(int foodId, int userId) { if (!this.Exists(foodId) || !userService.Exists(userId)) { throw new InvalidOperationException("Given food or user do not exist in the database"); } var order = new Order() { PurchaseDate = DateTime.UtcNow, Status = OrderStatus.Done, UserId = userId }; var foodOrder = new FoodOrder() { FoodId = foodId, Order = order }; this.data.Orders.Add(order); this.data.FoodOrders.Add(foodOrder); this.data.SaveChanges(); }
public async Task <FoodOrder> Create(CydcContext db, int userId, FoodOrderClientInfo clientInfo) { var menu = await db.FoodMenu.FindAsync(MenuId); var dateNow = DateTime.Now; var foodOrder = new FoodOrder { OrderUserId = userId, OrderTime = dateNow, LocationId = AddressId, FoodMenuId = MenuId, TasteId = TasteId, Comment = Comment, FoodOrderClientInfo = clientInfo, }; foodOrder.AccountDetails.Add(new AccountDetails { UserId = userId, CreateTime = dateNow, Amount = -menu.Price }); db.Add(foodOrder); await db.SaveChangesAsync(); decimal amount = await db.AccountDetails.Where(x => x.UserId == userId).SumAsync(x => x.Amount); if (amount >= 0) { await AutoPay(db, foodOrder); } return(foodOrder); }
public void SellFoodToUser(int foodId, int userId) { if (!this.data.Foods.Any(f => f.Id == foodId)) { throw new ArgumentException("There is no such food in database"); } if (!this.userSerice.Exists(userId)) { throw new ArgumentException("There is no such user with the given Id in the database"); } var order = new Order() { PurchaseDate = DateTime.Now, Status = OrderStatus.Done, UserId = userId, }; var foodOrder = new FoodOrder() { FoodId = foodId, Order = order }; this.data .Orders .Add(order); this.data .FoodOrders.Add(foodOrder); this.data.SaveChanges(); }
protected async Task OrderNow(FoodOrder food) { await Writer.Order.Save(OrderService.GetOrder(food.FoodNavigation, food.FoodOrderIngredient.Select(ingredient => ingredient.IngredientNavigation).ToList())); UriHelper.NavigateTo("/orders"); }
// GET: FoodOrders/Details/5 public async Task <IActionResult> Details(int?id) { if (id == null) { return(NotFound()); } var foodOrder = await _context.FoodOrder .Include(f => f.FoodQuarter) .Include(f => f.FoodType) .Include(f => f.PaymentMethod) .SingleOrDefaultAsync(m => m.OrderId == id); if (foodOrder == null) { return(NotFound()); } FoodOrder order = _context.FoodOrder.SingleOrDefault(f => f.OrderId == id); order.IsSeen = true; _context.FoodOrder.Update(order); _context.SaveChanges(); return(View(foodOrder)); }
public void ShouldAddOrder() { var order = new FoodOrder { ModeOfPayment = PaymentType.Wallet, CustomerId = 2, OrderDate = DateTime.Now }; var orderItems = new List <OrderItem> { new OrderItem { ItemName = "Cheese Sandwich", Quantity = 4, Price = 75, FoodOrder = order }, new OrderItem { ItemName = "Veg Cheese Sandwich", Quantity = 2, Price = 95, FoodOrder = order } }; var result = repository.AddOrder(orderItems); Assert.That(result, Is.True); }
public RedirectToRouteResult ChooseAlpinistWalk(MyInt myInt) { FoodOrder walk = new FoodOrder(); walk.AlpinistID = myInt.ID; return(RedirectToAction("CreateWalk", walk)); }
public IActionResult reserveFood([FromBody] FoodOrder order) { if (order.PaymentMethod == "CASH") { this._context.FoodOrders.Add(order); this._context.SaveChanges(); return(Ok()); } else if (order.PaymentMethod == "CARD") { this._context.FoodOrders.Add(order); this._context.SaveChanges(); using (var client = new System.Net.Http.HttpClient()) { Payment p = new Payment(); p.CardHolderName = order.CardHolderName; p.CardNumber = order.CardNumber; p.CardExpiryDate = order.CardExpiryDate; p.CardCSVNumber = order.CardCSVNumber; client.BaseAddress = new Uri(PAYMENT_GATEWAY); var response = client.PostAsync("", new System.Net.Http.StringContent( new JavaScriptSerializer().Serialize(p), System.Text.Encoding.UTF8, "application/json")).Result; if (response.IsSuccessStatusCode) { return(Ok()); } else { return(BadRequest()); } } } return(BadRequest()); }
public RedirectToRouteResult ChooseAlpinistHouse(MyInt myInt) { FoodOrder houseOrder = new FoodOrder(); houseOrder.AlpinistID = myInt.ID; return(RedirectToAction("CreateHouseOrder", houseOrder)); }
public static FoodOrder GetFoodOrder(Food food, ICollection <Ingredient> customIngredients = null) { var originalIngredients = GetOriginalIngredients(food); var foodOrderIngredient = new List <FoodOrderIngredient>(); if (customIngredients != null) { foodOrderIngredient.AddRange(customIngredients.Except(originalIngredients).Select(ingredient => new FoodOrderIngredient { Isremoval = false, Ingredient = ingredient.Id, IngredientNavigation = ingredient }).ToList()); foodOrderIngredient.AddRange(originalIngredients.Except(customIngredients).Select(ingredient => new FoodOrderIngredient { Isremoval = true, Ingredient = ingredient.Id, IngredientNavigation = ingredient }).ToList()); } var foodOrder = new FoodOrder { Food = food.Id, FoodNavigation = food, FoodOrderIngredient = foodOrderIngredient }; return(foodOrder); }
public ActionResult EditOrderStatus(FoodOrder obj) { //FoodItem objFooditem = new FoodItem(); Dictionary <string, object> data = new Dictionary <string, object>(); data["OrderId"] = obj.OrderID; data["OrderStatus"] = obj.OrderStatus; using (var client = new HttpClient()) { client.BaseAddress = new Uri(Shared.ServerConfig.GetBaseUrl()); //HTTP GET var responseTask = client.PostAsJsonAsync("CafeteriaStaff/UpdateOrderStatus", data); responseTask.Wait(); var result = responseTask.Result; if (result.StatusCode == HttpStatusCode.OK) { return(Content("Order Status Updated!")); } else { return(Content("Err...There seems to be some error!")); } } }
private void button3_Click_1(object sender, EventArgs e) { int a = 0; Random r = new Random(); OrderRepository occ = new OrderRepository(); FoodOrder f = new FoodOrder(); AccountRepository ar = new AccountRepository(); f.AccountId = this.id; a = f.OrderId = r.Next(10000); f.TotalPrice = total; f.Status = "Unpaid"; textBox1.Text = a.ToString(); if (occ.Insert(f)) { MessageBox.Show("Insert Complete"); Cashier c = new Cashier(); } else { MessageBox.Show("Insert Not Complete", "Error"); } }
public void SellFood(int foodId, int userId) { if (!Exists(foodId)) { throw new ArgumentException("No such food exists."); } if (!this.userService.Exists(userId)) { throw new ArgumentException("User not found."); } var order = new Order { Status = Data.Models.Enumerations.OrderStatus.Sold, PurchaseDate = DateTime.Now, UserId = userId }; var foodOrder = new FoodOrder { FoodId = foodId, Order = order }; this.data.Orders.Add(order); this.data.FoodOrders.Add(foodOrder); this.data.SaveChanges(); }
public async Task <IActionResult> Edit(int id, [Bind("OrderId,CustomerEmail,TypeId,FoodName,Price,NumberOfFood,QuarterId,TotalPrice,TypeId2,FoodName2,Price2,NumberOfFood2,QuarterId2,TotalPrice2,TypeId3,FoodName3,Price3,NumberOfFood3,QuarterId3,TotalPrice3,SubTotalPrice,PaymentMethodId,LastFiveDigit,IsPaid,IsSeen,IsAccepted,IsRejected,OrderDate,LastUpdatedDate")] FoodOrder foodOrder) { if (id != foodOrder.OrderId) { return(NotFound()); } if (foodOrder.TypeId > 0 && foodOrder.PaymentMethodId > 0 && foodOrder.TotalPrice > 0) { try { _context.Update(foodOrder); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!FoodOrderExists(foodOrder.OrderId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } //get dropdown data GetDropdownData(); return(View(foodOrder)); }
public async Task <IActionResult> Create([Bind("OrderId,CustomerEmail,TypeId,FoodName,Price,NumberOfFood,QuarterId,TotalPrice,TypeId2,FoodName2,Price2,NumberOfFood2,QuarterId2,TotalPrice2,TypeId3,FoodName3,Price3,NumberOfFood3,QuarterId3,TotalPrice3,SubTotalPrice,PaymentMethodId,LastFiveDigit,IsPaid,IsSeen,IsAccepted,IsRejected,OrderDate,LastUpdatedDate")] FoodOrder foodOrder) { if (_signInManager.IsSignedIn(User)) { foodOrder.CustomerEmail = _userManager.GetUserName(User); } else { return(RedirectToAction("Login", "Account")); } if (!string.IsNullOrEmpty(foodOrder.CustomerEmail)) { if (foodOrder.TypeId > 0 && foodOrder.PaymentMethodId > 0 && foodOrder.TotalPrice > 0) { foodOrder.OrderDate = DateTime.Now; _context.Add(foodOrder); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } } GetDropdownData(); return(View(foodOrder)); }
public void SellFoodToUser(List <int> foodIds, int orderId) { var order = this.data.Orders.Find(orderId); if (order == null) { throw new ArgumentNullException(String.Format(OutputMessages.OrderNotExists, orderId)); } foreach (var id in foodIds) { var food = this.data.Foods.Find(id); if (food == null || food.Quantity < 1) { throw new InvalidOperationException(String.Format(OutputMessages.FoodNotExists, id)); } var foodOrder = new FoodOrder() { FoodId = food.Id, OrderId = orderId }; food.Quantity--; food.Orders.Add(foodOrder); order.Foods.Add(foodOrder); } this.data.SaveChanges(); }
public void SellFoodToUser(int foodId, int userId) { if (!Exists(foodId)) { throw new ArgumentException("There is no such food with given id in the datebase!"); } if (!userServices.Exists(userId)) { throw new ArgumentException("There is no such user with given id in the datebase!"); } var order = new Order() { PurchaseDate = DateTime.Now, Status = OrderStatus.Done, UserId = userId }; var foodOrder = new FoodOrder() { FoodId = foodId, Order = order }; data.Orders.Add(order); data.FoodOrders.Add(foodOrder); data.SaveChanges(); }
public static void AddOrder(FoodOrder order) { using (FoodStallEntities context = new FoodStallEntities()) { context.FoodOrders.Add(order); context.SaveChanges(); } }
public ActionResult CreateWalk(FoodOrder walk) { ViewBag.MyID = false; Walk walk1 = new Walk(); walk1.AlpinistID = walk.AlpinistID; return(View(walk1)); }
public ActionResult CreateHouseOrder(FoodOrder houseOrder) { ViewBag.MyID = false; HouseOrder houseOrder1 = new HouseOrder(); houseOrder1.AlpinistID = houseOrder.AlpinistID; return(View(houseOrder1)); }
public ActionResult DeleteConfirmed(long id) { FoodOrder foodOrder = db.FoodOrders.Find(id); db.FoodOrders.Remove(foodOrder); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult EditOrderStatus(int OrderId) { FoodOrder obj = lstOrder.Where(x => x.OrderID == OrderId).FirstOrDefault(); SelectList OrderStatus = Shared.Constants.getOrderStatus(); ViewBag.OrderStatus = OrderStatus; return(PartialView(obj)); }
public async Task<IActionResult> FoodOrderCreate( FoodOrderViewModel foodorder) { var food = _context.Foods.Single(x=>x.Id== foodorder.foodid); var foodorders = new FoodOrder { Food= food,Number=foodorder.Number,Remarks=foodorder.Remarks,FoodState=foodorder.FoodState,FlarNames=foodorder.degrees,OrderStatus=true }; _context.FoodOrders.Add(foodorders); await _context.SaveChangesAsync(); return RedirectToAction(nameof(Index)); }