diff --git a/NpgsqlBlogProvider/ChangeLog b/NpgsqlBlogProvider/ChangeLog index ecc22d5b..a0a13022 100644 --- a/NpgsqlBlogProvider/ChangeLog +++ b/NpgsqlBlogProvider/ChangeLog @@ -1,3 +1,7 @@ +2015-10-13 Paul Schneider + + * NpgsqlBlogProvider.cs: implements the tag methods on db + 2015-10-10 Paul Schneider * NpgsqlBlogProvider.cs: diff --git a/NpgsqlBlogProvider/NpgsqlBlogProvider.cs b/NpgsqlBlogProvider/NpgsqlBlogProvider.cs index 7b8bba2e..2f611ce8 100644 --- a/NpgsqlBlogProvider/NpgsqlBlogProvider.cs +++ b/NpgsqlBlogProvider/NpgsqlBlogProvider.cs @@ -7,6 +7,7 @@ using Yavsc.Model.Blogs; using Yavsc.Model.Circles; using System.Web.Mvc; using NpgsqlTypes; +using System.Linq; namespace Npgsql.Web.Blog { @@ -19,34 +20,51 @@ namespace Npgsql.Web.Blog string connectionString; #region implemented abstract members of BlogProvider + /// - /// Tag the specified postid and tag. + /// Tag the specified post by identifier + /// using the given tag. /// /// Postid. - /// Tag. - public override long Tag (long postid, string tag) + /// Tag name. + public override long Tag (long postid, string tagname) { + long tid = GetOrCreateTagId (tagname); using (NpgsqlConnection cnx = new NpgsqlConnection (connectionString)) using (NpgsqlCommand cmd = cnx.CreateCommand ()) { - cmd.CommandText = "insert into bltag (blid,tag) values (:postid,:tag) returning _id"; - cmd.Parameters.AddWithValue("tag",tag); - cmd.Parameters.AddWithValue("postid",postid); + cmd.CommandText = "INSERT INTO tagged (tagid,postid) VALUES (:tid,:pid)"; + cmd.Parameters.AddWithValue("tid",tid); + cmd.Parameters.AddWithValue("pid",postid); cnx.Open (); - return (long) cmd.ExecuteScalar (); + cmd.ExecuteNonQuery (); + return tid; } } + /// - /// Removes the tag. + /// Uns the tag. /// + /// Postid. /// Tagid. - public override void RemoveTag (long tagid) - { + /// Name. + override public void Untag(long postid, string name) { + Untag(postid, GetTagId (name)); + } + + /// + /// Uns the tag. + /// + /// Postid. + /// Tagid. + /// Tid. + override public void Untag(long postid, long tid) { using (NpgsqlConnection cnx = new NpgsqlConnection (connectionString)) using (NpgsqlCommand cmd = cnx.CreateCommand ()) { - cmd.CommandText = "delete from bltag where _id = :tagid"; - cmd.Parameters.AddWithValue("tagid",tagid); + cmd.CommandText = "DELETE FROM tagged WHERE postid = :pid AND tagid = :tid"; + cmd.Parameters.AddWithValue ("pid", postid); + cmd.Parameters.AddWithValue ("tid", tid); cnx.Open (); - cmd.ExecuteNonQuery (); + cmd.ExecuteNonQuery (); } } /// @@ -257,7 +275,7 @@ namespace Npgsql.Web.Blog } } } - if (be!=null) SetCirclesOn (be); + if (be!=null) Populate (be); return be; } @@ -334,8 +352,7 @@ namespace Npgsql.Web.Blog be.Tags = tags.ToArray (); } } - - SetCirclesOn (bec); + if (bec!=null) Populate (bec); } } return bec; @@ -359,11 +376,103 @@ namespace Npgsql.Web.Blog be.AllowedCircles = circles.ToArray (); } - private void SetCirclesOn(BlogEntryCollection bec) - { + /// + /// Removes the tag. + /// + /// Tagid. + public override void DropTag(long tagid) + { + using (NpgsqlConnection cnx = new NpgsqlConnection (connectionString)) + using (NpgsqlCommand cmd = cnx.CreateCommand ()) { + cmd.CommandText = "DELETE from public.tag where _id = :tid"; + cmd.Parameters.AddWithValue("tagid",tagid); + cnx.Open (); + cmd.ExecuteNonQuery (); + cnx.Close (); + } + } + + private static string SelectTagsSql = "SELECT tag.name, tag._id FROM public.tag WHERE name like :name"; + private IEnumerable GetSuggestion (string pattern) { + using (NpgsqlConnection cnx = new NpgsqlConnection (connectionString)) + using (NpgsqlCommand cmd = cnx.CreateCommand ()) { + cmd.CommandText = SelectTagsSql; + throw new NotImplementedException (); + } + } + + private static string InsertTagSql = "INSERT INTO tag (name) VALUES (:name) returning _id"; + private void InsertTag(long postid, long tagid) + { + using (NpgsqlConnection cnx = new NpgsqlConnection (connectionString)) + using (NpgsqlCommand cmd = cnx.CreateCommand ()) { + cmd.CommandText = InsertTagSql; + throw new NotImplementedException (); + } + } + + private long GetTagId(string tagname) + { + long id = 0; + using (NpgsqlConnection cnx = new NpgsqlConnection (connectionString)) + using (NpgsqlCommand cmd = cnx.CreateCommand ()) { + cmd.CommandText = "SELECT tag._id FROM public.tag WHERE name = :name"; + cmd.Parameters.AddWithValue ("name", tagname); + cnx.Open (); + id = (long) cmd.ExecuteScalar (); + } + return id; + } + private long GetOrCreateTagId(string tagname) + { + long id = 0; + using (NpgsqlConnection cnx = new NpgsqlConnection (connectionString)) + using (NpgsqlCommand cmd = cnx.CreateCommand ()) { + cmd.CommandText = "SELECT tag._id FROM public.tag WHERE name = :name;\n" + + "IF NOT FOUND THEN INSERT INTO tag (name) values (:name) RETURNING _id; ENDIF;\n"; + cmd.Parameters.AddWithValue ("name", tagname); + cnx.Open (); + id = (long) cmd.ExecuteScalar (); + } + return id; + } + + + + private static string SelectPostTagsSql = "SELECT tag.name FROM public.tag, public.tagged\n" + + "WHERE tag._id = tagged.tagid AND tagged.postid = :pid \n"; + private void SetTagsOn(BlogEntryCollection bec){ foreach (BlogEntry be in bec) { - SetCirclesOn (be); + SetTagsOn (be); + } + } + private void SetTagsOn(BlogEntry be) + { + List tags = new List (); + using (NpgsqlConnection cnx = new NpgsqlConnection (connectionString)) + using (NpgsqlCommand cmdtags = cnx.CreateCommand ()) { + cmdtags.CommandText = SelectPostTagsSql; + cmdtags.Parameters.AddWithValue ("pid", be.Id); + cnx.Open (); + using (NpgsqlDataReader rdr = cmdtags.ExecuteReader ()) { + while (rdr.Read ()) { + tags.Add (rdr.GetString (0)); + } + } } + be.Tags = tags.ToArray (); + } + + // Assert(bec!=null); + private void Populate(BlogEntryCollection bec) + { + foreach (BlogEntry be in bec) Populate(be); + } + + private void Populate(BlogEntry be) + { + SetTagsOn (be); + SetCirclesOn (be); } /// /// Post the specified username, title, content and visible. @@ -487,6 +596,15 @@ namespace Npgsql.Web.Blog } cmd.Parameters.AddWithValue ("appname", applicationName); if (pattern != null) { + if ((searchflags & FindBlogEntryFlags.MatchTag) > 0) { + cmd.CommandText += + "AND EXISTS (SELECT tag._id FROM public.tag, public.tagged WHERE " + + "public.tag._id = public.tagged.tagid " + + "AND public.tagged.postid = a.post_id " + + "public.tag.name like :tagname) "; + cmd.Parameters.AddWithValue ("tagname", pattern); + } + if ((searchflags & FindBlogEntryFlags.MatchContent) > 0) { cmd.CommandText += " and bcontent like :bcontent"; cmd.Parameters.AddWithValue ("bcontent", pattern); @@ -532,8 +650,7 @@ namespace Npgsql.Web.Blog rdr.Close (); } } - foreach (BlogEntry be in c) - SetCirclesOn (be); + if (c!=null) Populate (c); return c; } @@ -602,8 +719,7 @@ namespace Npgsql.Web.Blog } } } - foreach (BlogEntry be in c) - SetCirclesOn (be); + if (c!=null) Populate (c); return c; } #endregion diff --git a/TestAPI/BlogUnitTest.cs b/TestAPI/AccountUnitTestCase.cs similarity index 58% rename from TestAPI/BlogUnitTest.cs rename to TestAPI/AccountUnitTestCase.cs index be591a08..78679641 100644 --- a/TestAPI/BlogUnitTest.cs +++ b/TestAPI/AccountUnitTestCase.cs @@ -24,27 +24,55 @@ using Yavsc.Model.Blogs; using Yavsc.Controllers; using System.Web.Mvc; using System.Web.Security; +using System.Web.Configuration; +using System.Configuration; +using System.IO; +using System.Web.Http; -namespace TestAPI +namespace Yavsc { + [TestFixture ()] - public class BlogUnitTest + public class AccountUnitTestCase { public string UserName { get; set; } public string Email { get; set; } public string Password { get; set; } - AccountController accountController; - [TestFixtureSetUp] - public void Init() + + public AccountController AccountController { + get { + return accountController; + } + } + string defaultMembershipProvider = null; + [Test] + public virtual void Init() { + webSource = new XSPWebSource (configurationManager.Address, configurationManager.Port, !root); + + + var server = new ApplicationServer (webSource, configurationManager.Root) { + Verbose = configurationManager.Verbose, + SingleApplication = !root + }; + string basedir = AppDomain.CurrentDomain.BaseDirectory; + string curdir = Directory.GetCurrentDirectory (); + string dummyVirtualPath = "/"; + string physicalPath = @"/home/paul/workspace/totem/web/"; + WebConfigurationFileMap map = new WebConfigurationFileMap (); + map.VirtualDirectories.Add(dummyVirtualPath, new VirtualDirectoryMapping(physicalPath, true)); + Configuration configuration = WebConfigurationManager.OpenMappedWebConfiguration(map, dummyVirtualPath); accountController = new AccountController (); + string da = (string) configuration.AppSettings.Settings ["DefaultAvatar"].Value; + MembershipSection s = configuration.GetSection ("system.web/membership") as MembershipSection; + defaultMembershipProvider = s.DefaultProvider; } [Test ()] - public void Register () + public virtual void Register () { ViewResult actionResult = accountController.Register ( new Yavsc.Model.RolesAndMembers.RegisterViewModel () { @@ -53,7 +81,7 @@ namespace TestAPI IsApprouved = true }, "/testreturnurl") as ViewResult; - Assert.AreEqual (actionResult.ViewName, "RegistrationPending"); + Assert.AreSame ("",actionResult.ViewName); MembershipUser u = Membership.GetUser (UserName, false); Assert.NotNull (u); Assert.False (u.IsApproved); @@ -64,8 +92,9 @@ namespace TestAPI Membership.UpdateUser (u); Assert.True (u.IsApproved); } + [TestFixtureTearDown()] - public void Unregister() + public virtual void Unregister() { ViewResult actionResult = accountController.Unregister (UserName, true) as ViewResult; diff --git a/TestAPI/BlogUnitTestCase.cs b/TestAPI/BlogUnitTestCase.cs new file mode 100644 index 00000000..4836f416 --- /dev/null +++ b/TestAPI/BlogUnitTestCase.cs @@ -0,0 +1,52 @@ +// +// TagTestCases.cs +// +// Author: +// Paul Schneider +// +// Copyright (c) 2015 GNU GPL +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program. If not, see . +using NUnit.Framework; +using System; +using Yavsc.Model.Blogs; + +namespace Yavsc +{ + [TestFixture ()] + public class BlogUnitTestCase: AccountUnitTestCase + { + + [TestFixtureSetUp] + void NeedAPost() + { + Register (); + } + + [Test ()] + public void TestCase () + { + long pid = BlogManager.Post (UserName, "BlogUnitTestCase", "content", true, null); + BlogManager.Tag (pid, "test"); + + } + + [TestFixtureTearDown()] + void Cleanup() + { + Unregister (); + } + } +} + diff --git a/web/Test/TestByteA.cs b/TestAPI/TestByteA.cs similarity index 100% rename from web/Test/TestByteA.cs rename to TestAPI/TestByteA.cs diff --git a/TestAPI/Web.config b/TestAPI/Web.config new file mode 100644 index 00000000..dcc7e6c2 --- /dev/null +++ b/TestAPI/Web.config @@ -0,0 +1,124 @@ + + + + + +
+ +
+
+
+
+ + + +
+ +
+
+
+
+
+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/WebControls/ChangeLog b/WebControls/ChangeLog index efe3e9e7..0289448f 100644 --- a/WebControls/ChangeLog +++ b/WebControls/ChangeLog @@ -1,3 +1,8 @@ +2015-10-13 Paul Schneider + + * ResultPages.cs: A multi-pages result meta info when one page + only + 2015-10-04 Paul Schneider * ResultPages.cs: . diff --git a/WebControls/ResultPages.cs b/WebControls/ResultPages.cs index f3232106..46e756fb 100644 --- a/WebControls/ResultPages.cs +++ b/WebControls/ResultPages.cs @@ -91,6 +91,21 @@ namespace Yavsc.WebControls } } + /// + /// Gets or sets the Single page message. + /// + /// The none. + [Bindable (true)] + [DefaultValue("1")] + public string SinglePage { + get { + return (string) ViewState["SinglePage"]; + } + set { + ViewState["SinglePage"] = value; + } + } + /// /// Gets or sets the none. /// @@ -105,7 +120,20 @@ namespace Yavsc.WebControls ViewState["None"] = value; } } - + /// + /// Gets or sets the none. + /// + /// The none. + [Bindable (true)] + [DefaultValue("Pages: ")] + public string PagesLabel { + get { + return (string) ViewState["PagesLabel"]; + } + set { + ViewState["PagesLabel"] = value; + } + } /// /// Gets or sets the current page. /// @@ -132,6 +160,7 @@ namespace Yavsc.WebControls writer.WriteEncodedText (Text); int pageCount = ((ResultCount-1) / PageSize) + 1; if ( pageCount > 1 ) { + writer.Write (PagesLabel); for (int pi = (PageIndex < 5) ? 0 : PageIndex - 5; pi < pageCount && pi < PageIndex + 5; pi++) { if (PageIndex == pi) writer.RenderBeginTag ("b"); @@ -144,6 +173,9 @@ namespace Yavsc.WebControls writer.RenderEndTag (); writer.Write (" "); } + } + else { + writer.Write (SinglePage); } } if (ResultCount == 0) { diff --git a/web/ApiControllers/AccountController.cs b/web/ApiControllers/AccountController.cs index 1a7e2362..a9180291 100644 --- a/web/ApiControllers/AccountController.cs +++ b/web/ApiControllers/AccountController.cs @@ -39,10 +39,11 @@ namespace Yavsc.ApiControllers /// Register the specified model. ///
/// Model. - [Authorize()] + [Authorize ()] [ValidateAjaxAttribute] public HttpResponseMessage Register ([FromBody] RegisterClientModel model) { + if (ModelState.IsValid) { if (model.IsApprouved) if (!Roles.IsUserInRole ("Admin")) @@ -54,32 +55,32 @@ namespace Yavsc.ApiControllers } MembershipCreateStatus mcs; var user = Membership.CreateUser ( - model.UserName, - model.Password, - model.Email, - model.Question, - model.Answer, - model.IsApprouved, - out mcs); + model.UserName, + model.Password, + model.Email, + model.Question, + model.Answer, + model.IsApprouved, + out mcs); switch (mcs) { case MembershipCreateStatus.DuplicateEmail: ModelState.AddModelError ("Email", "Cette adresse e-mail correspond " + - "à un compte utilisateur existant"); + "à un compte utilisateur existant"); break; case MembershipCreateStatus.DuplicateUserName: ModelState.AddModelError ("UserName", "Ce nom d'utilisateur est " + - "déjà enregistré"); + "déjà enregistré"); break; case MembershipCreateStatus.Success: if (!model.IsApprouved) Url.SendActivationMessage (user); ProfileBase prtu = ProfileBase.Create (model.UserName); - prtu.SetPropertyValue("Name",model.Name); - prtu.SetPropertyValue("Address",model.Address); - prtu.SetPropertyValue("CityAndState",model.CityAndState); - prtu.SetPropertyValue("Mobile",model.Mobile); - prtu.SetPropertyValue("Phone",model.Phone); - prtu.SetPropertyValue("ZipCode",model.ZipCode); + prtu.SetPropertyValue ("Name", model.Name); + prtu.SetPropertyValue ("Address", model.Address); + prtu.SetPropertyValue ("CityAndState", model.CityAndState); + prtu.SetPropertyValue ("Mobile", model.Mobile); + prtu.SetPropertyValue ("Phone", model.Phone); + prtu.SetPropertyValue ("ZipCode", model.ZipCode); break; default: break; @@ -88,15 +89,12 @@ namespace Yavsc.ApiControllers return DefaultResponse (); } - - - /// /// Resets the password. /// /// Model. [ValidateAjax] - public void ResetPassword(LostPasswordModel model) + public void ResetPassword (LostPasswordModel model) { StringDictionary errors; MembershipUser user; @@ -108,4 +106,3 @@ namespace Yavsc.ApiControllers } } } - diff --git a/web/ApiControllers/BlogsController.cs b/web/ApiControllers/BlogsController.cs index 2ba096a1..6da541b5 100644 --- a/web/ApiControllers/BlogsController.cs +++ b/web/ApiControllers/BlogsController.cs @@ -40,9 +40,19 @@ namespace Yavsc.ApiControllers ///
/// Postid. /// Tag. - public long Tag (long postid,string tag) { + public void Tag (long postid,string tag) { BlogManager.GetForEditing (postid); - return BlogManager.Tag (postid, tag); + BlogManager.Tag (postid, tag); + } + + /// + /// Untag the specified postid and tag. + /// + /// Postid. + /// Tag. + public void Untag (long postid,string tag) { + BlogManager.GetForEditing (postid); + BlogManager.Untag (postid, tag); } /// @@ -57,6 +67,7 @@ namespace Yavsc.ApiControllers throw new AuthorizationDenied (user); BlogManager.RemoveTitle (user, title); } + /// /// Removes the tag. /// @@ -65,6 +76,7 @@ namespace Yavsc.ApiControllers throw new NotImplementedException (); } + /// /// The allowed media types. /// @@ -125,9 +137,9 @@ namespace Yavsc.ApiControllers } } + /// - /// Searchs the files accociated to the given post id, - /// or related to the given terms. + /// Searchs the file. /// /// The file. /// Postid. @@ -165,7 +177,8 @@ namespace Yavsc.ApiControllers try { // Read the form data. - IEnumerable data = await Request.Content.ReadAsMultipartAsync(provider) ; + //IEnumerable data = + await Request.Content.ReadAsMultipartAsync(provider) ; var invalidChars = Path.GetInvalidFileNameChars(); List bodies = new List(); @@ -182,10 +195,7 @@ namespace Yavsc.ApiControllers FileInfo fp = new FileInfo (Path.Combine(root,filename)); if (fi.Exists) fi.Delete(); fp.MoveTo(fi.FullName); - // Get the mime type - - - + // TODO Get the mime type using (Process p = new Process ()) { p.StartInfo.WorkingDirectory = root; p.StartInfo = new ProcessStartInfo (); diff --git a/web/instdbws.sql b/web/App_Data/instdbws.sql similarity index 100% rename from web/instdbws.sql rename to web/App_Data/instdbws.sql diff --git a/web/App_Themes/style.css b/web/App_Themes/style.css index c3de49d2..0918f8dd 100644 --- a/web/App_Themes/style.css +++ b/web/App_Themes/style.css @@ -8,13 +8,8 @@ body { margin: 0; } - .iconsmall { max-height: 1.3em; max-width: 1.3em; } -input, textarea, checkbox { - color: #FFFFA0; - background-color: black; - } .photo { width: 100%; } .blogbanner { float: left; top:0; } @@ -76,7 +71,7 @@ legend { footer p { display:inline-block; } footer img { max-height: 2em; vertical-align: middle; } -a.actionlink img, h1 img, .menuitem img { vertical-align: middle; } +a img, h1 img, .menuitem img { max-height: 1em; vertical-align: middle; } #gspacer { background-color: rgba(20,20,20,.8); @@ -116,7 +111,7 @@ aside { margin:1em; padding:1em; background-color: rgba(0,0,32,0.8); - color: #aaa; + color: #eee; border-radius:10px; } .hiddenpost { background-color: rgba(16,16,16,0.5); } @@ -167,14 +162,13 @@ content: ")"; .usertitleref { - color: #B0B080; border-radius: 5px; background-color:rgba(0,0,32,0.6); font-family: 'Arial', cursive; padding: 1em; } a:visited { - color: #90B090; + color: #E0E0E0; } label { font-size: medium; @@ -186,7 +180,8 @@ label { border: dashed rgb(020,20,256) 2px; } #notifications { - padding: .5em; + margin: 2em; + padding: 2em; } .notification { @@ -227,30 +222,33 @@ a { } .actionlink, .menuitem, a { - color: #B0B080; + display:inline-block; + color: white; border-radius:1em; border: solid black 1px; background-color: rgba(20,20,20,.8); cursor: pointer; font-family: 'Arial', cursive; - padding: .2em; - display: inline-block; + padding: 1em; + margin:1em; } -input, select { - color: #B0B080; +input, select, textarea { + color: white; + background-color:rgba(0,0,64,0.8); border: solid 1px rgb(128,128,128); border-radius:1em; - background-color:rgba(0,0,32,0.8); - font-family: 'Arial', cursive; + font-family: 'Arial', cursive; } - -.actionlink:hover, fa:hover, .menuitem:hover, a:hover, input:hover { +.actionlink:hover, fa:hover, .menuitem:hover, a:hover { background-color:rgba(30,0,124,0.9); border: solid green 1px; } - + input:hover, textarea:hover { + color: white; + background-color:rgba(64,64,64,0.8); +} .code { font-family: "monospace"; background-color: rgba(0,0,256,0.1); @@ -273,14 +271,6 @@ input, select { font-size: smaller; } - -.menuitem { - border-radius:5px; - margin:.5em; - padding:.5em; - display: inline-block; -} - .onhover { display:none; position: absolute; @@ -300,7 +290,7 @@ input, select { .c3 { font-size: x-small; font-style: italic; } @media print { body {background-color:white;color:black;} - .control,.actionlink,nav { display:none;} + .control, .actionlink, .menuitem, nav { display:none;} } .bshpanel { display:block; } diff --git a/web/ChangeLog b/web/ChangeLog index a0b30c97..797a34bf 100644 --- a/web/ChangeLog +++ b/web/ChangeLog @@ -1,3 +1,38 @@ +2015-10-13 Paul Schneider + + * Index.aspx: + * Title.aspx: + * yavsc.scrollnotif.js: + * AccountController.cs: refactoring + + * yavsc.tags.js: Implements a js call + to the tag & untag methods + + * PostActions.ascx: a better html structure + + * yavsc.circles.js: + * AccountController.cs: code formatting + + * BlogsController.cs: Untag a post + + * style.css: yastyle, yet a better one. + + * BlogsController.cs: View the Title after edition + + * App.master: + * UserPosts.aspx: a nicer html structure + + * yavsc.js: Fixes notice & dimiss js + + * Login.aspx: refactoring + + * Edit.aspx: better html + + * UserPost.aspx: A promess to be allowed to tag. + + * Web.csproj: Adds yavsc.tags.js and yavsc.scrollnotifs.js to + the project decription. + 2015-10-10 Paul Schneider * Web.csproj: diff --git a/web/Controllers/AccountController.cs b/web/Controllers/AccountController.cs index e7a74cc6..1f763956 100644 --- a/web/Controllers/AccountController.cs +++ b/web/Controllers/AccountController.cs @@ -92,12 +92,15 @@ namespace Yavsc.Controllers } /// - /// Registers the form. + /// Gets the registration form. /// - /// The form. - public ActionResult RegisterForm() + /// The register. + /// Model. + /// Return URL. + public ActionResult GetRegister(RegisterViewModel model, string returnUrl) { - return View ("Register"); + ViewData ["returnUrl"] = returnUrl; + return View ("Register",model); } /// @@ -109,11 +112,6 @@ namespace Yavsc.Controllers public ActionResult Register (RegisterViewModel model, string returnUrl) { ViewData ["returnUrl"] = returnUrl; - if (Request.RequestType == "GET") { - foreach (string k in ModelState.Keys) - ModelState [k].Errors.Clear (); - return View (model); - } if (ModelState.IsValid) { if (model.ConfirmPassword != model.Password) { diff --git a/web/Controllers/BlogsController.cs b/web/Controllers/BlogsController.cs index 2a1c7514..ad688cdc 100644 --- a/web/Controllers/BlogsController.cs +++ b/web/Controllers/BlogsController.cs @@ -71,7 +71,7 @@ namespace Yavsc.Controllers /// /// Title the specified title, pageIndex and pageSize. /// - /// Title. + /// Title. /// Page index. /// Page size. /// @@ -289,7 +289,7 @@ namespace Yavsc.Controllers model.Id = BlogManager.Post (model.Author, model.Title, model.Content, model.Visible, model.AllowedCircles); if (model.Photo != null) BlogManager.UpdatePostPhoto (model.Id, model.Photo); - return RedirectToAction ("UserPosts", new { user = model.Author, title = model.Title }); + return RedirectToAction ("Title", new { id = model.Title }); } ViewData ["AllowedCircles"] = CircleManager.DefaultProvider.List ( diff --git a/web/Models/App.master b/web/Models/App.master index 13d6f066..fdeb027e 100644 --- a/web/Models/App.master +++ b/web/Models/App.master @@ -19,7 +19,8 @@ - + + @@ -46,6 +47,7 @@ Yavsc.notice('<%=notice%>');