making dashboard
This commit is contained in:
@ -8,10 +8,13 @@ using System.Web;
|
||||
using System.Web.Mvc;
|
||||
using test.Models;
|
||||
|
||||
|
||||
|
||||
namespace test.Controllers
|
||||
{
|
||||
public class UsersController : Controller
|
||||
{
|
||||
|
||||
private testEntities db = new testEntities();
|
||||
|
||||
// GET: Users
|
||||
@ -58,6 +61,28 @@ namespace test.Controllers
|
||||
return View(user);
|
||||
}
|
||||
|
||||
|
||||
public ActionResult Dashboard()
|
||||
{
|
||||
// اگر کاربر لاگین نکرده بود، منتقلش کن به لاگین
|
||||
if (Session["UserID"] == null)
|
||||
return RedirectToAction("Login");
|
||||
|
||||
|
||||
ViewBag.Categories = db.Categories.ToList();
|
||||
ViewBag.tag = db.Tags.ToList();
|
||||
|
||||
return View();
|
||||
|
||||
}
|
||||
|
||||
public ActionResult Logout()
|
||||
{
|
||||
Session.Clear(); // یا Session.Abandon()
|
||||
return RedirectToAction("Login");
|
||||
}
|
||||
|
||||
|
||||
// GET: Users/Edit/5
|
||||
public ActionResult Edit(int? id)
|
||||
{
|
||||
@ -95,7 +120,8 @@ namespace test.Controllers
|
||||
Session["UserName"] = user.User_Name;
|
||||
|
||||
// انتقال به صفحه اصلی
|
||||
return RedirectToAction("Index", "Home");
|
||||
return RedirectToAction("Dashboard", "Users");
|
||||
|
||||
}
|
||||
|
||||
ViewBag.Message = "شماره یا رمز عبور اشتباه است.";
|
||||
@ -118,6 +144,9 @@ namespace test.Controllers
|
||||
return View(user);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// GET: Users/Delete/5
|
||||
public ActionResult Delete(int? id)
|
||||
{
|
||||
@ -133,6 +162,9 @@ namespace test.Controllers
|
||||
return View(user);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// POST: Users/Delete/5
|
||||
[HttpPost, ActionName("Delete")]
|
||||
[ValidateAntiForgeryToken]
|
||||
@ -152,5 +184,72 @@ namespace test.Controllers
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[ValidateAntiForgeryToken]
|
||||
public ActionResult AddCategoryFromDashboard(Category category)
|
||||
{
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
db.Categories.Add(category);
|
||||
db.SaveChanges();
|
||||
TempData["CategoryMessage"] = "دستهبندی با موفقیت اضافه شد.";
|
||||
}
|
||||
return RedirectToAction("Dashboard");
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[ValidateAntiForgeryToken]
|
||||
public ActionResult AddTagFromDashboard(Tag tag)
|
||||
{
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
db.Tags.Add(tag);
|
||||
db.SaveChanges();
|
||||
TempData["TagMessage"] = "تگ با موفقیت اضافه شد.";
|
||||
}
|
||||
return RedirectToAction("Dashboard");
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user