|
using Cong.Model;
using Cong.Utility;
using MongoDB.Bson;
using System.Web.Mvc;
using WebApp.Models;
namespace WebApp.Controllers
{
public partial>
{
MgHelper<Auth> mg = new MgHelper<Auth>();
public ActionResult Index()
{
return View();
}
[HttpGet]
public ActionResult Create()
{
return View();
}
[HttpPost]
public ActionResult Create(Auth auth)
{
mg.Insert(auth);
return Content("<script>alert('success!');window.location='/Auth/Create';</script>");
}
[HttpGet]
public ActionResult Modify()
{
AuthVM authvm = new AuthVM { Auths = mg.QueryAll() };
return View(authvm);
}
[HttpPost]
public ActionResult Modify(Auth auth, FormCollection form)
{
auth.Id = ObjectId.Parse(form["id"]);
mg.Update(auth);
return Content("<script>alert('success!');window.location='/Auth/Modify';</script>");
}
[HttpPost]
public string Delete(string>
{
mg.Modify(id, "State", "n");
return "success!";
}
}
public partial>
{
MgHelper<Role> mg = new MgHelper<Role>();
public ActionResult Index()
{
return View();
}
[HttpGet]
public ActionResult Create()
{
return View();
}
[HttpPost]
public ActionResult Create(Role role)
{
mg.Insert(role);
return Content("<script>alert('success!');window.location='/Role/Create';</script>");
}
[HttpGet]
public ActionResult Modify()
{
RoleVM rolevm = new RoleVM { Roles = mg.QueryAll() };
return View(rolevm);
}
[HttpPost]
public ActionResult Modify(Role role, FormCollection form)
{
role.Id = ObjectId.Parse(form["id"]);
mg.Update(role);
return Content("<script>alert('success!');window.location='/Role/Modify';</script>");
}
[HttpPost]
public string Delete(string>
{
mg.Modify(id, "State", "n");
return "success!";
}
}
public partial>
{
MgHelper<User> mg = new MgHelper<User>();
public ActionResult Index()
{
return View();
}
[HttpGet]
public ActionResult Create()
{
return View();
}
[HttpPost]
public ActionResult Create(User user)
{
mg.Insert(user);
return Content("<script>alert('success!');window.location='/User/Create';</script>");
}
[HttpGet]
public ActionResult Modify()
{
UserVM uservm = new UserVM { Users = mg.QueryAll() };
return View(uservm);
}
[HttpPost]
public ActionResult Modify(User user, FormCollection form)
{
user.Id = ObjectId.Parse(form["id"]);
mg.Update(user);
return Content("<script>alert('success!');window.location='/User/Modify';</script>");
}
[HttpPost]
public string Delete(string>
{
mg.Modify(id, "State", "n");
return "success!";
}
}
} |
|
|