Exemplo n.º 1
0
        public IActionResult Pay(int orderId)
        {
            FoodOrder foodOrder = dbFoodOrder.GetWholeEntity(orderId);

            if (foodOrder.TotalCost > foodOrder.Customer.Balance)
            {
                return(new ObjectResult("You can not pay, your balance is less that total cost!"));
            }
            int      newBalance = MainLogic.RefreshBalance((int)foodOrder.Customer.Balance, -foodOrder.TotalCost);
            Customer customer   = foodOrder.Customer;

            customer.Balance = newBalance;
            dbCustomer.Update(customer);
            dbCustomer.Save();
            //dbFoodOrder.Delete(orderId);
            dbFoodOrder.Save();
            return(new ObjectResult("Succesful pay!"));
        }