mirror of
https://github.com/lempamo/Project-Unite.git
synced 2025-01-22 17:22:15 +00:00
Fix topic delete bug
This commit is contained in:
parent
10e1866c9e
commit
872b3fb32e
1 changed files with 10 additions and 5 deletions
|
@ -154,16 +154,21 @@ public ActionResult DeletePost(string id)
|
|||
acl_perm = "CanDeleteOwnPosts";
|
||||
if (!ACL.Granted(User.Identity.Name, acl_perm))
|
||||
return new HttpStatusCodeResult(403);
|
||||
db.ForumPosts.Remove(topic);
|
||||
var parent = db.ForumTopics.FirstOrDefault(x => x.Id == topic.Parent);
|
||||
db.SaveChanges();
|
||||
if (parent.Posts.Length == 0)
|
||||
bool redirectToParent = false;
|
||||
string cat = "";
|
||||
if (parent.Posts.Length - 1 == 0)
|
||||
{
|
||||
string cat = parent.Parent;
|
||||
cat = parent.Parent;
|
||||
db.ForumTopics.Remove(parent);
|
||||
db.SaveChanges();
|
||||
RedirectToAction("ViewForum", new { id = cat });
|
||||
redirectToParent = true;
|
||||
}
|
||||
db.ForumPosts.Remove(topic);
|
||||
db.SaveChanges();
|
||||
if(redirectToParent)
|
||||
return RedirectToAction("ViewForum", new { id = cat });
|
||||
|
||||
return RedirectToAction("ViewTopic", new { id = db.ForumTopics.FirstOrDefault(x => x.Id == topic.Parent).Discriminator});
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue