From d76b0ec17a751c05b32bce7be7f94217e91aaefe Mon Sep 17 00:00:00 2001 From: Pure Krome Date: Tue, 10 Jan 2012 11:16:31 +1100 Subject: [PATCH] - Started adding in Asking a Question. --- .../Controllers/QuestionsController.cs | 43 ++++++++++++++ .../Models/ViewModels/CreateViewModel.cs | 12 ++++ .../Question/QuestionAreaRegistration.cs | 27 +++++++++ .../Question/Views/Questions/Create.cshtml | 45 ++++++++++++++ .../Areas/Question/Views/Web.config | 58 +++++++++++++++++++ Code/RavenOverflow.Web/Global.asax.cs | 25 ++++---- .../RavenOverflow.Web.csproj | 13 +++++ Code/RavenOverflow.Web/Web.config | 1 + Code/RavenOverflow.Web/packages.config | 1 + 9 files changed, 210 insertions(+), 15 deletions(-) create mode 100644 Code/RavenOverflow.Web/Areas/Question/Controllers/QuestionsController.cs create mode 100644 Code/RavenOverflow.Web/Areas/Question/Models/ViewModels/CreateViewModel.cs create mode 100644 Code/RavenOverflow.Web/Areas/Question/QuestionAreaRegistration.cs create mode 100644 Code/RavenOverflow.Web/Areas/Question/Views/Questions/Create.cshtml create mode 100644 Code/RavenOverflow.Web/Areas/Question/Views/Web.config diff --git a/Code/RavenOverflow.Web/Areas/Question/Controllers/QuestionsController.cs b/Code/RavenOverflow.Web/Areas/Question/Controllers/QuestionsController.cs new file mode 100644 index 0000000..c12cb1b --- /dev/null +++ b/Code/RavenOverflow.Web/Areas/Question/Controllers/QuestionsController.cs @@ -0,0 +1,43 @@ +using System.Web.Mvc; +using Raven.Client; +using RavenOverflow.Web.Areas.Question.Models.ViewModels; +using RavenOverflow.Web.Controllers; + +namespace RavenOverflow.Web.Areas.Question.Controllers +{ + public class QuestionsController : AbstractController + { + public QuestionsController(IDocumentSession documentSession) : base(documentSession) + { + } + + public ActionResult Details(int id) + { + return View(); + } + + public ActionResult Create() + { + var viewModel = new CreateViewModel(User.Identity) + { + Header = "Ask a Question" + }; + return View(); + } + + [HttpPost] + public ActionResult Create(FormCollection collection) + { + try + { + // TODO: Add insert logic here + + return RedirectToAction("Index"); + } + catch + { + return View(); + } + } + } +} \ No newline at end of file diff --git a/Code/RavenOverflow.Web/Areas/Question/Models/ViewModels/CreateViewModel.cs b/Code/RavenOverflow.Web/Areas/Question/Models/ViewModels/CreateViewModel.cs new file mode 100644 index 0000000..a80b1c9 --- /dev/null +++ b/Code/RavenOverflow.Web/Areas/Question/Models/ViewModels/CreateViewModel.cs @@ -0,0 +1,12 @@ +using RavenOverflow.Web.Models; +using RavenOverflow.Web.Models.Authentication; + +namespace RavenOverflow.Web.Areas.Question.Models.ViewModels +{ + public class CreateViewModel : _LayoutViewModel + { + public CreateViewModel(ICustomIdentity customIdentity) : base(customIdentity) + { + } + } +} \ No newline at end of file diff --git a/Code/RavenOverflow.Web/Areas/Question/QuestionAreaRegistration.cs b/Code/RavenOverflow.Web/Areas/Question/QuestionAreaRegistration.cs new file mode 100644 index 0000000..5e299ec --- /dev/null +++ b/Code/RavenOverflow.Web/Areas/Question/QuestionAreaRegistration.cs @@ -0,0 +1,27 @@ +using System.Web.Mvc; + +namespace RavenOverflow.Web.Areas.Question +{ + public class QuestionAreaRegistration : AreaRegistration + { + public override string AreaName + { + get { return "Question"; } + } + + public override void RegisterArea(AreaRegistrationContext context) + { + context.MapRoute( + "Question - ask", + "Question/ask", + new { controller = "Questions", action = "Create" } + ); + + context.MapRoute( + "Question_default", + "Question/{action}/{id}", + new { controller = "Questions", action = "Index", id = UrlParameter.Optional } + ); + } + } +} \ No newline at end of file diff --git a/Code/RavenOverflow.Web/Areas/Question/Views/Questions/Create.cshtml b/Code/RavenOverflow.Web/Areas/Question/Views/Questions/Create.cshtml new file mode 100644 index 0000000..7ab59a8 --- /dev/null +++ b/Code/RavenOverflow.Web/Areas/Question/Views/Questions/Create.cshtml @@ -0,0 +1,45 @@ +@using RavenOverflow.Web.Areas.Question.Models.ViewModels +@model CreateViewModel +@{ + Layout = "~/Views/Shared/_Layout.cshtml"; +} + +@section Header +{ + @Model.Header +} + +@section SideBar +{ +
How to Ask a Question
+} + +@using (Html.BeginForm()) +{ +
+ + + + + + + +
+ + + +
+
+
+
+
+ +
+
+ + +
 at least one tag such as (asp.net xml c++), max 5 tags
+ at least one tag such as (asp.net xml c++), max 5 tags +
+ +} \ No newline at end of file diff --git a/Code/RavenOverflow.Web/Areas/Question/Views/Web.config b/Code/RavenOverflow.Web/Areas/Question/Views/Web.config new file mode 100644 index 0000000..a4def2a --- /dev/null +++ b/Code/RavenOverflow.Web/Areas/Question/Views/Web.config @@ -0,0 +1,58 @@ + + + + + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Code/RavenOverflow.Web/Global.asax.cs b/Code/RavenOverflow.Web/Global.asax.cs index d67e903..5583891 100644 --- a/Code/RavenOverflow.Web/Global.asax.cs +++ b/Code/RavenOverflow.Web/Global.asax.cs @@ -1,22 +1,20 @@ using System; +using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; using System.Web.Routing; -using Raven.Abstractions.Data; using Raven.Client; using Raven.Client.MvcIntegration; using RavenOverflow.Core.Entities; using RavenOverflow.FakeData; -using System.Collections.Generic; using RavenOverflow.Web.Indexes; using RavenOverflow.Web.Models.Authentication; using StructureMap; namespace RavenOverflow.Web { - // Note: For instructions on enabling IIS6 or IIS7 classic mode, - // visit http://go.microsoft.com/?LinkId=9394801 + // ReSharper disable InconsistentNaming public class MvcApplication : HttpApplication { @@ -33,7 +31,7 @@ public static void RegisterRoutes(RouteCollection routes) routes.MapRoute( "Default", // Route name "{controller}/{action}/{id}", // URL with parameters - new {controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults + new {controller = "Home", action = "Index", id = UrlParameter.Optional} // Parameter defaults ); } @@ -43,9 +41,7 @@ private static void RegisterRazorViewEngine() ViewEngines.Engines.Add(new RazorViewEngine()); } - // ReSharper disable InconsistentNaming protected void Application_Start() - // ReSharper restore InconsistentNaming { AreaRegistration.RegisterAllAreas(); @@ -66,25 +62,24 @@ protected void Application_Start() RavenProfiler.InitializeFor(ObjectFactory.GetInstance()); } - // ReSharper disable InconsistentNaming protected void Application_AuthenticateRequest() - // ReSharper restore InconsistentNaming + { CustomFormsAuthentication.AuthenticateRequestDecryptCustomFormsAuthenticationTicket(Context); } private static void SeedDocumentStore(IDocumentStore documentStore) { - using (var session = documentStore.OpenSession()) + using (IDocumentSession session = documentStore.OpenSession()) { // Don't add any seed data, if we already have some data in the system. - var user = session.Query().Take(1).ToList(); + List user = session.Query().Take(1).ToList(); if (user.Any()) { return; } - var users = FakeUsers.CreateFakeUsers(); + ICollection users = FakeUsers.CreateFakeUsers(); StoreEntites(session, users); @@ -106,12 +101,12 @@ private static void StoreEntites(IDocumentSession session, IEnumerable ..\..\packages\RavenDB.1.0.573\lib\net40\Raven.Client.MvcIntegration.dll + + ..\..\packages\routedebugger.2.1.2\lib\net40\RouteDebugger.dll + ..\..\packages\structuremap.2.6.3\lib\StructureMap.dll @@ -107,6 +110,9 @@ + + + @@ -154,6 +160,7 @@ + @@ -211,6 +218,12 @@ + + + + + + diff --git a/Code/RavenOverflow.Web/packages.config b/Code/RavenOverflow.Web/packages.config index 35841d9..74aa268 100644 --- a/Code/RavenOverflow.Web/packages.config +++ b/Code/RavenOverflow.Web/packages.config @@ -7,6 +7,7 @@ +