public void SavePayment(TourClient tourClient, decimal amountToPay)
 {
     tourClient.CurrentPayment = amountToPay;
     tourClient.DateUpdated    = DateTime.Now;
     _simbaToursUnitOfWork._tourClientRepository.Update(tourClient);
     _simbaToursUnitOfWork.SaveChanges();
 }
Example #2
0
        public IActionResult MakePayment([FromBody] UserDetailViewModel userDetail)
        {
            _serviceEndPoint = new ServicesEndPoint.GeneralSevices.ServicesEndPoint(_simbaToursUnitOfWork, _emailService);
            TourClient tourClient = _serviceEndPoint.GetTourClient(userDetail.EmailAddress);

            var payPalRedirectUrl = ValidatePayment(tourClient, userDetail.CurrentPayment);

            payPalRedirectUrl += "&clientId=" + tourClient.TourClientId;
            //return Redirect(payPalRedirectUrl);
            return(Json(new { PayPalRedirectUrl = payPalRedirectUrl, PaymentCompletion = "Success", Message = "The payment will be acquired by Paypal reporting, and you will be informed by email whether successful. Wait for the email." }));
        }
Example #3
0
        private string ValidatePayment(TourClient tourClient, decimal amountToPay)
        {
            _serviceEndPoint = new ServicesEndPoint.GeneralSevices.ServicesEndPoint(_simbaToursUnitOfWork, _emailService);
            var productArray = new List <Product>();

            if (tourClient != null)
            {
                productArray.Add(new Product
                {
                    ProductName   = tourClient.Hotel.Location.LocationName + "-" + tourClient.Hotel.HotelName,
                    Amount        = amountToPay,
                    HasPaidInfull = amountToPay == tourClient.GrossTotalCosts - tourClient.PaidInstallments
                });
            }
            _serviceEndPoint.SavePayment(tourClient, amountToPay);
            var paymentGateway = new PaymentGateway(_applicationConstants.Value.BaseUrl, _applicationConstants.Value.BusinessEmail, _applicationConstants.Value.SuccessUrl, _applicationConstants.Value.CancelUrl, _applicationConstants.Value.NotifyUrl, tourClient.EmailAddress);

            return(paymentGateway.MakePaymentByPaypal(productArray));
        }
Example #4
0
        private void IterateThroughMeals(IList <Item> mealItems, ref decimal runningCostItems, MealPricing unitPaymentMeal, TourClientViewModel tourClientModel, TourClient tourClient)
        {
            foreach (var it in tourClientModel.CombinedMeals.MealItems)
            {
                var actualItemCost = 0.00M;

                var itemType = (Domain.Models.ItemType)Enum.Parse <Domain.Models.ItemType>(it.ItemType.ToString());
                if (it.Quantity > 0)
                {
                    CalculateRunningItemCostMeal(itemType, tourClientModel, it, unitPaymentMeal, ref runningCostItems, ref actualItemCost);
                    mealItems.Add(new Item {
                        mealPricing = unitPaymentMeal, mealPricingId = unitPaymentMeal.MealPricingId, ItemCost = actualItemCost, ItemId = it.ItemId,
                        ItemType    = (Domain.Models.ItemType)Enum.Parse <Domain.Models.ItemType>(it.ItemType.ToString()),
                        Meal        = new Meal {
                            MealId = 0, TourClient = tourClient, TourClientId = tourClient.TourClientId
                        }, Quantity = it.Quantity
                    });
                }
            }
        }
 public void UpdateClientPayments(TourClient client)
 {
     _simbaToursUnitOfWork._tourClientRepository.Update(client);
     _simbaToursUnitOfWork.SaveChanges();
 }
        public bool BookSafariPackage(TourClient tourClient, Item[] combinedMeal, Item[] combinedLaguage)
        {
            using (IDbContextTransaction transaction = _simbaToursUnitOfWork.SimbaToursEastAfricaDbContext.Database.BeginTransaction())
            {
                try
                {
                    var tourClientModel = new TourClient {
                        DateCreated = DateTime.Now, ClientFirstName = tourClient.ClientFirstName, ClientLastName = tourClient.ClientLastName, HotelId = tourClient.Hotel.HotelId, GrossTotalCosts = tourClient.GrossTotalCosts, HasRequiredVisaStatus = tourClient.HasRequiredVisaStatus, Nationality = tourClient.Nationality, NumberOfIndividuals = tourClient.NumberOfIndividuals, EmailAddress = tourClient.EmailAddress
                    };
                    _simbaToursUnitOfWork._tourClientRepository.Insert(tourClientModel);
                    _simbaToursUnitOfWork.SaveChanges();
                    tourClient.TourClientId = tourClientModel.TourClientId;
                    foreach (var vehicle in tourClient.Vehicles)
                    {
                        _simbaToursUnitOfWork._vehicleRepository.Insert(vehicle);
                        vehicle.TourClientId = tourClientModel.TourClientId;
                        _simbaToursUnitOfWork.SaveChanges();
                    }
                    var hotel    = tourClient.Hotel;
                    var location = hotel.Location;
                    var ht       = new HotelBooking
                    {
                        TourClientId     = tourClientModel.TourClientId,
                        LocationId       = location.LocationId,
                        HotelName        = hotel.HotelName,
                        AccomodationCost = tourClient.GrossTotalCosts,
                        HasMealsIncluded = hotel.HasMealsIncluded,
                        HotelPricingId   = hotel.HotelPricing.HotelPricingId,
                    };
                    _simbaToursUnitOfWork._hotelBookingRepository.Insert(ht);
                    _simbaToursUnitOfWork.SaveChanges();

                    var laguage = new Laguage {
                        TourClientId = tourClientModel.TourClientId, LaguagePricingId = (combinedLaguage.Length > 0) ? (int)combinedLaguage[0].laguagePricing.LaguagePricingId : 1
                    };
                    _simbaToursUnitOfWork._laguageRepository.Insert(laguage);
                    _simbaToursUnitOfWork.SaveChanges();


                    var invoice = new Invoice {
                        InvoiceName = string.Format("Combined Laguage Invoice for Client {0}", tourClientModel.TourClientId), TourClientId = tourClientModel.TourClientId
                    };

                    _simbaToursUnitOfWork._invoiceRepository.Insert(invoice);
                    _simbaToursUnitOfWork.SaveChanges();

                    foreach (var item in combinedLaguage)
                    {
                        var it = new Item();
                        it.Quantity         = item.Quantity;
                        it.MealId           = null;
                        it.LaguageId        = laguage.LaguageId;
                        it.ItemType         = item.ItemType;
                        it.InvoiceId        = invoice.InvoiceId;
                        it.laguagePricingId = laguage.LaguagePricingId;
                        it.mealPricingId    = null;
                        _simbaToursUnitOfWork._itemRepository.Insert(it);
                        _simbaToursUnitOfWork.SaveChanges();

                        invoice.InvoicedItems.Add(it);
                        _simbaToursUnitOfWork.SaveChanges();
                    }


                    var meal = new Meal {
                        TourClientId = tourClientModel.TourClientId, MealPricingId = combinedMeal.Length > 0 ?combinedMeal[0].mealPricing.MealPricingId : 1
                    };
                    _simbaToursUnitOfWork._mealRepository.Insert(meal);
                    _simbaToursUnitOfWork.SaveChanges();
                    var mealInvoice = new Invoice {
                        InvoiceName = string.Format("Combined Meal Invoice for Client {0}", tourClientModel.TourClientId), TourClientId = tourClientModel.TourClientId
                    };

                    _simbaToursUnitOfWork._invoiceRepository.Insert(mealInvoice);
                    _simbaToursUnitOfWork.SaveChanges();
                    foreach (var mealItem in combinedMeal)
                    {
                        var mealIt = new Item();
                        mealIt.MealId           = meal.MealId;
                        mealIt.LaguageId        = null;
                        mealIt.ItemType         = ItemType.Meal;
                        mealIt.Quantity         = mealItem.Quantity;
                        mealIt.InvoiceId        = mealInvoice.InvoiceId;
                        mealIt.mealPricingId    = meal.MealPricingId;
                        mealIt.laguagePricingId = null;
                        _simbaToursUnitOfWork._itemRepository.Insert(mealIt);
                        _simbaToursUnitOfWork.SaveChanges();
                        mealInvoice.InvoicedItems.Add(mealIt);
                        _simbaToursUnitOfWork.SaveChanges();
                    }
                    transaction.Commit();
                    return(true);
                }
                catch (Exception e)
                {
                    transaction.Rollback();
                    throw e;
                }
            }
        }