Exemple #1
0
        // Update the specific ordered food detail in database
        public async Task <IActionResult> UpdateOrderDetail(OrderDetailDisplayModel displayDetail)
        {
            var table = await _table.GetTableByTableNumber(displayDetail.TableNumber);

            string[] fullName = displayDetail.Server.Split(" ");
            var      server   = await _people.GetPersonByFullName(fullName[0], fullName[1]);

            var food = await _food.GetFoodByName(displayDetail.FoodName);

            OrderDetailModel orderDetail = new OrderDetailModel
            {
                Id            = displayDetail.Id,
                DiningTableId = table.Id,
                ServerId      = server.Id,
                FoodId        = food.Id,
                Quantity      = displayDetail.Quantity,
                OrderDate     = displayDetail.OrderDate
            };

            await _order.UpdateOrderDetail(orderDetail);

            return(RedirectToAction("OrderDetailsByTableNumber", new { table.TableNumber }));
        }
        // Pay Bill button press will insert bill info into database and update BillPaid info
        // in order table and orderDetail table
        public async Task <IActionResult> PayBill(BillDisplayModel displayBill)
        {
            var table = await _table.GetTableByTableNumber(displayBill.TableNumber);

            string[] fullName = displayBill.Server.Split(" ");
            var      server   = await _people.GetPersonByFullName(fullName[0], fullName[1]);

            BillModel bill = new BillModel
            {
                OrderId       = displayBill.OrderId,
                DiningTableId = table.Id,
                ServerId      = server.Id,
                SubTotal      = displayBill.SubTotal,
                Tax           = displayBill.Tax,
                Total         = displayBill.Total,
                BillPaid      = true
            };

            await _bill.InsertBill(bill);

            return(RedirectToAction("Index", "Home"));
        }