public ActionResult Login(AccountModel accountModel) { if (accountModel.aAccount.UserName != null) { accountModel.aAccount.PassWord = bllMethods.PassWordHash(accountModel.aAccount.PassWord); AccountDO accountDO = dataMethods.GetAccountInfoByUserName(accountModel.aAccount.UserName); if (ModelState.IsValid) { if (accountModel.aAccount.PassWord == accountDO.PassWord) { accountModel.aAccount = MappingMethods.MapAccountDOtoPO(accountDO); Session["RoleID"] = accountModel.aAccount.RoleID; Session["AccountID"] = accountModel.aAccount.AccountID; Session["FirstName"] = accountModel.aAccount.FirstName; Session["LastName"] = accountModel.aAccount.LastName; Session["Email"] = accountModel.aAccount.Email; return(View("Index")); } else { ModelState.AddModelError("", "Username or Password is invalid."); } } } return(View()); }
public IEnumerable <AccountDO> getAccount() { using (var Db = new ProjectWebEntities()) { var result = new List <AccountDO>(); foreach (var m in Db.Tbl_MemberAccount) { var tmp = new AccountDO(); tmp.Id = m.Id; tmp.FullName = m.FirstName + " " + m.LastName; tmp.Email = m.Email; tmp.Password = m.Password; tmp.Phone = m.Phone; tmp.Address = m.Address; tmp.ProvinceId = m.ProvinceId; tmp.ProvinceName = m.Tbl_Province == null ? "" : m.Tbl_Province.ProName; tmp.DistrictId = m.DistrictId; tmp.DistrictName = m.Tbl_District == null ? "" : m.Tbl_District.DisName; tmp.WardId = m.WardId; tmp.WardName = m.Tbl_Ward == null ? "" : m.Tbl_Ward.WardName; tmp.ImagePath = m.ImagePath; tmp.Sex = m.Sex; tmp.PIN = m.PIN; tmp.DOB = m.DOB == null ? "" : m.DOB.Value.ToShortDateString(); tmp.DateCreate = m.DateCreate.ToShortDateString(); tmp.IsReceiptNewsLetter = m.IsReceiptNewsLetter; tmp.Message = m.Message; result.Add(tmp); } return(result); } }
// GET: Home public ActionResult Index() { AccountDAO dao = new AccountDAO(); List <AccountDO> getAll = dao.Carregar(); var accessToken = _token; var facebookClient = new FacebookClient(); var facebookService = new FacebookService(facebookClient); var account = facebookService.GetAccount(accessToken); AccountDO accDO = new AccountDO() { Id = account.Id, Name = account.Name, FirstName = account.FirstName, LastName = account.LastName }; dao.Salvar(accDO); ViewBag.AccountId = account.Id; ViewBag.AccountName = account.Name; return(View()); }
}//end of view accounts public void UpdateAccountAdmin(AccountDO accountDO) { SqlConnection sqlConnection = new SqlConnection(connectionString); SqlCommand commandUpdateAccount = new SqlCommand("sp_UpdateAccount", sqlConnection); try { commandUpdateAccount.CommandType = CommandType.StoredProcedure; commandUpdateAccount.Parameters.AddWithValue("@AccountID", accountDO.AccountID); commandUpdateAccount.Parameters.AddWithValue("@RoleID", accountDO.RoleId); commandUpdateAccount.Parameters.AddWithValue("@PassWord", accountDO.PassWord); commandUpdateAccount.Parameters.AddWithValue("@UserName", accountDO.UserName); commandUpdateAccount.Parameters.AddWithValue("@FirstName", accountDO.FirstName); commandUpdateAccount.Parameters.AddWithValue("@LastName", accountDO.LastName); sqlConnection.Open(); commandUpdateAccount.ExecuteNonQuery(); } catch (SqlException sqlEx) { DataErrorLogger.ErrorLogger("Update Account(Admin)", DateTime.Now, sqlEx.Message); } finally { sqlConnection.Close(); sqlConnection.Dispose(); } }//end of update account
}//end of get account info by ID public AccountDO GetAccountInfoByUserName(string UserName) { SqlConnection sqlConnection = new SqlConnection(connectionString); SqlCommand commandGetByUserName = new SqlCommand("sp_GetAccountInfoByUserName", sqlConnection); AccountDO accountDO = new AccountDO(); try { commandGetByUserName.CommandType = CommandType.StoredProcedure; commandGetByUserName.Parameters.AddWithValue("@UserName", UserName); sqlConnection.Open(); using (SqlDataReader reader = commandGetByUserName.ExecuteReader()) { while (reader.Read()) { accountDO.AccountID = Convert.ToInt32(reader["AccountID"]); accountDO.RoleId = (int)reader["RoleID"]; accountDO.PassWord = (string)reader["PassWord"]; accountDO.FirstName = (string)reader["FirstName"]; accountDO.LastName = (string)reader["LastName"]; accountDO.Email = (string)reader["Email"]; } } } catch (SqlException sqlEx) { DataErrorLogger.ErrorLogger("Get account info by UserName", DateTime.Now, sqlEx.Message); } finally { sqlConnection.Close(); sqlConnection.Dispose(); } return(accountDO); }
}//end of delete account public AccountDO GetAccountInfoByID(int AccountID) { SqlConnection sqlConnection = new SqlConnection(connectionString); SqlCommand commandGetInfoByID = new SqlCommand("sp_GetAccountInfoByID", sqlConnection); AccountDO accountDO = new AccountDO(); try { commandGetInfoByID.CommandType = CommandType.StoredProcedure; commandGetInfoByID.Parameters.AddWithValue("@AccountID", AccountID); sqlConnection.Open(); using (SqlDataReader reader = commandGetInfoByID.ExecuteReader()) { while (reader.Read()) { accountDO.UserName = (string)reader["UserName"]; accountDO.FirstName = (string)reader["FirstName"]; accountDO.LastName = (string)reader["LastName"]; accountDO.Email = (string)reader["Email"]; } } } catch (SqlException sqlEx) { DataErrorLogger.ErrorLogger("Get account info by ID", DateTime.Now, sqlEx.Message); } finally { sqlConnection.Close(); sqlConnection.Dispose(); } return(accountDO); }//end of get account info by ID
public ActionResult RegisterAccount(AccountModel viewModel) { if (ModelState.IsValid) { viewModel.aAccount.PassWord = bllMethods.PassWordHash(viewModel.aAccount.PassWord); AccountDO accountDO = MappingMethods.MapAccountPOtoDO(viewModel.aAccount); dataMethods.CreateAccount(accountDO); return(RedirectToAction("Login", "Home")); } else { return(View()); } }
public static AccountDO MapAccountPOtoDO(AccountPO from) { AccountDO to = new AccountDO(); to.RoleId = from.RoleID; to.AccountID = from.AccountID; to.UserName = from.UserName; to.PassWord = from.PassWord; to.FirstName = from.FirstName; to.LastName = from.LastName; to.Email = from.Email; return(to); }
public static Model.Account ToBusinessObject(this AccountDO account) { if (account == null) { throw new ArgumentNullException(nameof(account)); } var entity = new Model.Account { Id = account.Id, UserName = account.UserName, Password = account.Password, CreatedBy = account.CreatedBy, CreatedTime = account.CreatedTime, UpdatedBy = account.UpdatedBy, UpdatedTime = account.UpdatedTime }; return(entity); }
public void UpdateAccount(AccountDO item) { Execute("UPDATE account SET username = @username,password=@password,updatedby=@updatedby,updatedtime=@updatedtime WHERE id = @Id", item); }
public int CreateAccount(AccountDO item) { return(ExecuteScalar("INSERT INTO public.account (username, password, createdby, createdtime, updatedby, updatedtime) VALUES (@username,@password, @createdby, @createdtime, @updatedby, @updatedtime) RETURNING id", item)); }