Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Globalization;
- using System.IO;
- using System.Linq;
- using System.Threading.Tasks;
- using System.Web;
- using System.Web.Hosting;
- using System.Web.Mvc;
- using thePure5.Models;
- namespace thePure5.Controllers
- {
- public class OrderNowController : Controller
- {
- //// GET: OrderNow
- //public ActionResult Index()
- //{
- // return View();
- //}
- public ActionResult OrderNow()
- {
- return View();
- }
- public static async Task<string> OrderTemplate(string template)
- {
- var templateFilePath = HostingEnvironment.MapPath("~/Content/orderTemplate/") + template + ".cshtml";
- StreamReader objstreamrederfile = new StreamReader(templateFilePath);
- var body = await objstreamrederfile.ReadToEndAsync();
- objstreamrederfile.Close();
- return body;
- }
- [HttpPost]
- [AllowAnonymous]
- public async Task<ActionResult> OrderNow(OrderNowViewModel model)
- {
- if (ModelState.IsValid)
- {
- var message = await OrderTemplate("orderNowTemplate");
- message = message.Replace("@ViewBag.Name", CultureInfo.CurrentCulture.TextInfo.ToTitleCase(model.Name));
- message = message.Replace("@ViewBag.Company", CultureInfo.CurrentCulture.TextInfo.ToTitleCase(model.Company));
- message = message.Replace("@ViewBag.Company", CultureInfo.CurrentCulture.TextInfo.ToTitleCase(model.Adress));
- message = message.Replace("@ViewBag.Email", CultureInfo.CurrentCulture.TextInfo.ToTitleCase(model.YourEmail));
- message = message.Replace("@ViewBag.YourPhone", CultureInfo.CurrentCulture.TextInfo.ToTitleCase(model.YourPhone));
- message = message.Replace("@ViewBag.Type", CultureInfo.CurrentCulture.TextInfo.ToTitleCase(model.Type));
- message = message.Replace("@ViewBag.MonthlyVolume", CultureInfo.CurrentCulture.TextInfo.ToTitleCase(model.MonthlyVolume));
- message = message.Replace("@ViewBag.Quantity", CultureInfo.CurrentCulture.TextInfo.ToTitleCase(model.Quantity));
- message = message.Replace("@ViewBag.YourMsg", CultureInfo.CurrentCulture.TextInfo.ToTitleCase(model.YourMsg));
- await OrderServices.OrderNowAsync(model.YourEmail, "Hello! I want to order !", message);
- ModelState.Clear();
- return View("OrderSent");
- }
- return Redirect(Request.UrlReferrer.ToString());
- }
- public ActionResult OrderSent()
- {
- return View();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement