Example #1
0
        public async Task <IActionResult> Finish([FromBody] FinishOrderRequest request)
        {
            try
            {
                request.UserId = Guid.Parse(User.FindFirst(ClaimTypes.PrimarySid).Value);
                var response = await _mediator.Send(request, CancellationToken.None);

                return(Ok(response));
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }
        }
        private async void cpCheckoutButton_Clicked(object sender, EventArgs e)
        {
            if (checkOutOrder.orderItems.Count() == 0)
            {
                await DisplayAlert("No Items Selected", "Please select items to checkout", "OK");

                return;
            }

            await UpdateOrderMenuItemsRequest.SendUpdateOrderMenuItemsRequest(order._id, order.menuItems);

            tip = (cpTip.Text == "") ? 0f : Double.Parse(cpTip.Text);

            updateItems();

            MainMenu.OnReturn();

            await PostTipRequest.SendPostTipRequest(order.employee_id, tip);

            for (int i = 0; i < coupons.Count(); i++)
            {
                if (coupons[i].couponType == "Customer")
                {
                    await DeactivateCouponRequest.SendDeactivateCouponRequest(coupons[i]._id);
                }
            }

            bool orderComplete = true;

            await GetTableRequest.SendGetTableRequest(RealmManager.All <Table>().First().table_number);

            for (int i = 0; i < RealmManager.All <Table>().First().order_id.menuItems.Count(); i++)
            {
                if (!RealmManager.All <Table>().First().order_id.menuItems[i].paid && !RealmManager.All <Table>().First().order_id.menuItems[i].prepared)
                {
                    orderComplete = false;
                    break;
                }
            }

            if (orderComplete)
            {
                await FinishOrderRequest.SendFinishOrderRequest(RealmManager.All <Table>().First()._id);
            }

            await Navigation.PushAsync(new PaymentPage(totalPrice, tip));
        }