public ActionResult OnceOff() { var onceOffRequest = new PayFastRequest(this.payFastSettings.PassPhrase); int ReservationID = int.Parse(Session["bookID"].ToString()); RoomBooking roomBooking = new RoomBooking(); roomBooking = db.RoomBookings.Find(ReservationID); var userName = User.Identity.GetUserName(); var guest = db.guests.Where(x => x.Email == userName).FirstOrDefault(); var attachments = new List <Attachment>(); attachments.Add(new Attachment(new MemoryStream(GeneratePDF(ReservationID)), "Reservation Receipt", "application/pdf")); var mailTo = new List <MailAddress>(); mailTo.Add(new MailAddress(User.Identity.GetUserName(), guest.FullName)); var body = $"Hello {guest.FullName}, please see attached receipt for the recent reservation you made. <br/>Make sure you bring along your receipt when you check in for your room.<br/>"; ExploreBookings.Models.EmailService emailService = new ExploreBookings.Models.EmailService(); emailService.SendEmail(new EmailContent() { mailTo = mailTo, mailCc = new List <MailAddress>(), mailSubject = "Application Statement | Ref No.:" + roomBooking.RoomBookingId, mailBody = body, mailFooter = "<br/> Many Thanks, <br/> <b>Explorer</b>", mailPriority = MailPriority.High, mailAttachments = attachments }); // Merchant Details onceOffRequest.merchant_id = this.payFastSettings.MerchantId; onceOffRequest.merchant_key = this.payFastSettings.MerchantKey; onceOffRequest.return_url = this.payFastSettings.ReturnUrl; onceOffRequest.cancel_url = this.payFastSettings.CancelUrl; onceOffRequest.notify_url = this.payFastSettings.NotifyUrl; // Buyer Details onceOffRequest.email_address = "*****@*****.**"; //onceOffRequest.email_address = "*****@*****.**"; // Transaction Details onceOffRequest.m_payment_id = ""; onceOffRequest.amount = Convert.ToDouble(roomBooking.Total); onceOffRequest.item_name = "Room Booking payment"; onceOffRequest.item_description = "Some details about the once off payment"; BusinessLogic.UpdateRoomsAvailable(roomBooking.RoomId); // Transaction Options onceOffRequest.email_confirmation = true; onceOffRequest.confirmation_address = "*****@*****.**"; var redirectUrl = $"{this.payFastSettings.ProcessUrl}{onceOffRequest.ToString()}"; return(Redirect(redirectUrl)); }
public async Task <ActionResult> HotelManagerRegister(RegisterViewModel model) { if (ModelState.IsValid) { string pwd = "@User001"; var user = new ApplicationUser { UserName = model.Email, Email = model.Email }; var result = await UserManager.CreateAsync(user, pwd); if (result.Succeeded) { model.Password = pwd; model.ConfirmPassword = pwd; HotelManager hotelManager = new HotelManager(); hotelManager.FullName = model.FullName; hotelManager.LastName = model.LastName; hotelManager.Phone = model.Phone; hotelManager.Gender = model.Gender; hotelManager.Address = model.Address; hotelManager.UserId = user.Id; hotelManager.Email = model.Email; db.hotelManagers.Add(hotelManager); db.SaveChanges(); string code = await UserManager.GenerateEmailConfirmationTokenAsync(user.Id); var callbackUrl = Url.Action("ConfirmEmail", "Users", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme); var mailTo = new List <MailAddress>(); mailTo.Add(new MailAddress(model.Email, model.FullName)); var body = $"Hello {model.FullName}, Explorer Team has created an account on your behalf as a Manager. <br/><br/>Your login credentials are as follows<br/><br/>" + "Email (Username) : " + model.Email + "<br/>Password : "******"<br/><br/> " + "Please confirm your account by clicking <a href=\"" + callbackUrl + "\">here</a>"; ExploreBookings.Models.EmailService emailService = new ExploreBookings.Models.EmailService(); emailService.SendEmail(new EmailContent() { mailTo = mailTo, mailCc = new List <MailAddress>(), mailSubject = "Confirm your account", mailBody = body, mailFooter = "<br/> Many Thanks, <br/> <b>The Explorer Team</b>", mailPriority = MailPriority.High, mailAttachments = new List <Attachment>() }); //await SignInManager.SignInAsync(user, isPersistent: false, rememberBrowser: false); // For more information on how to enable account confirmation and password reset please visit https://go.microsoft.com/fwlink/?LinkID=320771 // Send an email with this link // string code = await UserManager.GenerateEmailConfirmationTokenAsync(user.Id); // var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme); // await UserManager.SendEmailAsync(user.Id, "Confirm your account", "Please confirm your account by clicking <a href=\"" + callbackUrl + "\">here</a>"); UserManager.AddToRole(user.Id, "HotelManager"); TempData["AlertMessage"] = "Manager Added Successfully"; return(RedirectToAction("Index", "HotelManagers")); } AddErrors(result); } // If we got this far, something failed, redisplay form return(View(model)); }