public ActionResult Login(UserLogin _user) { if (ModelState.IsValid) { using (PizzatoriumDB db = new PizzatoriumDB()) { User obj = db.Users.Where(a => a.Username.ToLower().Equals(_user.Username.ToLower()) && a.Password.Equals(_user.Password)).FirstOrDefault(); if (obj != null) { Session["User"] = obj; Session["IsLoggedIn"] = true; if (_user.RedirectURL != null) { return(Redirect(_user.RedirectURL)); } if (((User)Session["User"]).ID == 1) { return(RedirectToAction("Index", "Admin")); } return(RedirectToAction("Design")); } Session["IsLoggedIn"] = false; } } return(View(_user)); }
public ActionResult Index() { ViewBag.MyText = "WTF"; PizzatoriumDB db = new PizzatoriumDB(); ViewBag.User = db.Users.ToList(); return(View()); }
public ActionResult EditUser(int?id, User _user) { if (id != 1) { PizzatoriumDB db = new PizzatoriumDB(); db.Users.Single(u => u.ID == id).Update(_user); db.SaveChanges(); } return(RedirectToAction("ListUsers")); }
public ActionResult UserDetails(int?id) { if (id != 1) { PizzatoriumDB db = new PizzatoriumDB(); List <User> _list = db.Users.ToList(); User _user = _list.Single(u => u.ID == id); return(View(_user)); } else { return(RedirectToAction("ListUsers")); } }
public ActionResult Delete(int?id) { if (id != 1) { PizzatoriumDB db = new PizzatoriumDB(); List <User> _list = db.Users.ToList(); User _user = _list.Single(u => u.ID == id); db.Users.Remove(_user); db.SaveChanges(); } return(RedirectToAction("ListUsers")); }
public ActionResult Design() { if ((bool)Session["IsLoggedIn"]) { using (PizzatoriumDB db = new PizzatoriumDB()) { ViewBag.Ingredients = db.Ingredients.ToList(); return(View()); } } else { return(RedirectToAction("Login")); } }
public ActionResult AddUser(User _user) { if (_user == null) { throw new ArgumentNullException(nameof(_user)); } PizzatoriumDB db = new PizzatoriumDB(); _user.Roles = new List <int> { 0 }; db.Users.Add(_user); db.SaveChanges(); return(RedirectToAction("ListUsers")); }
public ActionResult ListUsers() { PizzatoriumDB db = new PizzatoriumDB(); return(View(db.Users.Where(u => u.ID != 1))); }