public ActionResult BookStep2(BookingModel model) { var selectedTimes = Request.Form["selectedTimes"].ToString(); BookingsListModel bookingsList = new BookingsListModel(); foreach (var selectedTime in selectedTimes.Split(',')) { if (!String.IsNullOrEmpty(selectedTime)) { var bookingAmount = Convert.ToInt32(selectedTime.Split('_')[0].ToString()); var requestedDate = Convert.ToDateTime(selectedTime.Split('_')[1].ToString()); var requestedTime = Convert.ToDateTime(selectedTime.Split('_')[2].ToString().Replace('-', ':')); var requestedDay = selectedTime.Split('_')[2].ToString(); model.bookingDate = new DateTime(requestedDate.Year, requestedDate.Month, requestedDate.Day, requestedTime.Hour, requestedTime.Minute, requestedTime.Second); model.bookingTime = new DateTime(requestedDate.Year, requestedDate.Month, requestedDate.Day, requestedTime.Hour, requestedTime.Minute, requestedTime.Second); model.bookingAmount = bookingAmount; model.serviceProviderId = Convert.ToInt32(Request.Form["serviceProviderId"]); model.serviceId = Convert.ToInt32(Request.Form["serviceId"]); int hours = TheRepository.GetMinHours(model.serviceProviderId, requestedDate.DayOfWeek.ToString()); int customerid = 0; if (TheRepository.GetCustomerByEmail(model.customer.emailAddress) == null) { var cust = TheRepository.CreateCustomer(model.customer); customerid = cust.id; } else { customerid = TheRepository.GetCustomerByEmail(model.customer.emailAddress).id; } model.customerId = customerid; model.bookingHours = hours; var newBooking = TheRepository.CreateBooking(model); int newBookingId = newBooking.id; if (newBooking != null) { foreach (var answer in model.additionalQuestionsList) { answer.customerId = customerid; answer.serviceId = model.serviceId; TheRepository.CreateAdditionalQuestions(answer); } } model.id = newBooking.id; } } List <BookingModel> bookings = new List <BookingModel>(); bookings = TheRepository.GetAllBookingsByCustomer(model.customerId); bookingsList.bookings = bookings.Where(a => a.bookingAccepted == false).ToList(); bookingsList.serviceProvider = TheRepository.GetServiceProvider(model.serviceProviderId); return(View("ConfirmPayment", bookingsList)); }
public IActionResult CustSignupProcess(CustomerModel model) { model.isActive = true; // should be after user has validated their email. but temp for now model.VerifyCode = Guid.NewGuid().ToString(); var exist = TheRepository.CheckEmailExist(model.emailAddress); if (exist) { TempData["exist"] = "Email Exists"; return(View("CustSignup", model)); } var customer = TheRepository.CreateCustomer(model); model.id = customer.id; model.emailConfirmed = false; model.isRegistrationApproved = false; model.createdDate = DateTime.Now; model.password = PasswordHash.PasswordHash.CreateHash(model.password).Replace("1000:", String.Empty); LoginModel login = new LoginModel { userName = model.emailAddress, password = model.password, userid = customer.id, createdDate = DateTime.Now }; var createdLogin = TheRepository.CreateLogin(login); var encryptedid = EncryptionUtility.Encrypt(createdLogin.id.ToString()); //Send an authorisation email to the customer EmailInfo emailInfo = new EmailInfo(); var callbackUrl = Url.Action("VerifyEmail", "CustomerSignup", new { userId = customer.id, code = model.VerifyCode }, Request.Scheme, Request.Host.Value + "/CustomerArea"); emailInfo.Body = $"Welcome from I NEED YOUR TIME. Click <a href='{callbackUrl}'>here</a> to confirm your email"; emailInfo.emailType = "WelcomeEmail"; emailInfo.IsBodyHtml = true; emailInfo.Subject = "Welcome to INYT"; emailInfo.ToAddress = model.emailAddress; //_emailManager.SendEmail(emailInfo); var model2 = new Emailmodel { Name = model.firstName, Body = emailInfo.Body }; var renderedHTML = ControllerExtensions.RenderViewAsHTMLString(this, "_VerifyEmail.cshtml", model2); EmailManager.SendEmail2(model.emailAddress, "VerifyAccount", renderedHTML.Result); //SendSimpleMessage(String.Format("<strong>Welcome from I NEED YOUR TIME. Click <a href='CustomerSignup/ConfirmEmail/{0}'>here</a> to confirm your email", "*****@*****.**"), encryptedid).Content.ToString(); //Send an email to the Administrator with the customer details //EmailInfo emailInfo = new EmailInfo(); emailInfo.Body = "New customer on INYT website"; emailInfo.emailType = "NewCustomerEmail"; emailInfo.IsBodyHtml = true; emailInfo.Subject = "New customer"; emailInfo.ToAddress = "*****@*****.**"; _emailManager.SendEmail(emailInfo); var model_admin = new Emailmodel { Name = model.firstName, Body = emailInfo.Body }; var renderedHTMLAdmin = ControllerExtensions.RenderViewAsHTMLString(this, "_AdminEmail.cshtml", model_admin); EmailManager.SendEmail2(model.emailAddress, "VerifyAccount", renderedHTMLAdmin.Result); //SendSimpleMessage("New customer on INYT website", "*****@*****.**").Content.ToString(); return(View(model)); }