public ActionResult Booking(BookingViewModel bookingViewModel) { DateTime week = DateTime.Now.Date.AddDays(7); var todaydate = DateTime.UtcNow.Date; List <Booking> bookingList = new List <Booking>(); string UserID = User.Identity.GetUserId(); var db = GetDb(); if (ModelState.IsValid) { var UserAccountDetail = db.UserAccountDetail.Where(x => x.UserId == UserID && x.BookingID == bookingViewModel.BookingID).FirstOrDefault(); if (UserAccountDetail == null) { PayPalbusinessLogic obj = new PayPalbusinessLogic(); String Token = obj.GetPaypalToken(); bookingViewModel.UserID = UserID; var Response = obj.SaveinfoinPaypalValut(Token, bookingViewModel); if (Response.state == "ok") { var booking = db.Booking.Where(x => x.ID == bookingViewModel.BookingID).FirstOrDefault(); UserAccountDetails UserAccountDetails = new UserAccountDetails(); UserAccountDetails.UserId = UserID; UserAccountDetails.BookingHour = bookingViewModel.BookingHour.ToString(); UserAccountDetails.CraditcardID = Response.id; UserAccountDetails.BookingID = bookingViewModel.BookingID; UserAccountDetails.FirstName = bookingViewModel.FirstName; UserAccountDetails.LastName = bookingViewModel.LastName; UserAccountDetails.Createddate = DateTime.Now; UserAccountDetails.PhoneNumber = bookingViewModel.PhoneNumber; UserAccountDetails.CVV = bookingViewModel.cvv.ToString(); UserAccountDetails.Email = bookingViewModel.Email; UserAccountDetails.UpdatedDate = DateTime.Now; UserAccountDetails.SessionComplete = false; db.UserAccountDetail.Add(UserAccountDetails); int recordsinserted = db.SaveChanges(); String Path = System.Web.HttpContext.Current.Server.MapPath(@"~/App_Data/Template/emailtemplate.html"); EmailSender.SendEmail(bookingViewModel.FirstName, bookingViewModel.Email, bookingViewModel.FirstName, Path, booking.ZoomURL, booking.UTCStartTime.ToString(), booking.UTCEndTime.ToString()); ViewBag.Success = "Session Booked Succesfully."; } } else { ViewBag.ErrMessage = "You have already booking this Sessions."; bookingList = db.Booking.ToList(); bookingViewModel.ThreeHourWebiner = bookingList.Where(z => z.UTCStartTime.Date >= todaydate && z.UTCStartTime.Date <= week && z.SessionType == 1 && z.UserId == "67cb4926-6397-42b8-8bc5-ec85dd3ce2a7").ToList(); bookingViewModel.OneHourWebiner = bookingList.Where(z => z.UTCStartTime.Date >= todaydate && z.UTCStartTime.Date <= week && z.SessionType == 2 && z.UserId == "67cb4926-6397-42b8-8bc5-ec85dd3ce2a7").ToList(); bookingViewModel.TenMinuteWebiner = bookingList.Where(z => z.UTCStartTime.Date >= todaydate && z.UTCStartTime.Date <= week && z.SessionType == 3 && z.UserId == "67cb4926-6397-42b8-8bc5-ec85dd3ce2a7").ToList(); return(View(bookingViewModel)); } } bookingList = db.Booking.ToList(); bookingViewModel.ThreeHourWebiner = bookingList.Where(z => z.UTCStartTime.Date >= todaydate && z.UTCStartTime.Date <= week && z.SessionType == 1 && z.UserId == "67cb4926-6397-42b8-8bc5-ec85dd3ce2a7").ToList(); bookingViewModel.OneHourWebiner = bookingList.Where(z => z.UTCStartTime.Date >= todaydate && z.UTCStartTime.Date <= week && z.SessionType == 2 && z.UserId == "67cb4926-6397-42b8-8bc5-ec85dd3ce2a7").ToList(); bookingViewModel.TenMinuteWebiner = bookingList.Where(z => z.UTCStartTime.Date >= todaydate && z.UTCStartTime.Date <= week && z.SessionType == 3 && z.UserId == "67cb4926-6397-42b8-8bc5-ec85dd3ce2a7").ToList(); return(View(bookingViewModel)); }
/// <summary> /// Payment Deduct through Carditcard ID /// </summary> /// <param name="BookingID"></param> /// <returns></returns> public ActionResult PaypalValutthroughDeductPayment(int BookingID = 0) { if (BookingID != 0) { var db = GetDb(); String UserID = User.Identity.GetUserId(); PayPalbusinessLogic obj = new PayPalbusinessLogic(); // Token Get; string Token = PaypalConfiguration.GetAccessToken(); var UserAccountDetail = db.UserAccountDetail.Where(x => x.UserId == UserID && x.BookingID == BookingID).FirstOrDefault(); var response = obj.GetCraditCardPaypalValut(Token, UserAccountDetail.CraditcardID); var _AmountViewModel = (from ep in db.UserAccountDetail join e in db.Booking on ep.BookingID equals e.ID join see in db.SessionType on e.SessionType equals see.ID where ep.UserId == UserID && ep.BookingID == BookingID select new AmountViewModel { ID = ep.ID, Amount = see.Price, UserID = ep.UserId, CraditcardID = ep.CraditcardID, Email = ep.Email, BookingID = ep.BookingID, SessionType = e.SessionType, UserDetailID = ep.ID }).FirstOrDefault(); if (_AmountViewModel != null) { var PapalvalutAmountDeductResponse = obj.AmountDeduct(_AmountViewModel); if (PapalvalutAmountDeductResponse.state != "created") { PaymentDetails PaymentDetails = new PaymentDetails(); PaymentDetails.BookingID = _AmountViewModel.BookingID; PaymentDetails.Createddate = DateTime.Now; PaymentDetails.Updateddate = DateTime.Now; PaymentDetails.Status = "Success"; PaymentDetails.UserId = _AmountViewModel.UserID; PaymentDetails.TotalAmount = PapalvalutAmountDeductResponse.Amount; PaymentDetails.Intent = PapalvalutAmountDeductResponse.intent; PaymentDetails.ResponseID = PapalvalutAmountDeductResponse.id; PaymentDetails.UserDetailID = _AmountViewModel.UserDetailID; PaymentDetails.PaymentProcessed = true; db.PaymentDetail.Add(PaymentDetails); } } } return(View()); }