diff --git a/aspclassiccompiler/DLRSoft.Examples.NerdDinnerApp/Controllers/DinnersController.cs b/aspclassiccompiler/DLRSoft.Examples.NerdDinnerApp/Controllers/DinnersController.cs index 95306e7..381f465 100644 --- a/aspclassiccompiler/DLRSoft.Examples.NerdDinnerApp/Controllers/DinnersController.cs +++ b/aspclassiccompiler/DLRSoft.Examples.NerdDinnerApp/Controllers/DinnersController.cs @@ -1,189 +1,189 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Web.Mvc; -using NerdDinner.Helpers; -using NerdDinner.Models; - -namespace NerdDinner.Controllers { - - // - // ViewModel Classes - - public class DinnerFormViewModel { - - // Properties - public Dinner Dinner { get; private set; } - public SelectList Countries { get; private set; } - - // Constructor - public DinnerFormViewModel(Dinner dinner) { - Dinner = dinner; - Countries = new SelectList(PhoneValidator.Countries, Dinner.Country); - } - } - - // - // Controller Class - - [HandleError] - public class DinnersController : Controller { - - IDinnerRepository dinnerRepository; - - // - // Dependency Injection enabled constructors - - public DinnersController() - : this(new DinnerRepository()) { - } - - public DinnersController(IDinnerRepository repository) { - dinnerRepository = repository; - } - - // - // GET: /Dinners/ - // /Dinners/Page/2 - - public ActionResult Index(int? page) { - - const int pageSize = 10; - - var upcomingDinners = dinnerRepository.FindUpcomingDinners(); - var paginatedDinners = new PaginatedList(upcomingDinners, page ?? 0, pageSize); - - return View(paginatedDinners); - } - - // - // GET: /Dinners/Details/5 - - public ActionResult Details(int id) { - - Dinner dinner = dinnerRepository.GetDinner(id); - - if (dinner == null) - return View("NotFound"); - - return View(dinner); - } - - // - // GET: /Dinners/Edit/5 - - [Authorize] - public ActionResult Edit(int id) { - - Dinner dinner = dinnerRepository.GetDinner(id); - - if (!dinner.IsHostedBy(User.Identity.Name)) - return View("InvalidOwner"); - - return View(new DinnerFormViewModel(dinner)); - } - - // - // POST: /Dinners/Edit/5 - - [AcceptVerbs(HttpVerbs.Post), Authorize] - public ActionResult Edit(int id, FormCollection collection) { - - Dinner dinner = dinnerRepository.GetDinner(id); - - if (!dinner.IsHostedBy(User.Identity.Name)) - return View("InvalidOwner"); - - try { - UpdateModel(dinner); - - dinnerRepository.Save(); - - return RedirectToAction("Details", new { id=dinner.DinnerID }); - } - catch { - ModelState.AddModelErrors(dinner.GetRuleViolations()); - - return View(new DinnerFormViewModel(dinner)); - } - } - - // - // GET: /Dinners/Create - - [Authorize] - public ActionResult Create() { - - Dinner dinner = new Dinner() { - EventDate = DateTime.Now.AddDays(7) - }; - - return View(new DinnerFormViewModel(dinner)); - } - - // - // POST: /Dinners/Create - - [AcceptVerbs(HttpVerbs.Post), Authorize] - public ActionResult Create(Dinner dinner) { - - if (ModelState.IsValid) { - - try { - dinner.HostedBy = User.Identity.Name; - - RSVP rsvp = new RSVP(); - rsvp.AttendeeName = User.Identity.Name; - dinner.RSVPs.Add(rsvp); - - dinnerRepository.Add(dinner); - dinnerRepository.Save(); - - return RedirectToAction("Details", new { id=dinner.DinnerID }); - } - catch { - ModelState.AddModelErrors(dinner.GetRuleViolations()); - } - } - - return View(new DinnerFormViewModel(dinner)); - } - - // - // HTTP GET: /Dinners/Delete/1 - - [Authorize] - public ActionResult Delete(int id) { - - Dinner dinner = dinnerRepository.GetDinner(id); - - if (dinner == null) - return View("NotFound"); - - if (!dinner.IsHostedBy(User.Identity.Name)) - return View("InvalidOwner"); - - return View(dinner); - } - - // - // HTTP POST: /Dinners/Delete/1 - - [AcceptVerbs(HttpVerbs.Post), Authorize] - public ActionResult Delete(int id, string confirmButton) { - - Dinner dinner = dinnerRepository.GetDinner(id); - - if (dinner == null) - return View("NotFound"); - - if (!dinner.IsHostedBy(User.Identity.Name)) - return View("InvalidOwner"); - - dinnerRepository.Delete(dinner); - dinnerRepository.Save(); - - return View("Deleted"); - } - } -} +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web.Mvc; +using NerdDinner.Helpers; +using NerdDinner.Models; + +namespace NerdDinner.Controllers { + + // + // ViewModel Classes + + public class DinnerFormViewModel { + + // Properties + public Dinner Dinner { get; private set; } + public SelectList Countries { get; private set; } + + // Constructor + public DinnerFormViewModel(Dinner dinner) { + Dinner = dinner; + Countries = new SelectList(PhoneValidator.Countries, Dinner.Country); + } + } + + // + // Controller Class + + [HandleError] + public class DinnersController : Controller { + + IDinnerRepository dinnerRepository; + + // + // Dependency Injection enabled constructors + + public DinnersController() + : this(new DinnerRepository()) { + } + + public DinnersController(IDinnerRepository repository) { + dinnerRepository = repository; + } + + // + // GET: /Dinners/ + // /Dinners/Page/2 + + public ActionResult Index(int? page) { + + const int pageSize = 10; + + var upcomingDinners = dinnerRepository.FindUpcomingDinners(); + var paginatedDinners = new PaginatedList(upcomingDinners, page ?? 0, pageSize); + + return View(paginatedDinners); + } + + // + // GET: /Dinners/Details/5 + + public ActionResult Details(int id) { + + Dinner dinner = dinnerRepository.GetDinner(id); + + if (dinner == null) + return View("NotFound"); + + return View(dinner); + } + + // + // GET: /Dinners/Edit/5 + + [Authorize] + public ActionResult Edit(int id) { + + Dinner dinner = dinnerRepository.GetDinner(id); + + if (!dinner.IsHostedBy(User.Identity.Name)) + return View("InvalidOwner"); + + return View(new DinnerFormViewModel(dinner)); + } + + // + // POST: /Dinners/Edit/5 + + [AcceptVerbs(HttpVerbs.Post), Authorize] + public ActionResult Edit(int id, FormCollection collection) { + + Dinner dinner = dinnerRepository.GetDinner(id); + + if (!dinner.IsHostedBy(User.Identity.Name)) + return View("InvalidOwner"); + + try { + UpdateModel(dinner); + + dinnerRepository.Save(); + + return RedirectToAction("Details", new { id=dinner.DinnerID }); + } + catch { + ModelState.AddModelErrors(dinner.GetRuleViolations()); + + return View(new DinnerFormViewModel(dinner)); + } + } + + // + // GET: /Dinners/Create + + [Authorize] + public ActionResult Create() { + + Dinner dinner = new Dinner() { + EventDate = DateTime.Now.AddDays(7) + }; + + return View(new DinnerFormViewModel(dinner)); + } + + // + // POST: /Dinners/Create + + [AcceptVerbs(HttpVerbs.Post), Authorize] + public ActionResult Create(Dinner dinner) { + + if (ModelState.IsValid) { + + try { + dinner.HostedBy = User.Identity.Name; + + RSVP rsvp = new RSVP(); + rsvp.AttendeeName = User.Identity.Name; + dinner.RSVPs.Add(rsvp); + + dinnerRepository.Add(dinner); + dinnerRepository.Save(); + + return RedirectToAction("Details", new { id=dinner.DinnerID }); + } + catch { + ModelState.AddModelErrors(dinner.GetRuleViolations()); + } + } + + return View(new DinnerFormViewModel(dinner)); + } + + // + // HTTP GET: /Dinners/Delete/1 + + [Authorize] + public ActionResult Delete(int id) { + + Dinner dinner = dinnerRepository.GetDinner(id); + + if (dinner == null) + return View("NotFound"); + + if (!dinner.IsHostedBy(User.Identity.Name)) + return View("InvalidOwner"); + + return View(dinner); + } + + // + // HTTP POST: /Dinners/Delete/1 + + [AcceptVerbs(HttpVerbs.Post), Authorize] + public ActionResult Delete(int id, string confirmButton) { + + Dinner dinner = dinnerRepository.GetDinner(id); + + if (dinner == null) + return View("NotFound"); + + if (!dinner.IsHostedBy(User.Identity.Name)) + return View("InvalidOwner"); + + dinnerRepository.Delete(dinner); + dinnerRepository.Save(); + + return View("Deleted"); + } + } +} diff --git a/aspclassiccompiler/DLRSoft.Examples.NerdDinnerApp/Controllers/HomeController.cs b/aspclassiccompiler/DLRSoft.Examples.NerdDinnerApp/Controllers/HomeController.cs index b0105a7..8b52b8d 100644 --- a/aspclassiccompiler/DLRSoft.Examples.NerdDinnerApp/Controllers/HomeController.cs +++ b/aspclassiccompiler/DLRSoft.Examples.NerdDinnerApp/Controllers/HomeController.cs @@ -1,20 +1,20 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Web; -using System.Web.Mvc; - -namespace NerdDinner.Controllers { - - [HandleError] - public class HomeController : Controller { - - public ActionResult Index() { - return View(); - } - - public ActionResult About() { - return View(); - } - } -} +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; +using System.Web.Mvc; + +namespace NerdDinner.Controllers { + + [HandleError] + public class HomeController : Controller { + + public ActionResult Index() { + return View(); + } + + public ActionResult About() { + return View(); + } + } +} diff --git a/aspclassiccompiler/DLRSoft.Examples.NerdDinnerApp/Controllers/RSVPController.cs b/aspclassiccompiler/DLRSoft.Examples.NerdDinnerApp/Controllers/RSVPController.cs index 1c01d4f..7b71cb9 100644 --- a/aspclassiccompiler/DLRSoft.Examples.NerdDinnerApp/Controllers/RSVPController.cs +++ b/aspclassiccompiler/DLRSoft.Examples.NerdDinnerApp/Controllers/RSVPController.cs @@ -1,45 +1,45 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Web; -using System.Web.Mvc; -using NerdDinner.Models; - -namespace NerdDinner.Controllers -{ - public class RSVPController : Controller { - - IDinnerRepository dinnerRepository; - - // - // Dependency Injection enabled constructors - - public RSVPController() - : this(new DinnerRepository()) { - } - - public RSVPController(IDinnerRepository repository) { - dinnerRepository = repository; - } - - // - // AJAX: /Dinners/Register/1 - - [Authorize, AcceptVerbs(HttpVerbs.Post)] - public ActionResult Register(int id) { - - Dinner dinner = dinnerRepository.GetDinner(id); - - if (!dinner.IsUserRegistered(User.Identity.Name)) { - - RSVP rsvp = new RSVP(); - rsvp.AttendeeName = User.Identity.Name; - - dinner.RSVPs.Add(rsvp); - dinnerRepository.Save(); - } - - return Content("Thanks - we'll see you there!"); - } - } -} +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; +using System.Web.Mvc; +using NerdDinner.Models; + +namespace NerdDinner.Controllers +{ + public class RSVPController : Controller { + + IDinnerRepository dinnerRepository; + + // + // Dependency Injection enabled constructors + + public RSVPController() + : this(new DinnerRepository()) { + } + + public RSVPController(IDinnerRepository repository) { + dinnerRepository = repository; + } + + // + // AJAX: /Dinners/Register/1 + + [Authorize, AcceptVerbs(HttpVerbs.Post)] + public ActionResult Register(int id) { + + Dinner dinner = dinnerRepository.GetDinner(id); + + if (!dinner.IsUserRegistered(User.Identity.Name)) { + + RSVP rsvp = new RSVP(); + rsvp.AttendeeName = User.Identity.Name; + + dinner.RSVPs.Add(rsvp); + dinnerRepository.Save(); + } + + return Content("Thanks - we'll see you there!"); + } + } +} diff --git a/aspclassiccompiler/DLRSoft.Examples.NerdDinnerApp/Controllers/SearchController.cs b/aspclassiccompiler/DLRSoft.Examples.NerdDinnerApp/Controllers/SearchController.cs index 0431aa2..fb782a8 100644 --- a/aspclassiccompiler/DLRSoft.Examples.NerdDinnerApp/Controllers/SearchController.cs +++ b/aspclassiccompiler/DLRSoft.Examples.NerdDinnerApp/Controllers/SearchController.cs @@ -1,55 +1,55 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Web; -using System.Web.Mvc; -using NerdDinner.Models; - -namespace NerdDinner.Controllers { - - public class JsonDinner { - public int DinnerID { get; set; } - public string Title { get; set; } - public double Latitude { get; set; } - public double Longitude { get; set; } - public string Description { get; set; } - public int RSVPCount { get; set; } - } - - public class SearchController : Controller { - - IDinnerRepository dinnerRepository; - - // - // Dependency Injection enabled constructors - - public SearchController() - : this(new DinnerRepository()) { - } - - public SearchController(IDinnerRepository repository) { - dinnerRepository = repository; - } - - // - // AJAX: /Search/FindByLocation?longitude=45&latitude=-90 - - [AcceptVerbs(HttpVerbs.Post)] - public ActionResult SearchByLocation(float latitude, float longitude) { - - var dinners = dinnerRepository.FindByLocation(latitude, longitude); - - var jsonDinners = from dinner in dinners - select new JsonDinner { - DinnerID = dinner.DinnerID, - Latitude = dinner.Latitude, - Longitude = dinner.Longitude, - Title = dinner.Title, - Description = dinner.Description, - RSVPCount = dinner.RSVPs.Count - }; - - return Json(jsonDinners.ToList()); - } - } -} +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; +using System.Web.Mvc; +using NerdDinner.Models; + +namespace NerdDinner.Controllers { + + public class JsonDinner { + public int DinnerID { get; set; } + public string Title { get; set; } + public double Latitude { get; set; } + public double Longitude { get; set; } + public string Description { get; set; } + public int RSVPCount { get; set; } + } + + public class SearchController : Controller { + + IDinnerRepository dinnerRepository; + + // + // Dependency Injection enabled constructors + + public SearchController() + : this(new DinnerRepository()) { + } + + public SearchController(IDinnerRepository repository) { + dinnerRepository = repository; + } + + // + // AJAX: /Search/FindByLocation?longitude=45&latitude=-90 + + [AcceptVerbs(HttpVerbs.Post)] + public ActionResult SearchByLocation(float latitude, float longitude) { + + var dinners = dinnerRepository.FindByLocation(latitude, longitude); + + var jsonDinners = from dinner in dinners + select new JsonDinner { + DinnerID = dinner.DinnerID, + Latitude = dinner.Latitude, + Longitude = dinner.Longitude, + Title = dinner.Title, + Description = dinner.Description, + RSVPCount = dinner.RSVPs.Count + }; + + return Json(jsonDinners.ToList()); + } + } +} diff --git a/aspclassiccompiler/DLRSoft.Examples.NerdDinnerApp/Default.aspx.cs b/aspclassiccompiler/DLRSoft.Examples.NerdDinnerApp/Default.aspx.cs index 24e1def..16a8f6e 100644 --- a/aspclassiccompiler/DLRSoft.Examples.NerdDinnerApp/Default.aspx.cs +++ b/aspclassiccompiler/DLRSoft.Examples.NerdDinnerApp/Default.aspx.cs @@ -1,13 +1,13 @@ -using System.Web; -using System.Web.Mvc; -using System.Web.UI; - -namespace NerdDinner { - public partial class _Default : Page { - public void Page_Load(object sender, System.EventArgs e) { - HttpContext.Current.RewritePath(Request.ApplicationPath, false); - IHttpHandler httpHandler = new MvcHttpHandler(); - httpHandler.ProcessRequest(HttpContext.Current); - } - } -} +using System.Web; +using System.Web.Mvc; +using System.Web.UI; + +namespace NerdDinner { + public partial class _Default : Page { + public void Page_Load(object sender, System.EventArgs e) { + HttpContext.Current.RewritePath(Request.ApplicationPath, false); + IHttpHandler httpHandler = new MvcHttpHandler(); + httpHandler.ProcessRequest(HttpContext.Current); + } + } +} diff --git a/aspclassiccompiler/DLRSoft.Examples.NerdDinnerApp/Global.asax.cs b/aspclassiccompiler/DLRSoft.Examples.NerdDinnerApp/Global.asax.cs index 2d620c4..961c768 100644 --- a/aspclassiccompiler/DLRSoft.Examples.NerdDinnerApp/Global.asax.cs +++ b/aspclassiccompiler/DLRSoft.Examples.NerdDinnerApp/Global.asax.cs @@ -1,37 +1,37 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Web; -using System.Web.Mvc; -using System.Web.Routing; -using Dlrsoft.Asp.Mvc; - -namespace NerdDinner { - - public class MvcApplication : System.Web.HttpApplication { - - public void RegisterRoutes(RouteCollection routes) { - - routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); - - routes.MapRoute( - "UpcomingDinners", - "Dinners/Page/{page}", - new { controller = "Dinners", action = "Index" } - ); - - routes.MapRoute( - "Default", // Route name - "{controller}/{action}/{id}", // URL with parameters - new { controller = "Home", action = "Index", id = "" } // Parameter defaults - ); - } - - void Application_Start() { - RegisterRoutes(RouteTable.Routes); - ViewEngines.Engines.Clear(); - ViewEngines.Engines.Add(new AspViewEngine()); - ViewEngines.Engines.Add(new WebFormViewEngine()); - } - } +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; +using System.Web.Mvc; +using System.Web.Routing; +using Dlrsoft.Asp.Mvc; + +namespace NerdDinner { + + public class MvcApplication : System.Web.HttpApplication { + + public void RegisterRoutes(RouteCollection routes) { + + routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); + + routes.MapRoute( + "UpcomingDinners", + "Dinners/Page/{page}", + new { controller = "Dinners", action = "Index" } + ); + + routes.MapRoute( + "Default", // Route name + "{controller}/{action}/{id}", // URL with parameters + new { controller = "Home", action = "Index", id = "" } // Parameter defaults + ); + } + + void Application_Start() { + RegisterRoutes(RouteTable.Routes); + ViewEngines.Engines.Clear(); + ViewEngines.Engines.Add(new AspViewEngine()); + ViewEngines.Engines.Add(new WebFormViewEngine()); + } + } } \ No newline at end of file diff --git a/aspclassiccompiler/DLRSoft.Examples.NerdDinnerApp/Helpers/ControllerHelpers.cs b/aspclassiccompiler/DLRSoft.Examples.NerdDinnerApp/Helpers/ControllerHelpers.cs index 080a00e..ea6b24e 100644 --- a/aspclassiccompiler/DLRSoft.Examples.NerdDinnerApp/Helpers/ControllerHelpers.cs +++ b/aspclassiccompiler/DLRSoft.Examples.NerdDinnerApp/Helpers/ControllerHelpers.cs @@ -1,19 +1,19 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Web; -using NerdDinner.Models; -using System.Web.Mvc; - -namespace NerdDinner.Helpers { - - public static class ModelStateHelpers { - - public static void AddModelErrors(this ModelStateDictionary modelState, IEnumerable errors) { - - foreach (RuleViolation issue in errors) { - modelState.AddModelError(issue.PropertyName, issue.ErrorMessage); - } - } - } -} +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; +using NerdDinner.Models; +using System.Web.Mvc; + +namespace NerdDinner.Helpers { + + public static class ModelStateHelpers { + + public static void AddModelErrors(this ModelStateDictionary modelState, IEnumerable errors) { + + foreach (RuleViolation issue in errors) { + modelState.AddModelError(issue.PropertyName, issue.ErrorMessage); + } + } + } +} diff --git a/aspclassiccompiler/DLRSoft.Examples.NerdDinnerApp/Helpers/PaginatedList.cs b/aspclassiccompiler/DLRSoft.Examples.NerdDinnerApp/Helpers/PaginatedList.cs index b0d4ddc..e8c3dbc 100644 --- a/aspclassiccompiler/DLRSoft.Examples.NerdDinnerApp/Helpers/PaginatedList.cs +++ b/aspclassiccompiler/DLRSoft.Examples.NerdDinnerApp/Helpers/PaginatedList.cs @@ -1,35 +1,35 @@ -using System; -using System.Collections.Generic; -using System.Linq; - -namespace NerdDinner.Helpers { - - public class PaginatedList : List { - - public int PageIndex { get; private set; } - public int PageSize { get; private set; } - public int TotalCount { get; private set; } - public int TotalPages { get; private set; } - - public PaginatedList(IQueryable source, int pageIndex, int pageSize) { - PageIndex = pageIndex; - PageSize = pageSize; - TotalCount = source.Count(); - TotalPages = (int) Math.Ceiling(TotalCount / (double)PageSize); - - this.AddRange(source.Skip(PageIndex * PageSize).Take(PageSize)); - } - - public bool HasPreviousPage { - get { - return (PageIndex > 0); - } - } - - public bool HasNextPage { - get { - return (PageIndex+1 < TotalPages); - } - } - } -} +using System; +using System.Collections.Generic; +using System.Linq; + +namespace NerdDinner.Helpers { + + public class PaginatedList : List { + + public int PageIndex { get; private set; } + public int PageSize { get; private set; } + public int TotalCount { get; private set; } + public int TotalPages { get; private set; } + + public PaginatedList(IQueryable source, int pageIndex, int pageSize) { + PageIndex = pageIndex; + PageSize = pageSize; + TotalCount = source.Count(); + TotalPages = (int) Math.Ceiling(TotalCount / (double)PageSize); + + this.AddRange(source.Skip(PageIndex * PageSize).Take(PageSize)); + } + + public bool HasPreviousPage { + get { + return (PageIndex > 0); + } + } + + public bool HasNextPage { + get { + return (PageIndex+1 < TotalPages); + } + } + } +} diff --git a/aspclassiccompiler/DLRSoft.Examples.NerdDinnerApp/Helpers/PhoneValidator.cs b/aspclassiccompiler/DLRSoft.Examples.NerdDinnerApp/Helpers/PhoneValidator.cs index e7500d1..2a3e590 100644 --- a/aspclassiccompiler/DLRSoft.Examples.NerdDinnerApp/Helpers/PhoneValidator.cs +++ b/aspclassiccompiler/DLRSoft.Examples.NerdDinnerApp/Helpers/PhoneValidator.cs @@ -1,32 +1,32 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Web; -using System.Text.RegularExpressions; - -namespace NerdDinner.Helpers { - - public class PhoneValidator { - - static IDictionary countryRegex = new Dictionary() - { - { "USA", new Regex("^[2-9]\\d{2}-\\d{3}-\\d{4}$")}, - { "UK", new Regex("(^1300\\d{6}$)|(^1800|1900|1902\\d{6}$)|(^0[2|3|7|8]{1}[0-9]{8}$)|(^13\\d{4}$)|(^04\\d{2,3}\\d{6}$)")}, - { "Netherlands", new Regex("(^\\+[0-9]{2}|^\\+[0-9]{2}\\(0\\)|^\\(\\+[0-9]{2}\\)\\(0\\)|^00[0-9]{2}|^0)([0-9]{9}$|[0-9\\-\\s]{10}$)")}, - }; - - public static bool IsValidNumber(string phoneNumber, string country) { - - if (country != null && countryRegex.ContainsKey(country)) - return countryRegex[country].IsMatch(phoneNumber); - else - return false; - } - - public static IEnumerable Countries { - get { - return countryRegex.Keys; - } - } - } -} +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; +using System.Text.RegularExpressions; + +namespace NerdDinner.Helpers { + + public class PhoneValidator { + + static IDictionary countryRegex = new Dictionary() + { + { "USA", new Regex("^[2-9]\\d{2}-\\d{3}-\\d{4}$")}, + { "UK", new Regex("(^1300\\d{6}$)|(^1800|1900|1902\\d{6}$)|(^0[2|3|7|8]{1}[0-9]{8}$)|(^13\\d{4}$)|(^04\\d{2,3}\\d{6}$)")}, + { "Netherlands", new Regex("(^\\+[0-9]{2}|^\\+[0-9]{2}\\(0\\)|^\\(\\+[0-9]{2}\\)\\(0\\)|^00[0-9]{2}|^0)([0-9]{9}$|[0-9\\-\\s]{10}$)")}, + }; + + public static bool IsValidNumber(string phoneNumber, string country) { + + if (country != null && countryRegex.ContainsKey(country)) + return countryRegex[country].IsMatch(phoneNumber); + else + return false; + } + + public static IEnumerable Countries { + get { + return countryRegex.Keys; + } + } + } +} diff --git a/aspclassiccompiler/DLRSoft.Examples.NerdDinnerApp/Models/Dinner.cs b/aspclassiccompiler/DLRSoft.Examples.NerdDinnerApp/Models/Dinner.cs index 53bf556..8f26640 100644 --- a/aspclassiccompiler/DLRSoft.Examples.NerdDinnerApp/Models/Dinner.cs +++ b/aspclassiccompiler/DLRSoft.Examples.NerdDinnerApp/Models/Dinner.cs @@ -1,56 +1,56 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Data.Linq; -using System.Web.Mvc; -using NerdDinner.Helpers; - -namespace NerdDinner.Models { - - [Bind(Include="Title,Description,EventDate,Address,Country,ContactPhone,Latitude,Longitude")] - public partial class Dinner { - - public bool IsHostedBy(string userName) { - return HostedBy.Equals(userName, StringComparison.InvariantCultureIgnoreCase); - } - - public bool IsUserRegistered(string userName) { - return RSVPs.Any(r => r.AttendeeName.Equals(userName, StringComparison.InvariantCultureIgnoreCase)); - } - - public bool IsValid { - get { return (GetRuleViolations().Count() == 0); } - } - - public IEnumerable GetRuleViolations() { - - if (String.IsNullOrEmpty(Title)) - yield return new RuleViolation("Title is required", "Title"); - - if (String.IsNullOrEmpty(Description)) - yield return new RuleViolation("Description is required", "Description"); - - if (String.IsNullOrEmpty(HostedBy)) - yield return new RuleViolation("HostedBy is required", "HostedBy"); - - if (String.IsNullOrEmpty(Address)) - yield return new RuleViolation("Address is required", "Address"); - - if (String.IsNullOrEmpty(Country)) - yield return new RuleViolation("Country is required", "Address"); - - if (String.IsNullOrEmpty(ContactPhone)) - yield return new RuleViolation("Phone# is required", "ContactPhone"); - - if (!PhoneValidator.IsValidNumber(ContactPhone, Country)) - yield return new RuleViolation("Phone# does not match country", "ContactPhone"); - - yield break; - } - - partial void OnValidate(ChangeAction action) { - if (!IsValid) - throw new ApplicationException("Rule violations prevent saving"); - } - } -} +using System; +using System.Collections.Generic; +using System.Linq; +using System.Data.Linq; +using System.Web.Mvc; +using NerdDinner.Helpers; + +namespace NerdDinner.Models { + + [Bind(Include="Title,Description,EventDate,Address,Country,ContactPhone,Latitude,Longitude")] + public partial class Dinner { + + public bool IsHostedBy(string userName) { + return HostedBy.Equals(userName, StringComparison.InvariantCultureIgnoreCase); + } + + public bool IsUserRegistered(string userName) { + return RSVPs.Any(r => r.AttendeeName.Equals(userName, StringComparison.InvariantCultureIgnoreCase)); + } + + public bool IsValid { + get { return (GetRuleViolations().Count() == 0); } + } + + public IEnumerable GetRuleViolations() { + + if (String.IsNullOrEmpty(Title)) + yield return new RuleViolation("Title is required", "Title"); + + if (String.IsNullOrEmpty(Description)) + yield return new RuleViolation("Description is required", "Description"); + + if (String.IsNullOrEmpty(HostedBy)) + yield return new RuleViolation("HostedBy is required", "HostedBy"); + + if (String.IsNullOrEmpty(Address)) + yield return new RuleViolation("Address is required", "Address"); + + if (String.IsNullOrEmpty(Country)) + yield return new RuleViolation("Country is required", "Address"); + + if (String.IsNullOrEmpty(ContactPhone)) + yield return new RuleViolation("Phone# is required", "ContactPhone"); + + if (!PhoneValidator.IsValidNumber(ContactPhone, Country)) + yield return new RuleViolation("Phone# does not match country", "ContactPhone"); + + yield break; + } + + partial void OnValidate(ChangeAction action) { + if (!IsValid) + throw new ApplicationException("Rule violations prevent saving"); + } + } +} diff --git a/aspclassiccompiler/DLRSoft.Examples.NerdDinnerApp/Models/DinnerRepository.cs b/aspclassiccompiler/DLRSoft.Examples.NerdDinnerApp/Models/DinnerRepository.cs index 7919793..e018d7c 100644 --- a/aspclassiccompiler/DLRSoft.Examples.NerdDinnerApp/Models/DinnerRepository.cs +++ b/aspclassiccompiler/DLRSoft.Examples.NerdDinnerApp/Models/DinnerRepository.cs @@ -1,58 +1,58 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Web; - -namespace NerdDinner.Models { - - public class DinnerRepository : NerdDinner.Models.IDinnerRepository { - - NerdDinnerDataContext db = new NerdDinnerDataContext(); - - // - // Query Methods - - public IQueryable FindAllDinners() { - return db.Dinners; - } - - public IQueryable FindUpcomingDinners() { - return from dinner in FindAllDinners() - where dinner.EventDate > DateTime.Now - orderby dinner.EventDate - select dinner; - } - - public IQueryable FindByLocation(float latitude, float longitude) { - var dinners = from dinner in FindUpcomingDinners() - join i in db.NearestDinners(latitude, longitude) - on dinner.DinnerID equals i.DinnerID - select dinner; - - return dinners; - } - - public Dinner GetDinner(int id) { - return db.Dinners.SingleOrDefault(d => d.DinnerID == id); - } - - // - // Insert/Delete Methods - - public void Add(Dinner dinner) { - db.Dinners.InsertOnSubmit(dinner); - } - - public void Delete(Dinner dinner) { - db.RSVPs.DeleteAllOnSubmit(dinner.RSVPs); - db.Dinners.DeleteOnSubmit(dinner); - } - - // - // Persistence - - public void Save() { - db.SubmitChanges(); - } - } -} +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; + +namespace NerdDinner.Models { + + public class DinnerRepository : NerdDinner.Models.IDinnerRepository { + + NerdDinnerDataContext db = new NerdDinnerDataContext(); + + // + // Query Methods + + public IQueryable FindAllDinners() { + return db.Dinners; + } + + public IQueryable FindUpcomingDinners() { + return from dinner in FindAllDinners() + where dinner.EventDate > DateTime.Now + orderby dinner.EventDate + select dinner; + } + + public IQueryable FindByLocation(float latitude, float longitude) { + var dinners = from dinner in FindUpcomingDinners() + join i in db.NearestDinners(latitude, longitude) + on dinner.DinnerID equals i.DinnerID + select dinner; + + return dinners; + } + + public Dinner GetDinner(int id) { + return db.Dinners.SingleOrDefault(d => d.DinnerID == id); + } + + // + // Insert/Delete Methods + + public void Add(Dinner dinner) { + db.Dinners.InsertOnSubmit(dinner); + } + + public void Delete(Dinner dinner) { + db.RSVPs.DeleteAllOnSubmit(dinner.RSVPs); + db.Dinners.DeleteOnSubmit(dinner); + } + + // + // Persistence + + public void Save() { + db.SubmitChanges(); + } + } +} diff --git a/aspclassiccompiler/DLRSoft.Examples.NerdDinnerApp/Models/IDinnerRepository.cs b/aspclassiccompiler/DLRSoft.Examples.NerdDinnerApp/Models/IDinnerRepository.cs index 9e32d98..79a6e8a 100644 --- a/aspclassiccompiler/DLRSoft.Examples.NerdDinnerApp/Models/IDinnerRepository.cs +++ b/aspclassiccompiler/DLRSoft.Examples.NerdDinnerApp/Models/IDinnerRepository.cs @@ -1,18 +1,18 @@ -using System; -using System.Linq; - -namespace NerdDinner.Models { - - public interface IDinnerRepository { - - IQueryable FindAllDinners(); - IQueryable FindByLocation(float latitude, float longitude); - IQueryable FindUpcomingDinners(); - Dinner GetDinner(int id); - - void Add(Dinner dinner); - void Delete(Dinner dinner); - - void Save(); - } -} +using System; +using System.Linq; + +namespace NerdDinner.Models { + + public interface IDinnerRepository { + + IQueryable FindAllDinners(); + IQueryable FindByLocation(float latitude, float longitude); + IQueryable FindUpcomingDinners(); + Dinner GetDinner(int id); + + void Add(Dinner dinner); + void Delete(Dinner dinner); + + void Save(); + } +} diff --git a/aspclassiccompiler/DLRSoft.Examples.NerdDinnerApp/Models/NerdDinner.designer.cs b/aspclassiccompiler/DLRSoft.Examples.NerdDinnerApp/Models/NerdDinner.designer.cs index feaa57a..04acff0 100644 --- a/aspclassiccompiler/DLRSoft.Examples.NerdDinnerApp/Models/NerdDinner.designer.cs +++ b/aspclassiccompiler/DLRSoft.Examples.NerdDinnerApp/Models/NerdDinner.designer.cs @@ -1,583 +1,583 @@ -#pragma warning disable 1591 -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:2.0.50727.3521 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace NerdDinner.Models -{ - using System.Data.Linq; - using System.Data.Linq.Mapping; - using System.Data; - using System.Collections.Generic; - using System.Reflection; - using System.Linq; - using System.Linq.Expressions; - using System.ComponentModel; - using System; - - - [System.Data.Linq.Mapping.DatabaseAttribute(Name="NerdDinner")] - public partial class NerdDinnerDataContext : System.Data.Linq.DataContext - { - - private static System.Data.Linq.Mapping.MappingSource mappingSource = new AttributeMappingSource(); - - #region Extensibility Method Definitions - partial void OnCreated(); - partial void InsertDinner(Dinner instance); - partial void UpdateDinner(Dinner instance); - partial void DeleteDinner(Dinner instance); - partial void InsertRSVP(RSVP instance); - partial void UpdateRSVP(RSVP instance); - partial void DeleteRSVP(RSVP instance); - #endregion - - public NerdDinnerDataContext() : - base(global::System.Configuration.ConfigurationManager.ConnectionStrings["NerdDinnerConnectionString"].ConnectionString, mappingSource) - { - OnCreated(); - } - - public NerdDinnerDataContext(string connection) : - base(connection, mappingSource) - { - OnCreated(); - } - - public NerdDinnerDataContext(System.Data.IDbConnection connection) : - base(connection, mappingSource) - { - OnCreated(); - } - - public NerdDinnerDataContext(string connection, System.Data.Linq.Mapping.MappingSource mappingSource) : - base(connection, mappingSource) - { - OnCreated(); - } - - public NerdDinnerDataContext(System.Data.IDbConnection connection, System.Data.Linq.Mapping.MappingSource mappingSource) : - base(connection, mappingSource) - { - OnCreated(); - } - - public System.Data.Linq.Table Dinners - { - get - { - return this.GetTable(); - } - } - - public System.Data.Linq.Table RSVPs - { - get - { - return this.GetTable(); - } - } - - [Function(Name="dbo.NearestDinners", IsComposable=true)] - public IQueryable NearestDinners([Parameter(DbType="Real")] System.Nullable lat, [Parameter(Name="long", DbType="Real")] System.Nullable @long) - { - return this.CreateMethodCallQuery(this, ((MethodInfo)(MethodInfo.GetCurrentMethod())), lat, @long); - } - - [Function(Name="dbo.DistanceBetween", IsComposable=true)] - public System.Nullable DistanceBetween([Parameter(Name="Lat1", DbType="Real")] System.Nullable lat1, [Parameter(Name="Long1", DbType="Real")] System.Nullable long1, [Parameter(Name="Lat2", DbType="Real")] System.Nullable lat2, [Parameter(Name="Long2", DbType="Real")] System.Nullable long2) - { - return ((System.Nullable)(this.ExecuteMethodCall(this, ((MethodInfo)(MethodInfo.GetCurrentMethod())), lat1, long1, lat2, long2).ReturnValue)); - } - } - - [Table(Name="dbo.Dinners")] - public partial class Dinner : INotifyPropertyChanging, INotifyPropertyChanged - { - - private static PropertyChangingEventArgs emptyChangingEventArgs = new PropertyChangingEventArgs(String.Empty); - - private int _DinnerID; - - private string _Title; - - private System.DateTime _EventDate; - - private string _Description; - - private string _HostedBy; - - private string _ContactPhone; - - private string _Address; - - private string _Country; - - private double _Latitude; - - private double _Longitude; - - private EntitySet _RSVPs; - - #region Extensibility Method Definitions - partial void OnLoaded(); - partial void OnValidate(System.Data.Linq.ChangeAction action); - partial void OnCreated(); - partial void OnDinnerIDChanging(int value); - partial void OnDinnerIDChanged(); - partial void OnTitleChanging(string value); - partial void OnTitleChanged(); - partial void OnEventDateChanging(System.DateTime value); - partial void OnEventDateChanged(); - partial void OnDescriptionChanging(string value); - partial void OnDescriptionChanged(); - partial void OnHostedByChanging(string value); - partial void OnHostedByChanged(); - partial void OnContactPhoneChanging(string value); - partial void OnContactPhoneChanged(); - partial void OnAddressChanging(string value); - partial void OnAddressChanged(); - partial void OnCountryChanging(string value); - partial void OnCountryChanged(); - partial void OnLatitudeChanging(double value); - partial void OnLatitudeChanged(); - partial void OnLongitudeChanging(double value); - partial void OnLongitudeChanged(); - #endregion - - public Dinner() - { - this._RSVPs = new EntitySet(new Action(this.attach_RSVPs), new Action(this.detach_RSVPs)); - OnCreated(); - } - - [Column(Storage="_DinnerID", AutoSync=AutoSync.OnInsert, DbType="Int NOT NULL IDENTITY", IsPrimaryKey=true, IsDbGenerated=true)] - public int DinnerID - { - get - { - return this._DinnerID; - } - set - { - if ((this._DinnerID != value)) - { - this.OnDinnerIDChanging(value); - this.SendPropertyChanging(); - this._DinnerID = value; - this.SendPropertyChanged("DinnerID"); - this.OnDinnerIDChanged(); - } - } - } - - [Column(Storage="_Title", DbType="NVarChar(50) NOT NULL", CanBeNull=false)] - public string Title - { - get - { - return this._Title; - } - set - { - if ((this._Title != value)) - { - this.OnTitleChanging(value); - this.SendPropertyChanging(); - this._Title = value; - this.SendPropertyChanged("Title"); - this.OnTitleChanged(); - } - } - } - - [Column(Storage="_EventDate", DbType="DateTime NOT NULL")] - public System.DateTime EventDate - { - get - { - return this._EventDate; - } - set - { - if ((this._EventDate != value)) - { - this.OnEventDateChanging(value); - this.SendPropertyChanging(); - this._EventDate = value; - this.SendPropertyChanged("EventDate"); - this.OnEventDateChanged(); - } - } - } - - [Column(Storage="_Description", DbType="NVarChar(256)")] - public string Description - { - get - { - return this._Description; - } - set - { - if ((this._Description != value)) - { - this.OnDescriptionChanging(value); - this.SendPropertyChanging(); - this._Description = value; - this.SendPropertyChanged("Description"); - this.OnDescriptionChanged(); - } - } - } - - [Column(Storage="_HostedBy", DbType="NVarChar(50) NOT NULL", CanBeNull=false)] - public string HostedBy - { - get - { - return this._HostedBy; - } - set - { - if ((this._HostedBy != value)) - { - this.OnHostedByChanging(value); - this.SendPropertyChanging(); - this._HostedBy = value; - this.SendPropertyChanged("HostedBy"); - this.OnHostedByChanged(); - } - } - } - - [Column(Storage="_ContactPhone", DbType="NVarChar(50) NOT NULL", CanBeNull=false)] - public string ContactPhone - { - get - { - return this._ContactPhone; - } - set - { - if ((this._ContactPhone != value)) - { - this.OnContactPhoneChanging(value); - this.SendPropertyChanging(); - this._ContactPhone = value; - this.SendPropertyChanged("ContactPhone"); - this.OnContactPhoneChanged(); - } - } - } - - [Column(Storage="_Address", DbType="NVarChar(50)")] - public string Address - { - get - { - return this._Address; - } - set - { - if ((this._Address != value)) - { - this.OnAddressChanging(value); - this.SendPropertyChanging(); - this._Address = value; - this.SendPropertyChanged("Address"); - this.OnAddressChanged(); - } - } - } - - [Column(Storage="_Country", DbType="NVarChar(30)")] - public string Country - { - get - { - return this._Country; - } - set - { - if ((this._Country != value)) - { - this.OnCountryChanging(value); - this.SendPropertyChanging(); - this._Country = value; - this.SendPropertyChanged("Country"); - this.OnCountryChanged(); - } - } - } - - [Column(Storage="_Latitude", DbType="Float NOT NULL")] - public double Latitude - { - get - { - return this._Latitude; - } - set - { - if ((this._Latitude != value)) - { - this.OnLatitudeChanging(value); - this.SendPropertyChanging(); - this._Latitude = value; - this.SendPropertyChanged("Latitude"); - this.OnLatitudeChanged(); - } - } - } - - [Column(Storage="_Longitude", DbType="Float NOT NULL")] - public double Longitude - { - get - { - return this._Longitude; - } - set - { - if ((this._Longitude != value)) - { - this.OnLongitudeChanging(value); - this.SendPropertyChanging(); - this._Longitude = value; - this.SendPropertyChanged("Longitude"); - this.OnLongitudeChanged(); - } - } - } - - [Association(Name="Dinner_RSVP", Storage="_RSVPs", ThisKey="DinnerID", OtherKey="DinnerID")] - public EntitySet RSVPs - { - get - { - return this._RSVPs; - } - set - { - this._RSVPs.Assign(value); - } - } - - public event PropertyChangingEventHandler PropertyChanging; - - public event PropertyChangedEventHandler PropertyChanged; - - protected virtual void SendPropertyChanging() - { - if ((this.PropertyChanging != null)) - { - this.PropertyChanging(this, emptyChangingEventArgs); - } - } - - protected virtual void SendPropertyChanged(String propertyName) - { - if ((this.PropertyChanged != null)) - { - this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName)); - } - } - - private void attach_RSVPs(RSVP entity) - { - this.SendPropertyChanging(); - entity.Dinner = this; - } - - private void detach_RSVPs(RSVP entity) - { - this.SendPropertyChanging(); - entity.Dinner = null; - } - } - - [Table(Name="dbo.RSVP")] - public partial class RSVP : INotifyPropertyChanging, INotifyPropertyChanged - { - - private static PropertyChangingEventArgs emptyChangingEventArgs = new PropertyChangingEventArgs(String.Empty); - - private int _RsvpID; - - private int _DinnerID; - - private string _AttendeeName; - - private EntityRef _Dinner; - - #region Extensibility Method Definitions - partial void OnLoaded(); - partial void OnValidate(System.Data.Linq.ChangeAction action); - partial void OnCreated(); - partial void OnRsvpIDChanging(int value); - partial void OnRsvpIDChanged(); - partial void OnDinnerIDChanging(int value); - partial void OnDinnerIDChanged(); - partial void OnAttendeeNameChanging(string value); - partial void OnAttendeeNameChanged(); - #endregion - - public RSVP() - { - this._Dinner = default(EntityRef); - OnCreated(); - } - - [Column(Storage="_RsvpID", AutoSync=AutoSync.OnInsert, DbType="Int NOT NULL IDENTITY", IsPrimaryKey=true, IsDbGenerated=true)] - public int RsvpID - { - get - { - return this._RsvpID; - } - set - { - if ((this._RsvpID != value)) - { - this.OnRsvpIDChanging(value); - this.SendPropertyChanging(); - this._RsvpID = value; - this.SendPropertyChanged("RsvpID"); - this.OnRsvpIDChanged(); - } - } - } - - [Column(Storage="_DinnerID", DbType="Int NOT NULL")] - public int DinnerID - { - get - { - return this._DinnerID; - } - set - { - if ((this._DinnerID != value)) - { - if (this._Dinner.HasLoadedOrAssignedValue) - { - throw new System.Data.Linq.ForeignKeyReferenceAlreadyHasValueException(); - } - this.OnDinnerIDChanging(value); - this.SendPropertyChanging(); - this._DinnerID = value; - this.SendPropertyChanged("DinnerID"); - this.OnDinnerIDChanged(); - } - } - } - - [Column(Storage="_AttendeeName", DbType="NVarChar(50) NOT NULL", CanBeNull=false)] - public string AttendeeName - { - get - { - return this._AttendeeName; - } - set - { - if ((this._AttendeeName != value)) - { - this.OnAttendeeNameChanging(value); - this.SendPropertyChanging(); - this._AttendeeName = value; - this.SendPropertyChanged("AttendeeName"); - this.OnAttendeeNameChanged(); - } - } - } - - [Association(Name="Dinner_RSVP", Storage="_Dinner", ThisKey="DinnerID", OtherKey="DinnerID", IsForeignKey=true)] - public Dinner Dinner - { - get - { - return this._Dinner.Entity; - } - set - { - Dinner previousValue = this._Dinner.Entity; - if (((previousValue != value) - || (this._Dinner.HasLoadedOrAssignedValue == false))) - { - this.SendPropertyChanging(); - if ((previousValue != null)) - { - this._Dinner.Entity = null; - previousValue.RSVPs.Remove(this); - } - this._Dinner.Entity = value; - if ((value != null)) - { - value.RSVPs.Add(this); - this._DinnerID = value.DinnerID; - } - else - { - this._DinnerID = default(int); - } - this.SendPropertyChanged("Dinner"); - } - } - } - - public event PropertyChangingEventHandler PropertyChanging; - - public event PropertyChangedEventHandler PropertyChanged; - - protected virtual void SendPropertyChanging() - { - if ((this.PropertyChanging != null)) - { - this.PropertyChanging(this, emptyChangingEventArgs); - } - } - - protected virtual void SendPropertyChanged(String propertyName) - { - if ((this.PropertyChanged != null)) - { - this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName)); - } - } - } - - public partial class NearestDinnersResult - { - - private int _DinnerID; - - public NearestDinnersResult() - { - } - - [Column(Storage="_DinnerID", DbType="Int NOT NULL")] - public int DinnerID - { - get - { - return this._DinnerID; - } - set - { - if ((this._DinnerID != value)) - { - this._DinnerID = value; - } - } - } - } -} -#pragma warning restore 1591 +#pragma warning disable 1591 +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:2.0.50727.3521 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace NerdDinner.Models +{ + using System.Data.Linq; + using System.Data.Linq.Mapping; + using System.Data; + using System.Collections.Generic; + using System.Reflection; + using System.Linq; + using System.Linq.Expressions; + using System.ComponentModel; + using System; + + + [System.Data.Linq.Mapping.DatabaseAttribute(Name="NerdDinner")] + public partial class NerdDinnerDataContext : System.Data.Linq.DataContext + { + + private static System.Data.Linq.Mapping.MappingSource mappingSource = new AttributeMappingSource(); + + #region Extensibility Method Definitions + partial void OnCreated(); + partial void InsertDinner(Dinner instance); + partial void UpdateDinner(Dinner instance); + partial void DeleteDinner(Dinner instance); + partial void InsertRSVP(RSVP instance); + partial void UpdateRSVP(RSVP instance); + partial void DeleteRSVP(RSVP instance); + #endregion + + public NerdDinnerDataContext() : + base(global::System.Configuration.ConfigurationManager.ConnectionStrings["NerdDinnerConnectionString"].ConnectionString, mappingSource) + { + OnCreated(); + } + + public NerdDinnerDataContext(string connection) : + base(connection, mappingSource) + { + OnCreated(); + } + + public NerdDinnerDataContext(System.Data.IDbConnection connection) : + base(connection, mappingSource) + { + OnCreated(); + } + + public NerdDinnerDataContext(string connection, System.Data.Linq.Mapping.MappingSource mappingSource) : + base(connection, mappingSource) + { + OnCreated(); + } + + public NerdDinnerDataContext(System.Data.IDbConnection connection, System.Data.Linq.Mapping.MappingSource mappingSource) : + base(connection, mappingSource) + { + OnCreated(); + } + + public System.Data.Linq.Table Dinners + { + get + { + return this.GetTable(); + } + } + + public System.Data.Linq.Table RSVPs + { + get + { + return this.GetTable(); + } + } + + [Function(Name="dbo.NearestDinners", IsComposable=true)] + public IQueryable NearestDinners([Parameter(DbType="Real")] System.Nullable lat, [Parameter(Name="long", DbType="Real")] System.Nullable @long) + { + return this.CreateMethodCallQuery(this, ((MethodInfo)(MethodInfo.GetCurrentMethod())), lat, @long); + } + + [Function(Name="dbo.DistanceBetween", IsComposable=true)] + public System.Nullable DistanceBetween([Parameter(Name="Lat1", DbType="Real")] System.Nullable lat1, [Parameter(Name="Long1", DbType="Real")] System.Nullable long1, [Parameter(Name="Lat2", DbType="Real")] System.Nullable lat2, [Parameter(Name="Long2", DbType="Real")] System.Nullable long2) + { + return ((System.Nullable)(this.ExecuteMethodCall(this, ((MethodInfo)(MethodInfo.GetCurrentMethod())), lat1, long1, lat2, long2).ReturnValue)); + } + } + + [Table(Name="dbo.Dinners")] + public partial class Dinner : INotifyPropertyChanging, INotifyPropertyChanged + { + + private static PropertyChangingEventArgs emptyChangingEventArgs = new PropertyChangingEventArgs(String.Empty); + + private int _DinnerID; + + private string _Title; + + private System.DateTime _EventDate; + + private string _Description; + + private string _HostedBy; + + private string _ContactPhone; + + private string _Address; + + private string _Country; + + private double _Latitude; + + private double _Longitude; + + private EntitySet _RSVPs; + + #region Extensibility Method Definitions + partial void OnLoaded(); + partial void OnValidate(System.Data.Linq.ChangeAction action); + partial void OnCreated(); + partial void OnDinnerIDChanging(int value); + partial void OnDinnerIDChanged(); + partial void OnTitleChanging(string value); + partial void OnTitleChanged(); + partial void OnEventDateChanging(System.DateTime value); + partial void OnEventDateChanged(); + partial void OnDescriptionChanging(string value); + partial void OnDescriptionChanged(); + partial void OnHostedByChanging(string value); + partial void OnHostedByChanged(); + partial void OnContactPhoneChanging(string value); + partial void OnContactPhoneChanged(); + partial void OnAddressChanging(string value); + partial void OnAddressChanged(); + partial void OnCountryChanging(string value); + partial void OnCountryChanged(); + partial void OnLatitudeChanging(double value); + partial void OnLatitudeChanged(); + partial void OnLongitudeChanging(double value); + partial void OnLongitudeChanged(); + #endregion + + public Dinner() + { + this._RSVPs = new EntitySet(new Action(this.attach_RSVPs), new Action(this.detach_RSVPs)); + OnCreated(); + } + + [Column(Storage="_DinnerID", AutoSync=AutoSync.OnInsert, DbType="Int NOT NULL IDENTITY", IsPrimaryKey=true, IsDbGenerated=true)] + public int DinnerID + { + get + { + return this._DinnerID; + } + set + { + if ((this._DinnerID != value)) + { + this.OnDinnerIDChanging(value); + this.SendPropertyChanging(); + this._DinnerID = value; + this.SendPropertyChanged("DinnerID"); + this.OnDinnerIDChanged(); + } + } + } + + [Column(Storage="_Title", DbType="NVarChar(50) NOT NULL", CanBeNull=false)] + public string Title + { + get + { + return this._Title; + } + set + { + if ((this._Title != value)) + { + this.OnTitleChanging(value); + this.SendPropertyChanging(); + this._Title = value; + this.SendPropertyChanged("Title"); + this.OnTitleChanged(); + } + } + } + + [Column(Storage="_EventDate", DbType="DateTime NOT NULL")] + public System.DateTime EventDate + { + get + { + return this._EventDate; + } + set + { + if ((this._EventDate != value)) + { + this.OnEventDateChanging(value); + this.SendPropertyChanging(); + this._EventDate = value; + this.SendPropertyChanged("EventDate"); + this.OnEventDateChanged(); + } + } + } + + [Column(Storage="_Description", DbType="NVarChar(256)")] + public string Description + { + get + { + return this._Description; + } + set + { + if ((this._Description != value)) + { + this.OnDescriptionChanging(value); + this.SendPropertyChanging(); + this._Description = value; + this.SendPropertyChanged("Description"); + this.OnDescriptionChanged(); + } + } + } + + [Column(Storage="_HostedBy", DbType="NVarChar(50) NOT NULL", CanBeNull=false)] + public string HostedBy + { + get + { + return this._HostedBy; + } + set + { + if ((this._HostedBy != value)) + { + this.OnHostedByChanging(value); + this.SendPropertyChanging(); + this._HostedBy = value; + this.SendPropertyChanged("HostedBy"); + this.OnHostedByChanged(); + } + } + } + + [Column(Storage="_ContactPhone", DbType="NVarChar(50) NOT NULL", CanBeNull=false)] + public string ContactPhone + { + get + { + return this._ContactPhone; + } + set + { + if ((this._ContactPhone != value)) + { + this.OnContactPhoneChanging(value); + this.SendPropertyChanging(); + this._ContactPhone = value; + this.SendPropertyChanged("ContactPhone"); + this.OnContactPhoneChanged(); + } + } + } + + [Column(Storage="_Address", DbType="NVarChar(50)")] + public string Address + { + get + { + return this._Address; + } + set + { + if ((this._Address != value)) + { + this.OnAddressChanging(value); + this.SendPropertyChanging(); + this._Address = value; + this.SendPropertyChanged("Address"); + this.OnAddressChanged(); + } + } + } + + [Column(Storage="_Country", DbType="NVarChar(30)")] + public string Country + { + get + { + return this._Country; + } + set + { + if ((this._Country != value)) + { + this.OnCountryChanging(value); + this.SendPropertyChanging(); + this._Country = value; + this.SendPropertyChanged("Country"); + this.OnCountryChanged(); + } + } + } + + [Column(Storage="_Latitude", DbType="Float NOT NULL")] + public double Latitude + { + get + { + return this._Latitude; + } + set + { + if ((this._Latitude != value)) + { + this.OnLatitudeChanging(value); + this.SendPropertyChanging(); + this._Latitude = value; + this.SendPropertyChanged("Latitude"); + this.OnLatitudeChanged(); + } + } + } + + [Column(Storage="_Longitude", DbType="Float NOT NULL")] + public double Longitude + { + get + { + return this._Longitude; + } + set + { + if ((this._Longitude != value)) + { + this.OnLongitudeChanging(value); + this.SendPropertyChanging(); + this._Longitude = value; + this.SendPropertyChanged("Longitude"); + this.OnLongitudeChanged(); + } + } + } + + [Association(Name="Dinner_RSVP", Storage="_RSVPs", ThisKey="DinnerID", OtherKey="DinnerID")] + public EntitySet RSVPs + { + get + { + return this._RSVPs; + } + set + { + this._RSVPs.Assign(value); + } + } + + public event PropertyChangingEventHandler PropertyChanging; + + public event PropertyChangedEventHandler PropertyChanged; + + protected virtual void SendPropertyChanging() + { + if ((this.PropertyChanging != null)) + { + this.PropertyChanging(this, emptyChangingEventArgs); + } + } + + protected virtual void SendPropertyChanged(String propertyName) + { + if ((this.PropertyChanged != null)) + { + this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName)); + } + } + + private void attach_RSVPs(RSVP entity) + { + this.SendPropertyChanging(); + entity.Dinner = this; + } + + private void detach_RSVPs(RSVP entity) + { + this.SendPropertyChanging(); + entity.Dinner = null; + } + } + + [Table(Name="dbo.RSVP")] + public partial class RSVP : INotifyPropertyChanging, INotifyPropertyChanged + { + + private static PropertyChangingEventArgs emptyChangingEventArgs = new PropertyChangingEventArgs(String.Empty); + + private int _RsvpID; + + private int _DinnerID; + + private string _AttendeeName; + + private EntityRef _Dinner; + + #region Extensibility Method Definitions + partial void OnLoaded(); + partial void OnValidate(System.Data.Linq.ChangeAction action); + partial void OnCreated(); + partial void OnRsvpIDChanging(int value); + partial void OnRsvpIDChanged(); + partial void OnDinnerIDChanging(int value); + partial void OnDinnerIDChanged(); + partial void OnAttendeeNameChanging(string value); + partial void OnAttendeeNameChanged(); + #endregion + + public RSVP() + { + this._Dinner = default(EntityRef); + OnCreated(); + } + + [Column(Storage="_RsvpID", AutoSync=AutoSync.OnInsert, DbType="Int NOT NULL IDENTITY", IsPrimaryKey=true, IsDbGenerated=true)] + public int RsvpID + { + get + { + return this._RsvpID; + } + set + { + if ((this._RsvpID != value)) + { + this.OnRsvpIDChanging(value); + this.SendPropertyChanging(); + this._RsvpID = value; + this.SendPropertyChanged("RsvpID"); + this.OnRsvpIDChanged(); + } + } + } + + [Column(Storage="_DinnerID", DbType="Int NOT NULL")] + public int DinnerID + { + get + { + return this._DinnerID; + } + set + { + if ((this._DinnerID != value)) + { + if (this._Dinner.HasLoadedOrAssignedValue) + { + throw new System.Data.Linq.ForeignKeyReferenceAlreadyHasValueException(); + } + this.OnDinnerIDChanging(value); + this.SendPropertyChanging(); + this._DinnerID = value; + this.SendPropertyChanged("DinnerID"); + this.OnDinnerIDChanged(); + } + } + } + + [Column(Storage="_AttendeeName", DbType="NVarChar(50) NOT NULL", CanBeNull=false)] + public string AttendeeName + { + get + { + return this._AttendeeName; + } + set + { + if ((this._AttendeeName != value)) + { + this.OnAttendeeNameChanging(value); + this.SendPropertyChanging(); + this._AttendeeName = value; + this.SendPropertyChanged("AttendeeName"); + this.OnAttendeeNameChanged(); + } + } + } + + [Association(Name="Dinner_RSVP", Storage="_Dinner", ThisKey="DinnerID", OtherKey="DinnerID", IsForeignKey=true)] + public Dinner Dinner + { + get + { + return this._Dinner.Entity; + } + set + { + Dinner previousValue = this._Dinner.Entity; + if (((previousValue != value) + || (this._Dinner.HasLoadedOrAssignedValue == false))) + { + this.SendPropertyChanging(); + if ((previousValue != null)) + { + this._Dinner.Entity = null; + previousValue.RSVPs.Remove(this); + } + this._Dinner.Entity = value; + if ((value != null)) + { + value.RSVPs.Add(this); + this._DinnerID = value.DinnerID; + } + else + { + this._DinnerID = default(int); + } + this.SendPropertyChanged("Dinner"); + } + } + } + + public event PropertyChangingEventHandler PropertyChanging; + + public event PropertyChangedEventHandler PropertyChanged; + + protected virtual void SendPropertyChanging() + { + if ((this.PropertyChanging != null)) + { + this.PropertyChanging(this, emptyChangingEventArgs); + } + } + + protected virtual void SendPropertyChanged(String propertyName) + { + if ((this.PropertyChanged != null)) + { + this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName)); + } + } + } + + public partial class NearestDinnersResult + { + + private int _DinnerID; + + public NearestDinnersResult() + { + } + + [Column(Storage="_DinnerID", DbType="Int NOT NULL")] + public int DinnerID + { + get + { + return this._DinnerID; + } + set + { + if ((this._DinnerID != value)) + { + this._DinnerID = value; + } + } + } + } +} +#pragma warning restore 1591 diff --git a/aspclassiccompiler/DLRSoft.Examples.NerdDinnerApp/Models/RuleViolation.cs b/aspclassiccompiler/DLRSoft.Examples.NerdDinnerApp/Models/RuleViolation.cs index f3244f2..1a578e6 100644 --- a/aspclassiccompiler/DLRSoft.Examples.NerdDinnerApp/Models/RuleViolation.cs +++ b/aspclassiccompiler/DLRSoft.Examples.NerdDinnerApp/Models/RuleViolation.cs @@ -1,22 +1,22 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Web; - -namespace NerdDinner.Models { - - public class RuleViolation { - - public string ErrorMessage { get; private set; } - public string PropertyName { get; private set; } - - public RuleViolation(string errorMessage) { - ErrorMessage = errorMessage; - } - - public RuleViolation(string errorMessage, string propertyName) { - ErrorMessage = errorMessage; - PropertyName = propertyName; - } - } -} +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; + +namespace NerdDinner.Models { + + public class RuleViolation { + + public string ErrorMessage { get; private set; } + public string PropertyName { get; private set; } + + public RuleViolation(string errorMessage) { + ErrorMessage = errorMessage; + } + + public RuleViolation(string errorMessage, string propertyName) { + ErrorMessage = errorMessage; + PropertyName = propertyName; + } + } +} diff --git a/aspclassiccompiler/DLRSoft.Examples.NerdDinnerApp/NerdDinnerAsp.csproj b/aspclassiccompiler/DLRSoft.Examples.NerdDinnerApp/NerdDinnerAsp.csproj index a1e029c..542de41 100644 --- a/aspclassiccompiler/DLRSoft.Examples.NerdDinnerApp/NerdDinnerAsp.csproj +++ b/aspclassiccompiler/DLRSoft.Examples.NerdDinnerApp/NerdDinnerAsp.csproj @@ -1,215 +1,215 @@ - - - Debug - AnyCPU - 9.0.30729 - 2.0 - {328C148C-DBEE-41A4-B1C7-104CBB216556} - {603c0e0b-db56-11dc-be95-000d561079b0};{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc} - Library - Properties - NerdDinner - NerdDinner - v3.5 - false - - - true - full - false - bin\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - bin\ - TRACE - prompt - 4 - - - true - bin\x86\Debug\ - DEBUG;TRACE - full - x86 - prompt - - - bin\x86\Release\ - TRACE - true - pdbonly - x86 - prompt - - - - False - ..\asp\bin\Release\Dlrsoft.Asp.dll - - - - - 3.5 - - - 3.5 - - - 3.5 - - - False - C:\Program Files\Microsoft ASP.NET\ASP.NET MVC RC\Assemblies\System.Web.Abstractions.dll - 3.5 - - - C:\Program Files\Microsoft ASP.NET\ASP.NET MVC RC\Assemblies\System.Web.Mvc.dll - False - True - - - False - C:\Program Files\Microsoft ASP.NET\ASP.NET MVC RC\Assemblies\System.Web.Routing.dll - 3.5 - - - 3.5 - - - - - - - - - - - - - - - - - Code - - - Default.aspx - ASPXCodeBehind - - - Global.asax - - - - - - - - - True - True - NerdDinner.dbml - - - - - - - - - NerdDinner.mdf - - - - - - - - - - - - - - ASPXCodeBehind - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - MSLinqToSQLGenerator - NerdDinner.designer.cs - Designer - - - - - - - - NerdDinner.dbml - - - - - - - - - - - - - False - True - 60848 - / - - - False - False - - - False - - - - + + + Debug + AnyCPU + 9.0.30729 + 2.0 + {328C148C-DBEE-41A4-B1C7-104CBB216556} + {603c0e0b-db56-11dc-be95-000d561079b0};{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc} + Library + Properties + NerdDinner + NerdDinner + v3.5 + false + + + true + full + false + bin\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\ + TRACE + prompt + 4 + + + true + bin\x86\Debug\ + DEBUG;TRACE + full + x86 + prompt + + + bin\x86\Release\ + TRACE + true + pdbonly + x86 + prompt + + + + False + ..\asp\bin\Release\Dlrsoft.Asp.dll + + + + + 3.5 + + + 3.5 + + + 3.5 + + + False + C:\Program Files\Microsoft ASP.NET\ASP.NET MVC RC\Assemblies\System.Web.Abstractions.dll + 3.5 + + + C:\Program Files\Microsoft ASP.NET\ASP.NET MVC RC\Assemblies\System.Web.Mvc.dll + False + True + + + False + C:\Program Files\Microsoft ASP.NET\ASP.NET MVC RC\Assemblies\System.Web.Routing.dll + 3.5 + + + 3.5 + + + + + + + + + + + + + + + + + Code + + + Default.aspx + ASPXCodeBehind + + + Global.asax + + + + + + + + + True + True + NerdDinner.dbml + + + + + + + + + NerdDinner.mdf + + + + + + + + + + + + + + ASPXCodeBehind + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + MSLinqToSQLGenerator + NerdDinner.designer.cs + Designer + + + + + + + + NerdDinner.dbml + + + + + + + + + + + + + False + True + 60848 + / + + + False + False + + + False + + + + \ No newline at end of file diff --git a/aspclassiccompiler/DLRSoft.Examples.NerdDinnerApp/Properties/AssemblyInfo.cs b/aspclassiccompiler/DLRSoft.Examples.NerdDinnerApp/Properties/AssemblyInfo.cs index a60c7ec..c7c7f74 100644 --- a/aspclassiccompiler/DLRSoft.Examples.NerdDinnerApp/Properties/AssemblyInfo.cs +++ b/aspclassiccompiler/DLRSoft.Examples.NerdDinnerApp/Properties/AssemblyInfo.cs @@ -1,35 +1,35 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("NerdDinner")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("NerdDinner")] -[assembly: AssemblyCopyright("Copyright © 2009")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("3f961952-a5a3-4ca2-bc29-5b46b500177d")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Revision and Build Numbers -// by using the '*' as shown below: -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("0.5.2.32072")] +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("NerdDinner")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("NerdDinner")] +[assembly: AssemblyCopyright("Copyright © 2009")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("3f961952-a5a3-4ca2-bc29-5b46b500177d")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Revision and Build Numbers +// by using the '*' as shown below: +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("0.5.2.32072")] diff --git a/aspclassiccompiler/DLRSoft.Examples.NerdDinnerApp/Scripts/Map.js b/aspclassiccompiler/DLRSoft.Examples.NerdDinnerApp/Scripts/Map.js index b30aba7..e12505a 100644 --- a/aspclassiccompiler/DLRSoft.Examples.NerdDinnerApp/Scripts/Map.js +++ b/aspclassiccompiler/DLRSoft.Examples.NerdDinnerApp/Scripts/Map.js @@ -1,138 +1,138 @@ -/// - -var map = null; -var points = []; -var shapes = []; -var center = null; - -function LoadMap(latitude, longitude, onMapLoaded) { - map = new VEMap('theMap'); - options = new VEMapOptions(); - options.EnableBirdseye = false; - - // Makes the control bar less obtrusize. - map.SetDashboardSize(VEDashboardSize.Small); - - if (onMapLoaded != null) - map.onLoadMap = onMapLoaded; - - if (latitude != null && longitude != null) { - center = new VELatLong(latitude, longitude); - } - - map.LoadMap(center, null, null, null, null, null, null, options); -} - -function LoadPin(LL, name, description) { - var shape = new VEShape(VEShapeType.Pushpin, LL); - - //Make a nice Pushpin shape with a title and description - shape.SetTitle(" " + escape(name) + ""); - if (description !== undefined) { - shape.SetDescription("

" + - escape(description) + "

"); - } - map.AddShape(shape); - points.push(LL); - shapes.push(shape); -} - -function FindAddressOnMap(where) { - var numberOfResults = 20; - var setBestMapView = true; - var showResults = true; - - map.Find("", where, null, null, null, - numberOfResults, showResults, true, true, - setBestMapView, callbackForLocation); -} - -function callbackForLocation(layer, resultsArray, places, - hasMore, VEErrorMessage) { - - clearMap(); - - if (places == null) - return; - - //Make a pushpin for each place we find - $.each(places, function(i, item) { - var description = ""; - if (item.Description !== undefined) { - description = item.Description; - } - var LL = new VELatLong(item.LatLong.Latitude, - item.LatLong.Longitude); - - LoadPin(LL, item.Name, description); - }); - - //Make sure all pushpins are visible - if (points.length > 1) { - map.SetMapView(points); - } - - //If we've found exactly one place, that's our address. - if (points.length === 1) { - $("#Latitude").val(points[0].Latitude); - $("#Longitude").val(points[0].Longitude); - } -} - -function clearMap() { - map.Clear(); - points = []; - shapes = []; -} - -function FindDinnersGivenLocation(where) { - map.Find("", where, null, null, null, null, null, false, - null, null, callbackUpdateMapDinners); -} - -function callbackUpdateMapDinners(layer, resultsArray, places, hasMore, VEErrorMessage) { - $("#dinnerList").empty(); - clearMap(); - var center = map.GetCenter(); - - $.post("/Search/SearchByLocation", { latitude: center.Latitude, - longitude: center.Longitude - }, function(dinners) { - $.each(dinners, function(i, dinner) { - - var LL = new VELatLong(dinner.Latitude, dinner.Longitude, 0, null); - - var RsvpMessage = ""; - - if (dinner.RSVPCount == 1) - RsvpMessage = "" + dinner.RSVPCount + " RSVP"; - else - RsvpMessage = "" + dinner.RSVPCount + " RSVPs"; - - // Add Pin to Map - LoadPin(LL, '' - + dinner.Title + '', - "

" + dinner.Description + "

" + RsvpMessage); - - //Add a dinner to the