public ActionResult EditUser(pm_User editUsers, HttpPostedFileBase upload) { if (!ModelState.IsValid) { return(View("EditUser", editUsers)); } string path = Path.Combine(Server.MapPath("~/Uploads"), upload.FileName); upload.SaveAs(path); editUsers.photo = upload.FileName; db.pm_User.Add(editUsers); db.SaveChanges(); var UserDB = db.pm_User.Single(a => a.id == editUsers.id); UserDB.firstname = editUsers.firstname; UserDB.lastname = editUsers.lastname; UserDB.email = editUsers.email; UserDB.password = editUsers.password; UserDB.mobile = editUsers.mobile; db.SaveChanges(); return(View("EditUser", UserDB)); //***** page that are U redirect to it }
public ActionResult Register(pm_User account) { if (ModelState.IsValid) { var checkUsername = db.pm_User.Where(e => e.email == account.email).FirstOrDefault(); var checkEmail = db.pm_User.Where(e => e.email == account.email).FirstOrDefault(); if (checkUsername == null) { if (checkEmail == null) { db.pm_User.Add(account); db.SaveChanges(); ModelState.Clear(); ViewBag.Message = account.firstname + " " + account.lastname + " Successfully registered"; } else { ModelState.AddModelError("", "This Email Address is already exists !"); } } else { ModelState.AddModelError("", "Username is already exists, Check another one !"); } } return(View()); }
public ActionResult AddUser() { pm_User userModel = new pm_User(); ViewBag.roles = new SelectList(db.pm_Role, "id", "role_title"); return(View(userModel)); }
public ActionResult Index() { int id = int.Parse(Session["user_id"].ToString()); pm_User user = db.pm_User.Where(e => e.id == id).FirstOrDefault(); ViewBag.skill = user.pm_personSkill.FirstOrDefault(); return(View(user)); }
public ActionResult UserDelete(int?id) { pm_User user = db.pm_User.Find(id); db.pm_User.Remove(user); db.SaveChanges(); return(RedirectToAction("AllUsers")); }
public ActionResult Login(pm_User user) { var usr = db.pm_User.Where(u => u.email == user.email).Where(u => u.password == user.password).FirstOrDefault(); if (usr != null) { Session["user_id"] = usr.id.ToString(); Session["user_email"] = usr.email.ToString(); Session["user_role_id"] = usr.role_id.ToString(); Session["user_name"] = usr.firstname.ToString() + " " + usr.lastname.ToString(); Session["user_photo"] = usr.photo.ToString(); //get user role to switch the views of the actors int user_role = usr.role_id.Value; switch (user_role) { case 1: { //case 1 goto admin dashboard return(RedirectToAction("profile")); } case 2: { //case 2 goto project customer dashboard return(RedirectToAction("profile")); } case 3: { //case 2 goto project customer dashboard return(RedirectToAction("profile")); } case 4: { //case 2 goto project customer dashboard return(RedirectToAction("profile")); } case 5: { //case 2 goto project customer dashboard return(RedirectToAction("profile")); } } } else { ModelState.AddModelError("", "Invalid Username or password"); } return(View()); }
public ActionResult profile() { if (Session["user_id"] != null) { int user_id = int.Parse(Session["user_id"].ToString()); pm_User user = db.pm_User.Find(user_id); return(View(user)); } else { return(RedirectToAction("Login")); } }
public ActionResult AddUser(pm_User userModel, HttpPostedFileBase upload) { if (!ModelState.IsValid) { return(Content("Not valid bro?!")); } string path = Path.Combine(Server.MapPath("~/Uploads"), upload.FileName); upload.SaveAs(path); userModel.photo = upload.FileName; db.pm_User.Add(userModel); db.SaveChanges(); ViewBag.roles = new SelectList(db.pm_Role, "id", "role_title"); //return View("AllUsers"); return(RedirectToAction("AllUsers")); }