public static ClientSession Login(QE_USER user) { try { //user.PASSWORD = AccountService.aesEncryptBase64(user.PASSWORD, "QEKey"); QE_USER loginedUser = KennyORM.GetDBSource("QE_USER", "select * from QE_USER where USER_ID='" + user.USER_ID + "' and PASSWORD='******' and active=1").Cast <QE_USER>().First(); if (loginedUser.ID != 0) { if (loginedUser.FIRST_LOGIN.Date.Year == 1900 || loginedUser.FIRST_LOGIN.Date == null) { loginedUser.FIRST_LOGIN = DateTime.Now; } else { loginedUser.LAST_LOGIN = DateTime.Now; } KennyORM.UpdateRecord(loginedUser); } ClientSession session = new ClientSession(); session.loginedUser = loginedUser; HttpContext.Current.Session["ClientSession"] = session; return(session); } catch { return(new ClientSession()); } }
public GroupUserView(QE_USER user) { ID = Constant.DEF_INT; QE_USER = user.ID; user_name = user.USER_NAME; USER_GROUP = Constant.DEF_INT; contain = Constant.DEF_BOOL; }
public ActionResult LoginPost(QE_USER user) { if (!string.IsNullOrEmpty(user.USER_ID) && !string.IsNullOrEmpty(user.PASSWORD)) { ClientSessionService.Login(user); if (ClientSessionService.IsLogined) { return(RedirectToAction("Index", "AdminAndSetup")); } } TempData["msg"] = "User ID or Password invalid!"; return(Index()); }
public ActionResult UsersAndTeachers(int?id) // user id { checkLogin(); List <QE_USER> list = DBS.findActiveRecords <QE_USER>(); Session["userList"] = list; QE_USER displayingUser = id != null?list.Where(l => l.ID == (int)id).FirstOrDefault() : new QE_USER(); UsersAndTeachersViewModel ViewModel = new UsersAndTeachersViewModel(list, displayingUser); return(View(ViewModel)); }
public ActionResult UsersAndTeachersPost(QE_USER user) { checkLogin(); //get user list List <QE_USER> userList = Session["userList"] != null ? (List <QE_USER>)Session["userList"] : DBS.findActiveRecords <QE_USER>(); UsersAndTeachersViewModel viewModel = new UsersAndTeachersViewModel(userList, user); //string password = Membership.GeneratePassword(8, 4); //user.PASSWORD = AccountService.aesEncryptBase64(password, "QEKey"); string password = "******"; user.PASSWORD = "******"; user.ACTIVE = true; user.ADD_BY = CP.userID; user.ADD_DATE = DateTime.Now; // fields checking if (!ModelState.IsValid) { return(View("UsersAndTeachers", viewModel)); // redirect to form with data } // business logic check //user.ID < 1 means this is a new user if (user.ID < 1) { if (userList != null && userList.Exists(u => u.ID == user.ID)) { TempData[Constant.msg_error] = "User ID already in use"; return(View("UsersAndTeachers", viewModel)); // redirect to form with data } } bool isSuccess = false; if (user.ID < 1) { user.ID = DBS.addRecordReturnID(user); isSuccess = user.ID > 0 ? true : false; } else { isSuccess = DBS.updateRecord(user); } if (isSuccess) { //reset user list after user changes CP.teacherSelectList = UserService.getTeacherSelectList(); userList = DBS.findActiveRecords <QE_USER>(); Session["userList"] = userList; //MailService.SendNewPassword(user.EMAIL, user.USER_ID, password); TempData[Constant.msg_success] = ((user.ID < 1) ? "user has been created" : Constant.ChangeSucceed); return(UsersAndTeachers(user.ID)); } else { TempData[Constant.msg_error] = "Ops! somethings gone wrong."; return(View("UsersAndTeachers", viewModel)); } }