public IActionResult Index() { SetTables(); SetDishes(); SetOrders(); var viewModel = new TableSummaryViewModel() { Tables = tables }; return(View(viewModel)); }
public IActionResult TableSummary(string tableId) { decimal tableTotal = 0; string orderList = string.Empty; var summary = new List <TableSummaryModel>(); var table_id = Convert.ToInt32(tableId.Decrypt()); // masa kodu: masa, o an masada yer alan müşteriler, müşterilerin siparişleri, siparişleri karşılayan garson // arasındaki bağlantıyı sağlayan unique bir değerdir. var tableCode = _tableService.GetTableById(table_id, _currentUser.BranchId).Code; // masada o an yer alan müşterileri getirir. var customers = _customerService.GetCustomersByTableCode(tableCode); // her bir müşteri için adisyonu hazırlar. foreach (var customer in customers) { var orders = _orderService.GetOrdersOfCustomer(customer.Id); foreach (var order in orders) { orderList += (string.Format("{0} ({1} {2}), ", order.Menu.Name, order.Menu.Price, "TL")); } summary.Add(new TableSummaryModel { CustomerName = customer.Name, CustomerTotal = orders.Sum(i => i.Menu.Price), Orders = orderList == "" ? orderList : orderList.Substring(0, orderList.Length - 2) }); tableTotal += orders.Sum(i => i.Menu.Price); orderList = string.Empty; } var model = new TableSummaryViewModel { Summary = summary, Total = tableTotal }; return(PartialView(model)); }