public string CreateScheduleEmail(int weekNumber) { var factory = new ScheduleEmailModelFactory(_dbFactory); var templatePath = HttpContext.Current.Server.MapPath("~/Static/PrintSchedule.cshtml"); //var templatePath = HttpContext.Current.Server.MapPath("~/Views/Main/PrintSchedule.cshtml"); using (var templater = new IsolatedRazor.RazorTemplater(templatePath)) { var emailContent = templater.ParseAsync(PrintSchedule, File.ReadAllText(templatePath), DateTime.Now, factory.Get(weekNumber)).Result; return emailContent; } //var configuration = new TemplateServiceConfiguration() //{ // // setting up our custom template manager so we map files on demand // TemplateManager = new SimpleTemplateManager() //}; //var service = RazorEngineService.Create(configuration); //var template = File.ReadAllText(HttpContext.Current.Server.MapPath("~/Views/Main/PrintSchedule.cshtml")); //var model = new MainController.PrintScheduleViewModel() {Schedule = schedule, SelectedRecipes = selectedRecipes}; //var emailContent = service.RunCompile(template, PrintSchedule, model.GetType(), model); ////var emailContent = Engine.Razor.Run(PrintSchedule, null, new MainController.PrintScheduleViewModel() {Schedule = schedule, SelectedRecipes = selectedRecipes}); //return emailContent; }
public ActionResult PrintSchedule(int weekNumber) { var factory = new ScheduleEmailModelFactory(_dbFactory); return View(factory.Get(weekNumber)); }