public static OrderR GetTeamInformation(Entities context, string user, Team team, int id) { var order = new OrderR { Team = team.Name }; var allOrders = context.Orders.Where(x => x.IdUniverseCompetition == id && x.Team == team.Id && x.Status == 0) .ToList(); var bestAsk = allOrders.Where(x => x.Side.Trim() == "SELL") .OrderBy(x => x.Price) .FirstOrDefault(); if (bestAsk != null) { order.BestAsk = bestAsk.Price; order.BestAskQuantity = bestAsk.Quantity; } var bestBid = allOrders.Where(x => x.Side.Trim() == "BUY") .OrderByDescending(x => x.Price) .FirstOrDefault(); if (bestBid != null) { order.BestBid = bestBid.Price; order.BestBidQuantity = bestBid.Quantity; } var myAsk = allOrders.FirstOrDefault(x => x.Side.Trim() == "SELL" && x.User == user); if (myAsk != null) { order.MyAsk = myAsk.Price; order.MyAskQuantity = myAsk.Quantity; } var myBid = allOrders.FirstOrDefault(x => x.Side.Trim() == "BUY" && x.User == user); if (myBid != null) { order.MyBid = myBid.Price; order.MyBidQuantity = myBid.Quantity; } var lastPrices = context.Trades.Where(x => x.IdUniverseCompetition == id && x.Team == team.Id && x.Price != 0) .OrderByDescending(x => x.Date) .ToList(); if (lastPrices.Count > 0) { order.LastTradedPrice = lastPrices[0].Price; if (lastPrices.Count > 1) { order.LastTradedPriceEvolution = order.LastTradedPrice - lastPrices[1].Price; } } return(order); }
public IActionResult Edit(int id, [Bind("Id,TableNo,OrderNumber,OrderDate,OrderType,EmployeeId,PaymentAmount,PaymentStautas,PaymentType,StatusType")] OrderR orderR) { if (id != orderR.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(orderR); _context.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!OrderRExists(orderR.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(orderR)); }
public IActionResult Create([Bind("Id,TableNo,OrderNumber,OrderDate,OrderType,EmployeeId,PaymentAmount,PaymentStautas,PaymentType,StatusType")] OrderR orderR) { if (ModelState.IsValid) { _context.Add(orderR); _context.SaveChanges(); return(RedirectToAction(nameof(Index))); } return(View(orderR)); }
private void insrtbtn_Click(object sender, EventArgs e) { if (this.orderIdTxt.Text == "" || this.productIdTxt.Text == "" || this.productNameTxt.Text == "" || this.quantityTxt.Text == "" || this.addressTxt.Text == "" || this.employeeNameTxt.Text == "" || this.comboBox1.Text == "" || this.comboBox3.Text == "") { MessageBox.Show("Insert data"); } else { OrderR i = new OrderR(); OrderRepository orderRepo = new OrderRepository(); InventoryRepository ir = new InventoryRepository(); i.OrderId = (this.orderIdTxt.Text).ToUpper().Trim(); i.ProductId = (this.productIdTxt.Text).ToUpper().Trim(); i.ProductName = this.productNameTxt.Text; i.Quantity = Convert.ToInt32(this.quantityTxt.Text); i.Address = this.addressTxt.Text; i.EmployeeName = this.employeeNameTxt.Text; i.Catagory = this.comboBox3.GetItemText(this.comboBox3.SelectedItem); i.Status = "Order"; if (orderRepo.Insert(i)) { List <OrderR> iList = orderRepo.GetAllOrder(); this.dataGrid2.DataSource = iList; this.orderIdTxt.Text = ""; this.productIdTxt.Text = ""; this.productNameTxt.Text = ""; this.quantityTxt.Text = ""; this.addressTxt.Text = ""; this.employeeNameTxt.Text = ""; this.comboBox3.Text = ""; } else { MessageBox.Show("Can Not Insert Order", "Insert Error"); } } }
private void updateBtn_Click(object sender, EventArgs e) { if (this.orderIdTxt.Text == "" || this.productIdTxt.Text == "" || this.productNameTxt.Text == "" || this.quantityTxt.Text == "" || this.addressTxt.Text == "" || this.employeeNameTxt.Text == "" || this.comboBox1.Text == "" || this.comboBox3.Text == "") { MessageBox.Show("Insert the data"); } else { OrderR i = new OrderR(); i.OrderId = this.orderIdTxt.Text; i.ProductId = this.productIdTxt.Text; i.ProductName = this.productNameTxt.Text; i.Quantity = Convert.ToInt32(this.quantityTxt.Text); i.Address = this.addressTxt.Text; i.EmployeeName = this.employeeNameTxt.Text; OrderRepository orderRepo = new OrderRepository(); if (orderRepo.Update(i)) { List <OrderR> iList = orderRepo.GetAllOrder(); this.dataGrid2.DataSource = iList; this.orderIdTxt.Text = ""; this.productIdTxt.Text = ""; this.productNameTxt.Text = ""; this.quantityTxt.Text = ""; this.addressTxt.Text = ""; this.employeeNameTxt.Text = ""; } else { MessageBox.Show("Can Not Update Order", "Opdate Error"); } } }
public IActionResult AddProduct(string tableNo, string OrderNo, DateTime OderDate, string orderType, string OrderStutas, string paymentType, double paymentAmount) { OrderR order = new OrderR(); order.TableNo = tableNo; order.OrderNumber = OrderNo; order.OrderDate = OderDate; order.OrderType = orderType; order.StatusType = OrderStutas; order.PaymentType = paymentType; order.PaymentAmount = paymentAmount; _context.OrderR.Add(order); _context.SaveChanges(); string msg = ""; if (!string.IsNullOrEmpty(order.TableNo)) { if (!string.IsNullOrEmpty(order.OrderNumber)) { if (!string.IsNullOrEmpty(order.OrderDate.ToString())) { if (!string.IsNullOrEmpty(order.OrderType)) { if (!string.IsNullOrEmpty(order.StatusType)) { if (!string.IsNullOrEmpty(order.PaymentType)) { if (order.PaymentAmount > 0) { string item = order.TableNo + ";" + order.OrderNumber + ";" + order.OrderDate.ToString() + ";" + order.OrderType + ";" + order.StatusType + ";" + order.PaymentType + ";" + order.PaymentAmount.ToString(); string prods = HttpContext.Session.GetString("shopcart"); if (!string.IsNullOrEmpty(prods)) { prods += "|" + item; HttpContext.Session.SetString("shopcart", prods); msg = "Order is addedsuccessfully."; } else { HttpContext.Session.SetString("shopcart", item); msg = "Order is added successfully."; } } else { msg = "Payment Amount Must Be Entered"; } } else { msg = "Payment Type Must Be Entered"; } } else { msg = "Order5 Stutas Must Be Entered"; } } else { msg = "OrderType Must Be Entered"; } } else { msg = "OrderDate Must Be Entered"; } } else { msg = "Order Must Be Entered"; } } else { msg = "Table Number Must Be Entered"; } TempData["msg"] = msg; return(RedirectToAction("Index")); }