// CREATE OPTIONS public ActionResult Create(LaysCatsPosts lcposts) { int idC = lcposts.SelectedCategory; int idL = lcposts.SelectedLayout; var post = new Post { LayoutID = idL, CategoryID = idC }; LaysCatsPost LCP = new LaysCatsPost { Categories = DbData.Categories.ToList(), Layouts = DbData.Layouts.ToList(), Post = post }; var category = DbData.Categories.Where(c => c.CategoryID == idC).SingleOrDefault(); var layout = DbData.Layouts.Where(l => l.LayoutID == idL).SingleOrDefault(); if (category.CategoryName == "Afirmacije") { return(View("Create", "~/Views/Shared/Afirmacije/" + layout.LayoutName + "c.cshtml", LCP)); } else if (category.CategoryName == "Pesme") { return(View("Create", "~/Views/Shared/Pesme/" + layout.LayoutName + "c.cshtml", LCP)); } else { return(RedirectToAction("Index", "AdminPanel")); } }
public ActionResult Delete(LaysCatsPosts lcp) { var post = DbData.Posts.Where(p => p.PostID == lcp.SelectedPost).SingleOrDefault(); DbData.Entry(post).State = System.Data.Entity.EntityState.Deleted; DbData.SaveChanges(); return(RedirectToAction("Index", "AdminPanel")); }
// ADMIN PANEL MAIN PAGE public ActionResult Index() { LaysCatsPosts LCP = new LaysCatsPosts { Posts = DbData.Posts.ToList(), Categories = DbData.Categories.ToList(), Layouts = DbData.Layouts.ToList() }; if (Session["AdminID"] != null) { return(View(LCP)); } else { return(RedirectToAction("Login", "AdminPanel")); } }