public ActionResult Index()
        {
            var movies = new[] {
                    new Movie {
                        Title = "The Big Lebowski",
                        ReleaseDate = "1998",
                        RunningTime = "117 mins",
                        Actors = new[] {
                                new Actor("Jeff Bridges"),
                                new Actor("John Goodman"),
                                new Actor("Steve Buscemi"),
                            }
                    },
                    new Movie {
                        Title = "The Princess Bride",
                        ReleaseDate = "1987",
                        RunningTime = "98 mins",
                        Actors = new[] {
                                new Actor("Cary Elwes"),
                                new Actor("Many Patinkin"),
                                new Actor("Robin Wright"),
                            }
                    },
                };

            return View(movies);
        }
        public ActionResult ResetDatabase(FormCollection form)
        {
            NHibernateBootstrapper.CreateSchema();
            using (var session = NHibernateBootstrapper.GetSession())
            {
                var users = new[]
                                {
                                    Core.Domain.User.CreateNewUser("*****@*****.**", "admin"),
                                    Core.Domain.User.CreateNewUser("*****@*****.**", "user")
                                };
                users.ForEach(u => session.Save(u));

                var project = Project.Create("Fail Tracker", users[0]);
                session.Save(project);

                (new[] {
                 		Issue.CreateNewIssue(project, "Project support", users[0], "As someone who manages many software projects, I want to be able to organize issues and bugs into projects within Fail Tracker.")
                                .ReassignTo(users[0])
                                .ChangeSizeTo(PointSize.Eight),
                 		Issue.CreateNewIssue(project, "Site rendering problems in IE6", users[1], "The site does not render the same in al versions of IE!")
                                .ChangeTypeTo(IssueType.Bug)
                                .ChangeSizeTo(PointSize.OneHundred)
                                .ReassignTo(users[1]),
                 		Issue.CreateNewIssue(project, "Enable user invite", users[0], "I want to be able to invite users to join Fail Tracker through a form on the site.")
                                .ReassignTo(users[0])
                                .ChangeSizeTo(PointSize.Five),
                 		Issue.CreateNewIssue(project, "Support unassigned stories", users[0], "I want to be able to leave stories and bugs unassigned.")
                                .ChangeSizeTo(PointSize.Five),
                 	}).ForEach(i => session.Save(i));

                session.Flush();
            }

            return this.RedirectToAction<DashboardController>(c => c.Index());
        }
        public static void RegisterRoutes(RouteCollection routes)
        {
            // Local variable of an array of strings that contains the namespace 
            // of wherever our PostsController namespace exists. When namespaces is
            // passed into the routes below, they'll be targeting a specific folder.
            // This is done to avoid conflicts as more than one PostsController exist.
            var namespaces = new[] { typeof(PostsController).Namespace };

            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

            routes.MapRoute("Login", "login", new { controller = "Auth", action = "Login" }, namespaces);

            routes.MapRoute("Logout", "logout", new { controller = "Auth", action = "Logout" }, namespaces);

            routes.MapRoute("Home", "", new { controller = "Posts", action = "Index" }, namespaces);

            // The default route will not be used.
            // All routes in this application will be explicit, which
            // allows the developer to have more control.

            //routes.MapRoute(
            //    name: "Default",
            //    url: "{controller}/{action}/{id}",
            //    defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
            //);
        }
Exemple #4
0
        public static void RegisterRoutes(RouteCollection routes)
        {
            var namespaces = new[] { "Branch.App.Controllers" };
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

            AreaRegistration.RegisterAllAreas();

            // Welcome
            routes.MapRoute("Welcome", "Home/",
                new { controller = "Home", action = "Index" }, namespaces);

            // Blog
            routes.MapRoute("Blog", "Blog/View/{slug}",
                new { controller = "Blog", action = "View", slug = "welcome" }, namespaces);

            // Search
            routes.MapRoute("SearchIdentity", "Search/Identity/{ident}",
                new { controller = "Search", action = "Identity", ident = UrlParameter.Optional }, namespaces);

            routes.MapRoute("Search", "Search/",
                new { controller = "Search", action = "Index" }, namespaces);

            // Catch All
            routes.MapRoute("Default", "{controller}/{action}/{id}",
                new { controller = "Home", action = "Index", id = UrlParameter.Optional }, namespaces);
        }
Exemple #5
0
 public ActionResult MoreVehicles()
 {
     var vehicles = new[]
     {
         new Vehicle
         {
             Name = "1968 Pontiac Firebird",
             Type = "Classic Car",
             Price = 27499.99m,
             Components = new[]
             {
                 new Component {Name = "8 cyl. Engine", Color = "Red"},
                 new Component {Name = "Interiors", Color = "Cameo Ivory"},
                 new Component {Name = "Exteriors", Color = "Autumn Bronze"}
             }
         },
         new Vehicle
         {
             Name = "WW-II Seehund U-Boat",
             Type = "German Midget Submarine",
             Price = 2579000m,
             Components = new[]
             {
                 new Component {Name = "Torpedo", Color = "Gray"},
                 new Component {Name = "Torpedo", Color = "Gray"},
                 new Component {Name = "Torpedo", Color = "Gray"},
                 new Component {Name = "Torpedo", Color = "Black"},
             }
         },
     };
     return Json(vehicles, JsonRequestBehavior.AllowGet);
 }
Exemple #6
0
 public ActionResult Index()
 {
     Vehicle[] vehicles = new[]
     {
         new Vehicle
         {
             Name = "Schinn Fixed Bicycle",
             Type = "Bicycle",
             Price = 199.99m,
             Components = new[]
             {
                 new Component {Name = "Speed Gauge", Color = "Red"},
                 new Component {Name = "Pedal", Color = "Black"},
                 new Component {Name = "Big Wheel", Color = "Dark Red"}
             }
         },
         new Vehicle
         {
             Name = "Predator",
             Type = "Fighter Drone",
             Price = 1650000.99m,
             Components = new[]
             {
                 new Component {Name = "Autopilot", Color = "None"},
                 new Component {Name = "Missile Battery", Color = "Black"},
             }
         },
     };
     return View(vehicles);
 }
Exemple #7
0
 public ActionResult PreviewBriefArticle(int articleId)
 {
     var articles = new[] {
         articlesService.GetById(articleId)
     };
     return View("~/Views/Articles/Articles.cshtml", articles);
 }
Exemple #8
0
        /* Eliminated all vbhtml and aspx, and unused locations, and engines*/
        private static void SetupRazor()
        {
            ViewEngines.Engines.Clear();

            var razor = new PrecompiledMvcEngine(typeof(Mvc).Assembly)
                            {
                                UsePhysicalViewsIfNewer = true
                            };

            ViewEngines.Engines.Insert(0, razor);

            // StartPage lookups are done by WebPages.
            VirtualPathFactoryManager.RegisterVirtualPathFactory(razor);

            // Not using areas, not using vbhtmls.
            var areaViewLocations = new string[0];
            var viewLocations = new[] { "~/Views/{1}/{0}.cshtml", "~/Views/Shared/{0}.cshtml" };
            razor.AreaMasterLocationFormats = areaViewLocations;
            razor.AreaPartialViewLocationFormats = areaViewLocations;
            razor.AreaViewLocationFormats = areaViewLocations;
            razor.MasterLocationFormats = viewLocations;
            razor.PartialViewLocationFormats = viewLocations;
            razor.ViewLocationFormats = viewLocations;
            ViewEngines.Engines.Add(razor);
        }
        public static void RegisterRoutes(RouteCollection routes)
        {
            var namespaces = new[] {typeof (PostsController).Namespace};
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

            routes.MapRoute("TagForRealThisTime", "tag/{idAndSlug}", new { controller = "Posts", action = "Tag" },
               namespaces);
            routes.MapRoute("Tag", "tag/{id}-{slug}", new { controller = "Posts", action = "Tag" }, namespaces);

            routes.MapRoute("PostForRealThisTime", "post/{idAndSlug}", new {controller = "Posts", action = "Show"},
                namespaces);
            routes.MapRoute("Post", "post/{id}-{slug}", new { controller = "Posts", action = "Show" }, namespaces);

            routes.MapRoute("Login", "login", new {controller = "Auth", action = "Login"}, namespaces);

            routes.MapRoute("Logout", "logout", new { controller = "Auth", action = "Logout" }, namespaces);

            //empty route "" means the one that shows up when nothing is specified
            routes.MapRoute("Home", "", new { controller = "Posts", action = "index" }, namespaces);

            routes.MapRoute("Sidebar", "", new { controller = "Layout", action = "Sidebar" }, namespaces);

            routes.MapRoute("Error500", "errors/500", new {controller="Errors", action="Error"}, namespaces);
            routes.MapRoute("Error404", "errors/404", new {controller="Errors", action="NotFound"}, namespaces);
        }
 public void CreateActionResultWithObjectReturnsSomethingElse()
 {
     var actionDescriptor = MockRepository.GenerateStub<ActionDescriptor>();
     object actionReturnValue = new {};
     var actionResult = _actionInvoker.CreateActionResult(null, actionDescriptor, actionReturnValue);
     Assert.That(actionResult, Is.Not.EqualTo(actionReturnValue));
 }
        public CustomRazorViewEngine()
        {
            var viewLocations = new[]
            {
                "~/Views/{0}.cshtml",
                "~/Views/{1}/{0}.cshtml",
                "~/Views/Menu/{0}.cshtml",
                //"~/Views/Carlos/{1}/{0}.cshtml",
                //"~/Views/Carlos/Shared/{0}.cshtml",
            };
            this.ViewLocationFormats = viewLocations;
            this.PartialViewLocationFormats = viewLocations;

            #region AREAs
            //var areaViewLocations = new[]
            //{
            //    "~/Views/Carlos/{1}/{0}.cshtml",
            //    "~/Views/Carlos/Shared/{0}.cshtml",
            //    "~/Views/{2}/{1}/{0}.cshtml",	// Coping with Area's
            //    "~/Views/{2}/Shared/{0}.cshtml"
            //};

            //this.AreaPartialViewLocationFormats = areaViewLocations;
            //this.AreaViewLocationFormats = areaViewLocations;
            #endregion
        }
        public ActionResult MoreMovies()
        {
            var movies = new[] {
                    new Movie {
                        Title = "Rounders",
                        ReleaseDate = "1998",
                        RunningTime = "121 mins",
                        Actors = new[] {
                                new Actor("Matt Damon"),
                                new Actor("Edward Norton"),
                                new Actor("John Malcovich"),
                            }
                    },
                    new Movie {
                        Title = "Batman",
                        ReleaseDate = "1989",
                        RunningTime = "126 mins",
                        Actors = new[] {
                                new Actor("Michael Keaton"),
                                new Actor("Jack Nicholson"),
                            }
                    },
                };

            return Json(movies, JsonRequestBehavior.AllowGet);
        }
        public static void Initialize()
        {
            if (_initialized)
                return;

            var namespaces = new[] { "HipChat.Widget.Mvc" };
            var routes = RouteTable.Routes;

            var hipChatWidgetRoute = Settings.Route;

            routes.MapRoute(
                "HipChat.Widget.Mvc",
                string.Format("{0}/{{resource}}", hipChatWidgetRoute),
                new
                {
                    controller = "HipChatWidget",
                    action = "Chat",
                    resource = UrlParameter.Optional
                },
                null,
                namespaces);

            if (hipChatWidgetRoute != "HipChatWidget" && Settings.IgnoreDefaultRoute)
            {
                routes.IgnoreRoute("HipChatWidget");
                routes.IgnoreRoute("HipChatWidget/{*pathinfo}");
            }

            _initialized = true;
        }
Exemple #14
0
		public void PasswordModelBinderShouldReturnValuesForSpecifiedQueryStrings()
		{
			var viewContext = new ViewContext();
			viewContext.HttpContext = MockHttpContext.FakeHttpContext();
			var appraisalCompanyAdminManagement = Substitute.For<IAppraiserManagement>();
			var appraisalCompanyWizardService = Substitute.For<IAppraisalCompanyService>();
		
			var controller = new AppraisalCompanyFeesController(appraisalCompanyWizardService, appraisalCompanyAdminManagement);
			controller.SetFakeControllerContext(viewContext.HttpContext);
			NameValueCollection queryString = new NameValueCollection();

			controller.HttpContext.Request.QueryString.Returns(queryString); 
			PasswordModelBinder target = new PasswordModelBinder();
			var testCases = new[] {
				new {QueryStringParameterName="UserChangePasswordViewModel.NewPassword",Value="17"},
				new {QueryStringParameterName="CreateUserGeneralInfoViewModel.Password",Value="42"},
				new {QueryStringParameterName="Password",Value="2"},
				new {QueryStringParameterName="NewPassword",Value="33"},
				new {QueryStringParameterName="AppraisalCompanyAdmin.Password",Value="asd"},
				new {QueryStringParameterName="GeneralInfo.Password",Value="sssssssssss"},
			};
				
			//act
			foreach (var testCase in testCases)
			{
				queryString.Add(testCase.QueryStringParameterName, testCase.Value);
				
				string result = (string)target.BindModel(controller.ControllerContext, new ModelBindingContext());
				result.Should().BeEquivalentTo(testCase.Value);

				queryString.Remove(testCase.QueryStringParameterName);
			}
		}
        public override void RegisterArea(AreaRegistrationContext context)
        {
            RegisterIoc();
            var ns = new[] { "MvcSolution.Web.Admin.Controllers.*" };
            var defaults = new {controller = "home", action = "index", id = UrlParameter.Optional};

            context.Map("admin/{controller}/{action}/{id}", defaults, ns);
        }
        protected override void RegisterRoutes(RouteCollection routes)
        {
            var defaults = new { controller = "home", action = "index", id = UrlParameter.Optional };
            var ns = new[] { "MvcSolution.Web.Public.Controllers.*" };

            routes.Map("{controller}/{action}/{id}", defaults, ns);

        }
        public ActionResult Index()
        {
            ViewBag.Title = "Home Page test";
            var data = new {firstname = "test", lastname = "lastname"};
            string json = JsonConvert.SerializeObject(data);

            return View();
        }
        public ActionResult Index()
        {
            ViewData["Message"] = "Welcome to ASP.NET MVC!";

            var model = new[] {new Person("John"), new Person("Jack"), new Person("Jill")};

            return new ResultHandledByCodecResult(model);
        }
        public virtual void RegisterArea(RouteCollection routes, ViewEngineCollection viewEngines, IEngine engine)
        {
            var route = new ContentRoute<IManagementHomePart>(engine);
            routes.Insert(0, route);

            var viewLocationFormats = new[] { Url.ResolveTokens("{ManagementUrl}/Myself/Analytics/Views/{1}/{0}.ascx"), Url.ResolveTokens("{ManagementUrl}/Myself/Analytics/Views/Shared/{0}.ascx") };
            viewEngines.Insert(0, new PrivateViewEngineDecorator(new WebFormViewEngine { AreaViewLocationFormats = viewLocationFormats, PartialViewLocationFormats = viewLocationFormats }, route));
        }
        public void GenreMenu_displays_the_list_of_genres()
        {
            var genres = new[] {new GenreVm()};
            catalogFacade.Setup(x => x.GetAllGenres()).Returns(genres);

            var menuResult = (PartialViewResult) storeController.GenreMenu();

            Assert.AreEqual(genres, menuResult.Model);
        }
        public ActionResult PageList(int page, int pageSize)
        {
            int total;
            var list = ExamItemService.PageList(page, pageSize, out total);

            var result = new { Rows = list, Total = total };

            return Json(result);
        }
        public ActionResult World()
        {
            var data = new
                       {
                       	message = "world"
                       };

            return Json(data);
        }
        public virtual JsonResult GetAll()
        {
            var result = new
            {
                locations = _locationService.GetAll(),
            };

            return Json(result, JsonRequestBehavior.AllowGet);
        }
        public override void RegisterArea(AreaRegistrationContext context)
        {
            Ioc.RegisterInheritedTypes(typeof(Services.Admin.IUserService).Assembly, typeof(ServiceBase));

            var ns = new[] { "MvcSolution.Web.Admin.Controllers.*" };

            context.Map("admin", "user", "index", ns);
            context.Map("admin/{controller}/{action}/{id}", new { controller = "home", action = "index", id = UrlParameter.Optional }, ns);
        }
 public ActionResult ResponderTest()
 {
     var data = new { message = "hello world" };
     return RespondTo(format => {
         format.Html = () => View(data.ToExpando());
         format.Json = () => new JsonHttpResult(data);
         format.Xml = () => new XmlHttpResult(data);
     });
 }
 public ActionResult Create(Street street)
 {
     if (_streetService.CreateStreet(street))
     {
         object item = new { value = street.StreetId, name = street.Name };
         return Json(item);
     }
     return View(street);
 }
        public override void RegisterArea(AreaRegistrationContext context)
        {
            RegisterIoc();
            var ns = new[] { "MvcSolution.Web.Public.Controllers.*" };

            context.Map("logout", "account", "logout", ns);
            context.Map("login", "account", "login", ns);
            context.Map("register", "account", "register", ns);
        }
 private void PushDropBoxLinkToCookie(DropBoxLink dropBoxLinkObj)
 {
     var linkObj = new { DROPBOXLINK = dropBoxLinkObj };
     if (Request.Cookies["DROPBOXLINK"] != null)
     {
         Request.Cookies.Remove("DROPBOXLINK");
     }
     Response.Cookies["DROPBOXLINK"].Value = JsonSerializer.SerializeObject(linkObj);
 }
Exemple #29
0
        public static void RegisterRoutes(RouteCollection routes)
        {
            var namespaces = new[] { typeof(PostsController).Namespace };
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

            routes.MapRoute("Login", "login", new { controller = "Auth", action = "Login" }, namespaces);
            routes.MapRoute("Logout", "logout", new { controller = "Auth", action = "Logout" }, namespaces);
            routes.MapRoute("Home", "", new { controller = "Posts", action = "Index" }, namespaces);
        }
        public ActionResult About()
        {
            var data = new
                       {
                       	message = "about"
                       };

            return Json(data);
        }