public async Task <ActionResult <PaymentResultDto> > GeneratePayment(GeneratePaymentDto generatePaymentDto)
 {
     if (generatePaymentDto == null)
     {
         return(BadRequest("Payment data must be set!"));
     }
     try
     {
         return(Ok(await _service.GeneratePaymentAsync(generatePaymentDto)));
     }
     catch (Exception e)
     {
         return(Conflict(e.Message));
     }
 }
        public async Task <PaymentResultDto> GeneratePaymentAsync(GeneratePaymentDto generatePaymentDto)
        {
            PaymentResultDto paymentResultDto = new PaymentResultDto
            {
                FullDiscount = 0,
                FullPrice    = 0
            };

            generatePaymentDto.Order.OrderItems
            .ForEach(x => paymentResultDto.FullPrice += x.MenuItemPrice * x.NumberOfItems);

            int regularGuestDiscount = 0;

            if (generatePaymentDto.RegularGuest != null)
            {
                regularGuestDiscount = (int)(paymentResultDto.FullPrice * (generatePaymentDto.RegularGuest.Discount / 100.00));
            }

            int discountDiscount = 0;

            if (generatePaymentDto.Discount != null)
            {
                if (generatePaymentDto.Discount.Type == "Price")
                {
                    discountDiscount = generatePaymentDto.Discount.Value;
                }
                else
                {
                    discountDiscount = (int)(paymentResultDto.FullPrice * (generatePaymentDto.Discount.Value / 100.00));
                }

                bool success = await _repository
                               .SetDiscountUsedAsync(generatePaymentDto.Discount.ToEntity());
            }

            paymentResultDto.FullDiscount = regularGuestDiscount + discountDiscount;
            paymentResultDto.Result       = paymentResultDto.FullPrice - paymentResultDto.FullDiscount;
            if (paymentResultDto.Result < 0)
            {
                paymentResultDto.Result = 0;
            }

            return(paymentResultDto);
        }