Esempio n. 1
0
 public string ParseTemplate(string templateText, UserModel userModel)
 {
     if (!_initialized)
     {
         HostingEnvironment.RegisterVirtualPathProvider(new RazorVirtualPathProvider());
         _initialized = true;
     }
     var model = GenerateModel(userModel);
     return Razor.Parse(templateText, model);
 }
Esempio n. 2
0
 public dynamic GenerateModel(UserModel userModel)
 {
     var date = DateTime.Now;
     return new
                {
                    month = date.ToString("MMM"),
                    day = date.Day,
                    year = date.ToString("yyyy"),
                    effectiveDate = date.ToString("MMM dd, yyyy"),
                    Customer = userModel.Name,
                    Address = "210 N 5th Ave Fargo, ND 58103",
                    Contact = "Mr. Important Guy",
                    fax = "701-203-5689",
                    Buyer = "Nick Swardson",
                    userModel.Commitments,
                    userModel.Prices
                };
 }
        private UserModel GenerateModel()
        {
            var model = new UserModel { Name = User.Identity.Name };
            model.Commitments.Add(new QuarterlyCommitment { QuantityOfSugar = 250000, Quarter = "1/1/2009 – 3/31/2009" });
            model.Commitments.Add(new QuarterlyCommitment { QuantityOfSugar = 250000, Quarter = "3/1/2009 – 6/30/2009" });
            model.Commitments.Add(new QuarterlyCommitment { QuantityOfSugar = 250000, Quarter = "7/1/2009 – 9/30/2009" });
            model.Commitments.Add(new QuarterlyCommitment { QuantityOfSugar = 750000, Quarter = "10/1/2009 – 12/31/2009" });

            model.Prices.Add(new Price {DeliveryLocation = "RRV", UnitPrice = 34.00m, Mode = Mode.Magic, PackageSizeAndType = "cwt", State = "MN", TotalPrice = 340.00m});
            model.Prices.Add(new Price { DeliveryLocation = "RRV", UnitPrice = 35.00m, Mode = Mode.Offline, PackageSizeAndType = "cwt", State = "WY", TotalPrice = 350.00m });
            model.Prices.Add(new Price { DeliveryLocation = "RRV", UnitPrice = 35.00m, Mode = Mode.Magic, PackageSizeAndType = "cwt", State = "ND", TotalPrice = 350.00m });
            model.Prices.Add(new Price { DeliveryLocation = "RRV", UnitPrice = 34.00m, Mode = Mode.Online, PackageSizeAndType = "cwt", State = "MN", TotalPrice = 340.00m });

            return model;
        }