public JsonResult GetCityStateInfoBasedOnZipcode(string inputzipcode) { var zipcodeResult = _zipCodeService.GetZipCodeDetailByZipcode(inputzipcode); //return songList; return(Json(zipcodeResult, JsonRequestBehavior.AllowGet)); }
public int SendOrderPlacedCustomerNotification(GutterCleanOrder order) { string mailBody = System.IO.File.ReadAllText(_webHelper.MapPath("~/EmailTemplates/OrderPlacedCustomerNotification.htm")); var zipcodedetail = _zipCodeService.GetZipCodeDetailByZipcode(order.Zipcode); var r = _questionAnswerEntityDataService.StyleOfGuttersAnswer().Where(i => i.Value == order.QuestionStyleOfGutter).SingleOrDefault(); var year = _questionAnswerEntityDataService.YearBuiltAnswer().Where(i => i.Value == order.QuestionYearBuilt.ToString()).SingleOrDefault(); string OrderURLForCustomer = string.Format("{0}order-details/{1}", GetSiteUrl(), order.Id); mailBody = mailBody.Replace("%Order.OrderURLForCustomer%", OrderURLForCustomer); mailBody = mailBody.Replace("%customerfullname%", order.Customer.FirstName + " " + order.Customer.LastName); mailBody = mailBody.Replace("%orderid%", order.Id.ToString()); mailBody = mailBody.Replace("%createddate%", _dateTimeHelper.ConvertToUserTime(order.CreatedOnUtc, DateTimeKind.Utc).ToString()); mailBody = mailBody.Replace("%completiondate%", ""); mailBody = mailBody.Replace("%ordertotal%", string.Format("{0:C}", order.OrderTotal)); mailBody = mailBody.Replace("%street%", order.Address); if (zipcodedetail != null) { mailBody = mailBody.Replace("%citystate%", zipcodedetail.CityName + ", " + zipcodedetail.StateName); } else { mailBody = mailBody.Replace("%citystate%", ""); } mailBody = mailBody.Replace("%zipcode%", order.Zipcode); mailBody = mailBody.Replace("%squarefootage%", order.QuestionSquareFootage.ToString()); mailBody = mailBody.Replace("%styleofgutters%", r.Text); mailBody = mailBody.Replace("%yearbuilt%", year.Text); mailBody = mailBody.Replace("%roofmaterial%", order.RoofMaterial); mailBody = mailBody.Replace("%siteurl%", _siteSetting.SiteUrl); mailBody = mailBody.Replace("%customeremail%", order.Customer.Email); EmailAccess.SendMail(_siteSetting.SenderEmail, _siteSetting.SenderName, order.Customer.Email, "", "", mailBody, "Eric's Gutter Cleaning Request | Order #: " + order.Id); return(1); }
public ActionResult GutterCleanInfoRegister(GutterCleanInfoModel model, bool captchaValid) { GutterCleanRequestModel requestModel = _httpContext.Session["GutterCleanRequestModel"] as GutterCleanRequestModel; if (requestModel == null) { return(RedirectToRoute("GutterCleanRequest")); } string returnUrl = string.Empty; if (!captchaValid) { ModelState.AddModelError("", "Wrong Captcha code."); } var zipcodeResult = _zipCodeService.GetZipCodeDetailByZipcode(model.ZipCode); if (zipcodeResult != null) { } else { ModelState.AddModelError("", "Zipcode is not valid."); } if (ModelState.IsValid) { if (!_workContext.CurrentCustomer.IsRegistered()) { //Already registered customer. _authenticationService.SignOut(); //Save a new record _workContext.CurrentCustomer = _customerService.InsertGuestCustomer(); var customer = _workContext.CurrentCustomer; customer.FirstName = model.FirstName; customer.LastName = model.LastName; customer.Address1 = model.Address; customer.ZipPostalCode = model.ZipCode; bool isApproved = true; string password = Guid.NewGuid().ToString(); var registrationRequest = new CustomerRegistrationRequest(customer, model.Email, password.Substring(0, 8), isApproved); var registrationResult = _customerService.RegisterCustomer(registrationRequest); if (registrationResult.Success) { //login customer now if (isApproved) { _authenticationService.SignIn(customer, true); } switch (UserRegistrationType.Standard) { case UserRegistrationType.Standard: { var address = new Address(); address.Address1 = model.Address; address.Address2 = ""; address.City = zipcodeResult.CityName; address.Email = model.Email; address.State = zipcodeResult.StateName; address.PhoneNumber = ""; address.ZipPostalCode = model.ZipCode; address.CreatedOnUtc = DateTime.UtcNow; customer.Addresses.Add(address); _customerService.UpdateCustomer(customer); //send email _workflowMessageService.SendCustomerWelcomeMessage(customer); GutterCleanRequestModel Requestmodel = _httpContext.Session["GutterCleanRequestModel"] as GutterCleanRequestModel; if (Requestmodel == null) { return(RedirectToRoute("GutterCleanRequest")); } else { return(RedirectToRoute("ProcessPayment")); } } default: { return(RedirectToRoute("GutterCleanRequest")); } } } //errors foreach (var error in registrationResult.Errors) { ModelState.AddModelError("", error); } } else { /// user is already registered return(RedirectToRoute("ProcessPayment")); } } // If we got this far, something failed, redisplay form return(View(model)); }