From a4d2e1b6daed68c42206847568d83d3fefd18c19 Mon Sep 17 00:00:00 2001 From: Paul Schneider Date: Tue, 23 Sep 2014 03:27:51 +0200 Subject: [PATCH] Fixes the blog post removal --- web/Controllers/BlogsController.cs | 4 ++++ web/Views/Blogs/Index.aspx | 2 +- web/Views/Blogs/RemovePost.aspx | 16 +++++++++------- web/Views/Blogs/UserPost.aspx | 2 +- web/Views/Blogs/UserPosts.aspx | 2 +- 5 files changed, 16 insertions(+), 10 deletions(-) diff --git a/web/Controllers/BlogsController.cs b/web/Controllers/BlogsController.cs index 4867b539..6c86fed2 100644 --- a/web/Controllers/BlogsController.cs +++ b/web/Controllers/BlogsController.cs @@ -245,6 +245,10 @@ namespace Yavsc.Controllers [Authorize] public ActionResult RemovePost (string user, string title, string returnUrl, bool confirm=false) { + if (returnUrl == null) + if (Request.UrlReferrer!=null) + returnUrl = Request.UrlReferrer.AbsoluteUri; + ViewData["returnUrl"]=returnUrl; if (!confirm) return View ("RemovePost"); HttpStatusCodeResult res = BlogsApiController.RemovePost (user,title); diff --git a/web/Views/Blogs/Index.aspx b/web/Views/Blogs/Index.aspx index e8dd06e3..e88ab358 100644 --- a/web/Views/Blogs/Index.aspx +++ b/web/Views/Blogs/Index.aspx @@ -18,7 +18,7 @@ if (Membership.GetUser().UserName==e.UserName) { %> <%= Html.ActionLink("Editer","Edit", new { user = e.UserName, title = e.Title }, new { @class="actionlink" }) %> - <%= Html.ActionLink("Supprimer","Remove", new { user = e.UserName, title = e.Title }, new { @class="actionlink" } ) %> + <%= Html.ActionLink("Supprimer","RemovePost", new { user = e.UserName, title = e.Title }, new { @class="actionlink" } ) %> <% } %> diff --git a/web/Views/Blogs/RemovePost.aspx b/web/Views/Blogs/RemovePost.aspx index cbae36bc..96b7b2cb 100644 --- a/web/Views/Blogs/RemovePost.aspx +++ b/web/Views/Blogs/RemovePost.aspx @@ -9,20 +9,22 @@ -
+ <%= Html.ValidationSummary() %> -<% using (Html.BeginForm("Remove","Blogs")) { %> - suivant : -<%= Html.LabelFor(model => model.Title) %>:
+<% using (Html.BeginForm("RemovePost","Blogs")) { %> + +<%= Html.LabelFor(model => model.Title) %> : <%= Html.TextBox( "Title" ) %> -<%= Html.ValidationMessage("Title", "*") %> +<%= Html.ValidationMessage("Title", "*") %>
+ - +<%= Html.CheckBox( "confirm" ) %> <%= Html.ValidationMessage("AgreeToRemove", "*") %> +<%= Html.Hidden("returnUrl") %> <% } %> -
+
diff --git a/web/Views/Blogs/UserPost.aspx b/web/Views/Blogs/UserPost.aspx index 37398b11..2388abcf 100644 --- a/web/Views/Blogs/UserPost.aspx +++ b/web/Views/Blogs/UserPost.aspx @@ -10,7 +10,7 @@ if (Membership.GetUser().UserName==Model.UserName) { %> <%= Html.ActionLink("Editer","Edit", new { user=Model.UserName, title = Model.Title }, new { @class="actionlink" }) %> - <%= Html.ActionLink("Supprimer","Remove", new { user=Model.UserName, title = Model.Title }, new { @class="actionlink" } ) %> + <%= Html.ActionLink("Supprimer","RemovePost", new { user=Model.UserName, title = Model.Title }, new { @class="actionlink" } ) %> <% } %> diff --git a/web/Views/Blogs/UserPosts.aspx b/web/Views/Blogs/UserPosts.aspx index 97c6ccfb..2f1e6b24 100644 --- a/web/Views/Blogs/UserPosts.aspx +++ b/web/Views/Blogs/UserPosts.aspx @@ -21,7 +21,7 @@ if (Membership.GetUser().UserName==e.UserName) { %> <%= Html.ActionLink("Editer","Edit", new { user = e.UserName, title = e.Title }, new { @class="actionlink" }) %> - <%= Html.ActionLink("Supprimer","Remove", new { user = e.UserName, title = e.Title }, new { @class="actionlink" } ) %> + <%= Html.ActionLink("Supprimer","RemovePost", new { user = e.UserName, title = e.Title }, new { @class="actionlink" } ) %> <% } %> <% } %>