public ActionResult AccountEdit() { string userID = Request.Params["userID"]; string accountID = Request.Params["accountID"]; ViewBag.userID = userID; List<LC_User> lcUserList = db.sp_LC_FindUser(accountID).ToList(); User user = new User(); if (lcUserList.Any()) { LC_User lcUser = lcUserList.First(); user.UserID = lcUser.UserID; user.UserName = lcUser.UserName; user.Password = lcUser.Password; user.UserLevel = lcUser.UserLevel; user.Dept = lcUser.Dept; user.Status = lcUser.Status; } //List<SelectListItem> items = new List<SelectListItem>(); //items.Add(new SelectListItem { Text = "Administer", Value = "AD" }); //items.Add(new SelectListItem { Text = "Worker", Value = "GU" }); //items.Add(new SelectListItem { Text = "Visitor", Value = "V " }); //var levelList = new SelectList(items, "Value", "Text", user.UserLevel); //ViewBag.levelLlist = levelList; return View(user); }
public ActionResult AccountEdit(User user, string loginID) { if (user.UserLevel == null) { ModelState.AddModelError("", "UserLevel is required!"); } if (user.Status == null) { ModelState.AddModelError("", "Status is required!"); } if (ModelState.IsValid) { List<LC_User> lcUserList = db.sp_LC_FindUser(user.UserID).ToList(); LC_User lcUser = new LC_User(); if (lcUserList.Any()) { lcUser = lcUserList.First(); lcUser.UserName = user.UserName; lcUser.Password = user.Password; lcUser.UserLevel = user.UserLevel; lcUser.Dept = user.Dept; lcUser.Status = user.Status; } else { lcUser.UserID = db.sp_LC_GenUserID().ToList().First(); lcUser.UserName = user.UserName; lcUser.Password = user.Password; lcUser.UserLevel = user.UserLevel; lcUser.Dept = user.Dept; lcUser.Status = user.Status; db.LC_User.Add(lcUser); } db.SaveChanges(); return RedirectToAction("Console", "Admin", new { userID = loginID }); } return View(user); }
public ActionResult Console(string userID) { LC_User lcUser = db.sp_LC_FindUser(userID).ToList().First(); User user = new User { UserID = lcUser.UserID, UserName = lcUser.UserName, Password = lcUser.Password, UserLevel = lcUser.UserLevel, Dept = lcUser.Dept, Status = lcUser.Status }; List<LC_Msg> msgList = db.sp_LC_SearchActiveMsg().ToList(); ViewBag.msgList = msgList; return View(user); }
public ActionResult Index(User user) { if (ModelState.IsValid) { List<LC_User> lcUserList = db.sp_LC_UserValid_CallCentre(user.UserName, user.Password).ToList(); if (lcUserList.Any()) { LC_User lcUser = lcUserList.First(); string userID = lcUser.UserID; return RedirectToAction("Console", new { userID = userID }); } else { ModelState.AddModelError("", "UserName and Password are not matched."); } } return View(user); }
// // GET: /Admin/ public ActionResult Index() { User user = new User(); return View(user); }
public ActionResult Console(string userID) { LC_User lcUser = db.sp_LC_FindUser(userID).ToList().First(); User user = new User(); user.UserID = lcUser.UserID; user.UserName = lcUser.UserName; user.Password = lcUser.Password; user.UserLevel = lcUser.UserLevel; user.Dept = lcUser.Dept; user.Status = lcUser.Status; return View(user); }