Browse Source

Fixed not being able to edit main blog

tags/2.0.3
Teknikode 4 years ago
parent
commit
5040f98cf6

+ 2
- 2
Teknik/Areas/Blog/Controllers/BlogController.cs View File

@@ -116,7 +116,7 @@ namespace Teknik.Areas.Blog.Controllers
return View("~/Areas/Blog/Views/Blog/ViewPost.cshtml", model);
}
public ActionResult NewPost(string username)
public ActionResult NewPost(string username, int blogID)
{
if (string.IsNullOrEmpty(username))
{
@@ -125,7 +125,7 @@ namespace Teknik.Areas.Blog.Controllers
BlogViewModel model = new BlogViewModel();
// find the post specified
bool isAuth = User.IsInRole("Admin");
var blog = db.Blogs.Where(p => (p.User.Username == username) && (p.User.Username == User.Identity.Name || isAuth)).FirstOrDefault();
var blog = db.Blogs.Where(p => (p.BlogId == blogID) && (p.User.Username == User.Identity.Name || isAuth)).FirstOrDefault();
if (blog != null)
{
model = new BlogViewModel(blog);

+ 2
- 2
Teknik/Areas/Blog/Views/Blog/Blog.cshtml View File

@@ -4,8 +4,8 @@

<script>
// We need to define the action URLs for the script

var uploadURL = '@Url.SubRouteUrl("upload", "Upload.Upload")';
var helpURL = '@Url.SubRouteUrl("help", "Help.Markdown")';

var getPostsURL = '@Url.SubRouteUrl("blog", "Blog.Action", new { action = "GetPosts" })';
var publishPostURL = '@Url.SubRouteUrl("blog", "Blog.Action", new { action = "PublishPost" })';
@@ -41,7 +41,7 @@
{
<div class="row">
<div class="col-sm-12 text-center">
<a href="@Url.SubRouteUrl("blog", "Blog.New", new { username = Model.User.Username })" role="button" class="btn btn-primary">Create Post</a>
<a href="@Url.SubRouteUrl("blog", "Blog.New", new { username = Model.User.Username, blogID = Model.BlogId })" role="button" class="btn btn-primary">Create Post</a>
</div>
</div>
}

+ 1
- 1
Teknik/Areas/Blog/Views/Blog/ViewPost.cshtml View File

@@ -4,8 +4,8 @@

<script>
// We need to define the action URLs for the script

var uploadURL = '@Url.SubRouteUrl("upload", "Upload.Upload")';
var helpURL = '@Url.SubRouteUrl("help", "Help.Markdown")';

var getPostsURL = '@Url.SubRouteUrl("blog", "Blog.Action", new { action = "GetPosts" })';
var publishPostURL = '@Url.SubRouteUrl("blog", "Blog.Action", new { action = "PublishPost" })';

Loading…
Cancel
Save