public List <string> postSignIn(Models.AccountModel accountModel) { var db = new MyDBModels.DB(); string cryptName = EncryptClass.DESEncrypt(accountModel.Secondname); string cryptPassword = EncryptClass.MD5Hash(accountModel.Password); List <string> result = new List <string>(); result.Clear(); MyDBModels.Account accountFinal = db.account.Where(b => b.LoginId == cryptName && b.PasswordWorker == cryptPassword).FirstOrDefault(); if (accountFinal != null) { result.Add(EncryptClass.DESDecrypt(accountFinal.LoginId)); result.Add(EncryptClass.DESDecrypt(accountFinal.RoleWorker)); result.Add(EncryptClass.DESDecrypt(accountFinal.NumberWorker)); int number = int.Parse(EncryptClass.DESDecrypt(accountFinal.NumberWorker)); if (number > 100) { MyDBModels.Dispatcher dispatcher = db.dispatcher.Where(b => b.DispatcherNumber == number).FirstOrDefault(); result.Add(dispatcher.Image); } else { MyDBModels.Driver driver = db.driver.Where(b => b.DriverNumber == number).FirstOrDefault(); result.Add(driver.Image); } } else { result.Add("NOT OK"); } return(result); }
public ActionResult Login(Models.AccountModel user) { int isAdmin; if (ModelState.IsValid) { if (IsValid(user.UserEmail, user.Password, out isAdmin)) { FormsAuthentication.SetAuthCookie(user.UserEmail, false); Response.SetCookie(new HttpCookie("UserId", userAccount.UserId.ToString())); //if log in as administrator user if (isAdmin == 1) { return(RedirectToAction("Index", "AdminUser")); } //if login as normal user else { return(RedirectToAction("Index", "Contact")); } } else { ModelState.AddModelError("", "Email/Password incorrect"); } } return(View()); }
public ActionResult Update(Models.AccountModel customerData) { //get account from Db var customer = _manager.GetCustomer(customerData.CustomerId); if (!ModelState.IsValid) { //return View(); return(PartialView("~/Views/Home/_Update.cshtml", customerData)); } if (customer == null) { ViewBag.message = "Your account number is not valid"; //return View(); return(Json(false)); } else { customer.Update(customerData.Customer); _manager.Update(); //return RedirectToAction("Detail", new { accountNumber = customerData.AccountNumber, customerID = customerData.CustomerId }); //return RedirectToAction("GetAccounts"); return(Json(true)); } }
public ActionResult Withdraw(Models.AccountModel accountData) { //get account from Db Account account = _manager.GetAccount(accountData.AccountNumber); if (!ModelState.IsValid) { //return View(); return(PartialView("~/Views/Home/_Withdraw.cshtml", accountData)); } if (account == null) { ViewBag.message = "Your account number is not valid"; //return View(); return(Json(false)); } else { bool result = account.Withdraw(accountData.TransactionAmount); if (result) { _manager.Update(); return(Json(true)); } return(Json(false)); // return RedirectToAction("GetAccounts"); // return RedirectToAction("Detail", new { accountNumber = account.AccountNumber }); } }
public int logicMethodForPostDataDispatcher(Models.DispatcherAccountModel data) { Models.AccountModel encrypt = encryptData(data.AccountModel); Models.DispatcherAccountModel model = new Models.DispatcherAccountModel(); model.AccountModel = encrypt; return(dataAccess.postDispatcher(model)); }
public ActionResult Account() { AccountModel data = new Models.AccountModel(); data.Load(Guid.Parse(this.CurrentUser.AccountName)); return(View(data)); }
// GET: Admin/Book public ActionResult getListBook(int page = 1, int pagesize = 10) { //Xử lý thao tác linq đơn giản //var listBook = from s in db.Sach select s; // return View(listBook.ToList()); var listPage = new Models.AccountModel(); var model = listPage.ListAllPage(page, pagesize); return(View(model)); }
public static AccountModel FindFirst(string username) { AccountModel account = null; MySqlDataReader reader = null; try { MySqlCommand Command = new MySqlCommand() { Connection = DatabaseManager.Provider.getConnection(), CommandText = "SELECT guid,username,pass,banned,level,pseudo,logged,question,answer,lastip,lastConnectionDate FROM accounts WHERE username=@user", }; Command.Prepare(); Command.Parameters.AddWithValue("@user", username); reader = DatabaseManager.Provider.ExecuteCommand(Command); if (reader.Read()) { account = new Models.AccountModel() { ID = reader.GetInt32("guid"), Username = reader.GetString("username"), Password = reader.GetString("pass"), Pseudo = reader.GetString("pseudo"), Level = reader.GetInt32("level"), Banned = reader.GetInt64("banned"), Logged = reader.GetInt32("logged"), LastIP = reader.GetString("lastip"), SecretQuestion = reader.GetString("question"), SecretAnswer = reader.GetString("answer"), LastConnectionDate = CDateTimeUtil.MySqlToNet(reader.GetMySqlDateTime("lastConnectionDate")), }; } reader.Close(); if (account != null) { FindCharacters(account); } Command = null; } catch (Exception e) { if (reader != null && !reader.IsClosed) { reader.Close(); } Logger.Error(e); } return(account); }
public List <string> postSignIn(Models.AccountModel accountModel) { var db = new MyDBModels.DB(); string cryptName = EncryptClass.DESEncrypt(accountModel.Secondname); string cryptPassword = EncryptClass.MD5Hash(accountModel.Password); List <string> result = new List <string>(); MyDBModels.Account accountFinal = db.account.Where(b => b.LoginId == cryptName && b.PasswordWorker == cryptPassword).FirstOrDefault(); if (accountFinal != null) { result.Add(EncryptClass.DESDecrypt(accountFinal.RoleWorker)); result.Add(EncryptClass.DESDecrypt(accountFinal.NumberWorker)); } else { result.Add("NOT OK"); } return(result); }
public static Models.AccountModel GetAccountFromSQL(string username) { lock (DatabaseManager.Locker) { Models.AccountModel account = null; var reader = DatabaseManager.Provider.ExecuteReader("SELECT * FROM accounts WHERE username='******'"); if (reader.Read()) { account = new Models.AccountModel() { ID = reader.GetInt32("Id"), Username = reader.GetString("Username"), Password = reader.GetString("Password"), Pseudo = reader.GetString("Pseudo"), AdminLevel = reader.GetInt32("AdminLevel"), Points = reader.GetInt32("Points"), Vip = reader.GetInt32("Vip"), }; } reader.Close(); return account; } }
public static Int32 Login(string userName, string password) { Models.AccountModel loginTest = new Models.AccountModel(userName, password); return(loginTest.CheckLogin()); }
public List <string> PostSignIn(Models.AccountModel data) { return(logic.logicMethodForPostSingDataDispatcher(data)); }
public List <string> logicMethodForPostSingDataDispatcher(Models.AccountModel data) { return(dataAccess.postSignIn(data)); }