public async Task <HttpResponseMessage> SaveTableItemAsync(TableOrder item, bool isNewItem = false) { // RestUrl = http://developer.xamarin.com:8081/api/todoitems try { var json = JsonConvert.SerializeObject(item); var content = new StringContent(json, Encoding.UTF8, "application/json"); HttpResponseMessage response = null; if (isNewItem) { var uri = new Uri("https://postalwebapi.azurewebsites.net/api/TableOrders"); response = await client.PostAsync(uri, content); } else { var uri = new Uri($"https://postalwebapi.azurewebsites.net/api/TableOrders/{item.Id}"); response = await client.PutAsync(uri, content); } if (response.IsSuccessStatusCode) { return(response); } } catch (Exception ex) { //Debug.WriteLine(@" ERROR {0}", ex.Message); } return(null); }
private async void SubmitOrder() { using (UserDialogs.Instance.Loading("Submitting Order...")) { TableOrder tableOrder = new TableOrder() { OrderTime = DateTime.Now, StaffId = Intent.GetIntExtra("StaffId", 1), TableNumId = Intent.GetIntExtra("TableId", 1) }; HttpResponseMessage tableOrderResponse = await tableOrderService.SaveTableItemAsync(tableOrder, true); var tableOrderContent = await tableOrderResponse.Content.ReadAsStringAsync(); var newTableOrder = JsonConvert.DeserializeObject <TableOrder>(tableOrderContent); foreach (Model.Menu item in orderList) { OrderItem orderItem = new OrderItem() { MenuId = item.Id, TableOrderId = newTableOrder.Id }; await orderItemService.SaveTableItemAsync(orderItem, true); } } await UserDialogs.Instance.AlertAsync("Order submitted"); Finish(); }
private void ConvertTable(TableJSON tableFirst) { if (DataWallet.TryFromTable(tableFirst, Wallet, out DataWallet outW)) { Console.WriteLine($"TableWallet Amount: {outW.Amount}"); Wallet = outW; } else if (DataMargin.TryFromTable(tableFirst, Margin, out DataMargin outM)) { Console.WriteLine($"TableMargin Amount: {outM.Amount}"); Margin = outM; } else if (Position.TryFromTable(tableFirst, Positions, out ObservableCollection <Position> outP)) { //Console.WriteLine($"TablePositions Positions.Data.Length: {table.Data.Length}"); //Console.WriteLine("************************************\r\n" + e.Data + "\r\n************************************"); Positions = outP; OnPropertyChanged("ChangedPositions"); } else if (TableOrder.TryFromTable(tableFirst, Orders, out ObservableCollection <TableOrder> outO)) { //Console.WriteLine($"TableOrders Orders.Data.Length: {table.Data.Length}"); Orders = outO; } else { } }
public ClientOrder Find(string id, CloudTable table) { ClientOrder resOrd = null; TableOperation operation = TableOperation.Retrieve <TableOrder>("Orders", id); TableResult result = table.Execute(operation); if (result.Result != null) { TableOrder obj = (TableOrder)result.Result; Customer cus = new Customer(); cus.Name = obj.Name; cus.Address = obj.Address; cus.City = obj.City; Item itm = new Item(); itm.ProductType = obj.ProductType; itm.Article = obj.Article; itm.Amount = obj.Amount; ClientOrder ord = new ClientOrder(); ord.Id = obj.RowKey; ord.customer = cus; ord.item = itm; resOrd = ord; } return(resOrd); }
public async Task <IActionResult> Edit(int id, [Bind("ID,Name,OrderNo,KOT,OrderDate")] TableOrder tableOrder) { if (id != tableOrder.ID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(tableOrder); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!TableOrderExists(tableOrder.ID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(tableOrder)); }
public bool createOrder(Order newOrder, List <OrderLine> orderLines) { //here i need a transaction because connection.Connection.Open(); using (connection.Transaction = connection.Connection.BeginTransaction()) { try { TableOrder createdOrder = new TableOrder(newOrder.customer.ID, newOrder.date, newOrder.total); this.connection.orders.InsertOnSubmit(createdOrder); connection.SubmitChanges(); foreach (var line in orderLines) { line.order = createdOrder.ID; this.connection.orderLines.InsertOnSubmit(new TableOrderLine(line.product.ID, line.order, line.qty, line.priceUnit)); var prod = (from prodotti in this.connection.products where prodotti.ID == line.product.ID select prodotti) .First(); prod.qty = prod.qty - line.qty; connection.SubmitChanges(); } connection.Transaction.Commit(); } catch (Exception e) { return(false); } connection.Connection.Close(); return(true); } }
public Tuple <String, Int32, String> GetTableAttributes(Int32 tableId, Boolean showPaidChecks) { TableOrder tableOrder = GetTableOrder(tableId); String checksIds = String.Empty; Int32 orderStatus = (Int32)CommonUnit.TableOrderStatus.Closed; String orderDate = String.Format("{0:M/d/yyyy HH:mm:ss}", DateTime.Now); // Grabbing checks if (tableOrder != default(TableOrder)) { List <Check> checks; if (!showPaidChecks) { checks = tableOrder.Checks.Where(m => m.Status != (Int32)CommonUnit.CheckStatus.Paid).ToList(); } else { checks = tableOrder.Checks.ToList(); } if (checks != null) { checksIds = String.Join("|", checks.Select(m => String.Format("{0}:{1}", m.id, m.Status)).ToArray()); } // Grab Status orderStatus = tableOrder.Status; // Grab Date orderDate = String.Format("{0:M/d/yyyy HH:mm:ss}", tableOrder.DateModified); } return(new Tuple <String, Int32, String>(checksIds, orderStatus, orderDate)); }
public ActionResult Create(int tableOrderId, int dishId, int newDishQuantity) { TableOrder foundOrder = TableOrder.Find(tableOrderId); foundOrder.AddDish(dishId, newDishQuantity); return(RedirectToAction("Show")); }
public ActionResult Update(int tableOrderId, string tableNumber, DateTime orderDate) { TableOrder foundTableOrder = TableOrder.Find(tableOrderId); foundTableOrder.Edit(tableNumber, orderDate); return(RedirectToAction("Show")); }
public ActionResult Update(int tableOrderId, int dishId, int quantity) { TableOrder foundOrder = TableOrder.Find(tableOrderId); foundOrder.UpdateDish(dishId, quantity); return(RedirectToAction("Show")); }
public ActionResult Delete(int tableOrderId) { TableOrder foundOrder = TableOrder.Find(tableOrderId); foundOrder.Delete(); return(RedirectToAction("Index")); }
public void Dispose() { Ingredient.ClearAll(); Dish.ClearAll(); //Shipment.ClearAll(); TableOrder.ClearAll(); }
public ActionResult Create(string tableNumber, DateTime orderDate) { TableOrder newOrder = new TableOrder(tableNumber, DateTime.Now); newOrder.Save(); return(RedirectToAction("Show", new { tableOrderId = newOrder.GetId() })); }
public async Task <IActionResult> PutTableOrder([FromRoute] int id, [FromBody] TableOrder tableOrder) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != tableOrder.Id) { return(BadRequest()); } _context.Entry(tableOrder).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!TableOrderExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
private void btnTable_Click(object sender, EventArgs e) { Button b = sender as Button; if (b == null) { return; } TableOrder to = new TableOrder(Convert.ToInt32(b.Tag)); /////// using (var TableOrder = new TableOrder(Convert.ToInt32(b.Tag))) { var result = to.ShowDialog(); if (result == DialogResult.OK) { ApplicationDbContext cntxt = new ApplicationDbContext(); var c = cntxt.ByTables.FirstOrDefault(z => z.TableID == (int)b.Tag); if (c.check == 1) { b.BackColor = Color.Red; b.ForeColor = Color.White; } else if (c.check == 0) { b.BackColor = Color.Azure; b.ForeColor = Color.Black; } } } ////// }
public void GetAllDishes_ReturnsOrder_DishQuantityList() { Dish newDish = new Dish("Cesar Salad"); newDish.Save(); int dishId = newDish.GetId(); Dish newDish2 = new Dish("Eggs and bacon"); newDish2.Save(); int dishId2 = newDish2.GetId(); TableOrder newTableOrder = new TableOrder("4", new DateTime(2019, 3, 12)); newTableOrder.Save(); newTableOrder.AddDish(dishId, 2); newTableOrder.AddDish(dishId2, 1); List <DishQuantity> testList = new List <DishQuantity> { new DishQuantity(newDish, 2), new DishQuantity(newDish2, 1) }; List <DishQuantity> result = newTableOrder.GetAllDishes(); Console.WriteLine("{0} {1}", testList.Count, result.Count); Console.WriteLine("{0} {1}", testList[0].GetQuantity(), result[0].GetQuantity()); Console.WriteLine("{0} {1}", testList[1].GetQuantity(), result[1].GetQuantity()); CollectionAssert.AreEquivalent(testList, result); //Assert.AreEqual(testList.Count, result.Count); //Assert.AreEqual(2, result[0].GetQuantity()); }
public bool Update(ref CloudTable table, ClientOrder order) { bool updated = false; TableOperation operation = TableOperation.Retrieve <TableOrder>("Orders", order.Id); TableResult result = table.Execute(operation); if (result.Result != null) { TableOrder obj = (TableOrder)result.Result; obj.Name = order.customer.Name; obj.Address = order.customer.Address; obj.City = order.customer.City; obj.ProductType = order.item.ProductType; obj.Article = order.item.Article; obj.Amount = order.item.Amount; operation = TableOperation.Replace(obj); table.Execute(operation); updated = true; } return(updated); }
public ActionResult Delete(int tableOrderId, int dishId) { Console.WriteLine(" Delete: {0} {1}", tableOrderId, dishId); TableOrder foundOrder = TableOrder.Find(tableOrderId); foundOrder.DeleteDish(dishId); return(RedirectToAction("Show")); }
public ActionResult DeleteConfirmed(int id) { TableOrder tableOrder = db.TableOrders.Find(id); db.TableOrders.Remove(tableOrder); db.SaveChanges(); return(RedirectToAction("Index")); }
private async void CompleteOrder(TableOrder tableOrder) { tableOrder.Complete = true; await tableOrderService.SaveTableItemAsync(tableOrder, false); GetOrders(); }
public void Equals_ChecksIfTwoOrdersAreTheSame_True() { string tableNumber = "4"; DateTime orderDate = new DateTime(2019, 3, 12); TableOrder firstOrder = new TableOrder(tableNumber, orderDate); TableOrder secondOrder = new TableOrder(tableNumber, orderDate); Assert.AreEqual(firstOrder, secondOrder); }
public OrderRESTWS(BitMEXOrder OrderREST, TableOrder OrderWS = null) { this.OrderREST = OrderREST; this.OrderWS = OrderWS; if (this.OrderREST != default && this.OrderWS != default && this.OrderREST.orderID != this.OrderWS.OrderID) { throw new ArgumentException(); } }
/// <summary>Изменить цену по выставленному ордеру</summary> /// <param name="parameter"></param> protected override void OnOrderAmend(object parameter) { if (CanOrderAmend(parameter)) { TableOrder oldOrder = ListOrderAmend.First().OrderWS; OrderAmend(oldOrder.OrderID, Price); } base.OnOrderAmend(parameter); }
private void toClosing(object sender, FormClosingEventArgs e) { Button b = sender as Button; if (b == null) { return; } TableOrder f = sender as TableOrder; }
public ActionResult Show(int tableOrderId) { TableOrder foundOrder = TableOrder.Find(tableOrderId); Dictionary <string, object> model = new Dictionary <string, object>(); model["order"] = foundOrder; model["order_dishes"] = foundOrder.GetAllDishes(); model["all_dishes"] = foundOrder.GetPotentialDishes();//Dish.GetAll(); return(View(model)); }
public ActionResult Edit([Bind(Include = "ID,Name,OrderNo,KOT,OrderDate")] TableOrder tableOrder) { if (ModelState.IsValid) { db.Entry(tableOrder).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(tableOrder)); }
public void GetTableOrderDate_ReturnsTableOrderDate_DateTime() { int id = 0; string tableNumber = "4"; DateTime orderDate = new DateTime(2019, 3, 12); TableOrder newOrder = new TableOrder(tableNumber, orderDate, id); DateTime result = newOrder.GetOrderDate(); Assert.AreEqual(result, orderDate); }
public void GetId_ReturnsId_Int() { int id = 0; string tableNumber = "4"; DateTime orderDate = new DateTime(2019, 3, 12); TableOrder newTableOrder = new TableOrder(tableNumber, orderDate, id); int result = newTableOrder.GetId(); Assert.AreEqual(result, id); }
public async Task <IActionResult> Create([Bind("ID,Name,OrderNo,KOT,OrderDate")] TableOrder tableOrder) { if (ModelState.IsValid) { _context.Add(tableOrder); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(tableOrder)); }
private void Order_PropertyChanged(object sender, PropertyChangedEventArgs e) { string nameProperty = e.PropertyName; TableOrder order = (TableOrder)sender; if ((string.IsNullOrEmpty(nameProperty) || nameProperty == "OrdStatus") && (order.OrdStatus == "Filled" || order.OrdStatus == "Canceled")) { MainDispatcher.dispatcher.Invoke(() => { Orders.Remove(order); }); } }
public TableBill(int table, TableOrder tableOrder = new TableOrder)