public ActionResult Edit(int id) { UserWeb userWeb = new UserWeb(); Library.User user = userWeb.Users.Single(g => g.Id == id); return(View(user)); }
public ActionResult Index() { UserWeb userWeb = new UserWeb(); List <Library.User> users = userWeb.Users.ToList(); return(View(users)); }
///<summary>Inserts one UserWeb into the database. Returns the new priKey.</summary> public static long Insert(UserWeb userWeb) { if (DataConnection.DBtype == DatabaseType.Oracle) { userWeb.UserWebNum = DbHelper.GetNextOracleKey("userweb", "UserWebNum"); int loopcount = 0; while (loopcount < 100) { try { return(Insert(userWeb, true)); } catch (Oracle.ManagedDataAccess.Client.OracleException ex) { if (ex.Number == 1 && ex.Message.ToLower().Contains("unique constraint") && ex.Message.ToLower().Contains("violated")) { userWeb.UserWebNum++; loopcount++; } else { throw ex; } } } throw new ApplicationException("Insert failed. Could not generate primary key."); } else { return(Insert(userWeb, false)); } }
public ActionResult ExistingUser(UserWeb user) { try { var libUser = MapperWeb.Map(user); var checkUser = Repo.FindUserId(libUser.FirstName, libUser.LastName); if (checkUser > 0) { TempData["id"] = checkUser; TempData["FirstName"] = libUser.FirstName; TempData["MID"] = Repo.FindManagerFlagById(checkUser); return(RedirectToAction("Index", "Home")); } else { ModelState.AddModelError(string.Empty, "User doesn't exist. Please login as a new user or try again"); return(View(user)); } // TODO: Add insert logic } catch { return(View()); } }
public IEnumerable <UserWeb> GetAll() { using (var con = new SqlConnection(_con_str)) { con.Open(); var cmd = new SqlCommand("procedure_GetAllWebUsers", con); cmd.CommandType = CommandType.StoredProcedure; var res = cmd.ExecuteReader(); List <UserWeb> usersWeb = new List <UserWeb>(); bool next = res.Read(); while (next) { var webUser = new UserWeb { Login = (string)res["Login"], Password = (string)res["Password"], Roles = new string[] { } }; while ((string)res["Login"] == webUser.Login) { webUser.Roles = new string[] { (string)res["Name"] }; if (!res.Read()) { next = false; break; } } usersWeb.Add(webUser); } return(usersWeb); } }
public bool Add(UserWeb user) { using (var connect = new SqlConnection(_con_str)) { connect.Open(); var cmd = new SqlCommand("procedure_InsertWebUser", connect); cmd.CommandType = CommandType.StoredProcedure; var LoginParam = new SqlParameter() { DbType = DbType.String, ParameterName = "@Login", Value = user.Login, }; var PasswordParam = new SqlParameter() { DbType = System.Data.DbType.String, ParameterName = "@Password", Value = user.Password, }; cmd.Parameters.Add(LoginParam); cmd.Parameters.Add(PasswordParam); cmd.ExecuteNonQuery(); } return(true); }
public ActionResult Create(Library.User user, string UserAccount) { UserWeb userWeb = new UserWeb(); if (!ModelState.IsValid) { return(View("Create")); } bool isSuccess = userWeb.AddUser(user); if (isSuccess) { ViewBag.Msg = "帳號已註冊過"; return(View()); } else { byte UserClass = 0; if (Session["Id"] != null) { byte.TryParse(Session["UserClass"].ToString(), out UserClass); } if (UserClass == 2) { return(RedirectToAction("Index", "User")); } else { return(RedirectToAction("Login", "User")); } } }
public IActionResult Edit(UserWeb user, string editAction) { if (this.ModelState.IsValid && user != null) { this.TempData["editResult"] = "Edit Fail"; if (editAction == "AddNew") { this.logic.AddUser(user.UserFullName, user.UserEmail, user.UserUsername, user.UserPassword, user.UserType); this.TempData["editResult"] = "Edit OK"; } else { if (this.logic.ChangeUser(user.UserId, user.UserFullName, user.UserEmail, user.UserUsername, user.UserPassword, user.UserType)) { this.TempData["editResult"] = "Edit OK"; } } return(this.RedirectToAction(nameof(this.Index))); } else { this.ViewData["editAction"] = "Edit"; this.vm.EditedUser = user; return(this.View("UsersIndex", this.vm)); } }
public ActionResult NewUser(UserWeb user) { try { var libUser = MapperWeb.Map(user); var checkUser = Repo.FindUserId(libUser.FirstName, libUser.LastName); if (checkUser == 0) { Repo.AddUser(libUser); Repo.Save(); checkUser = Repo.FindUserId(libUser.FirstName, libUser.LastName); TempData["id"] = checkUser; TempData["FirstName"] = libUser.FirstName; TempData["MID"] = false; return(RedirectToAction("Index", "Home")); } else { ModelState.AddModelError(string.Empty, "User already exists."); return(View(user)); } // TODO: Add insert logic } catch { return(View(user)); } }
public ActionResult Delete(int id) { UserWeb userWeb = new UserWeb(); userWeb.DeleteUser(id); return(RedirectToAction("Index")); }
private void FormPatientPortal_Load(object sender, EventArgs e) { _userWebCur = UserWebs.GetByFKeyAndType(_patCur.PatNum, UserWebFKeyType.PatientPortal); if (_userWebCur == null) { _isNew = true; _userWebCur = new UserWeb(); _userWebCur.UserName = UserWebs.CreateUserNameFromPat(_patCur, UserWebFKeyType.PatientPortal); _userWebCur.FKey = _patCur.PatNum; _userWebCur.FKeyType = UserWebFKeyType.PatientPortal; _userWebCur.RequireUserNameChange = true; _userWebCur.Password = ""; UserWebs.Insert(_userWebCur); } _userWebOld = _userWebCur.Copy(); textOnlineUsername.Text = _userWebCur.UserName; textOnlinePassword.Text = ""; if (_userWebCur.Password != "") //if a password was already filled in { butGiveAccess.Text = "Remove Online Access"; //We do not want to show the password hash that is stored in the database so we will fill the online password with asterisks. textOnlinePassword.Text = "********"; textOnlinePassword.ReadOnly = false; textOnlineUsername.ReadOnly = false; } textPatientPortalURL.Text = PrefC.GetString(PrefName.PatientPortalURL); }
// GET: User public ActionResult Index() { UserWeb user = new UserWeb(); //var libUsers = Repo.Get(search); //var webRests = libRests.Select(x => new Restaurant return(View(user)); }
///<summary>Inserts many UserWebs into the database. Provides option to use the existing priKey.</summary> public static void InsertMany(List <UserWeb> listUserWebs) { if (DataConnection.DBtype == DatabaseType.Oracle || PrefC.RandomKeys) { foreach (UserWeb userWeb in listUserWebs) { Insert(userWeb); } } else { StringBuilder sbCommands = null; int index = 0; while (index < listUserWebs.Count) { UserWeb userWeb = listUserWebs[index]; StringBuilder sbRow = new StringBuilder("("); bool hasComma = false; if (sbCommands == null) { sbCommands = new StringBuilder(); sbCommands.Append("INSERT INTO userweb ("); sbCommands.Append("FKey,FKeyType,UserName,Password,PasswordResetCode,RequireUserNameChange,DateTimeLastLogin,RequirePasswordChange) VALUES "); } else { hasComma = true; } sbRow.Append(POut.Long(userWeb.FKey)); sbRow.Append(","); sbRow.Append(POut.Int((int)userWeb.FKeyType)); sbRow.Append(","); sbRow.Append("'" + POut.String(userWeb.UserName) + "'"); sbRow.Append(","); sbRow.Append("'" + POut.String(userWeb.Password) + "'"); sbRow.Append(","); sbRow.Append("'" + POut.String(userWeb.PasswordResetCode) + "'"); sbRow.Append(","); sbRow.Append(POut.Bool(userWeb.RequireUserNameChange)); sbRow.Append(","); sbRow.Append(POut.DateT(userWeb.DateTimeLastLogin)); sbRow.Append(","); sbRow.Append(POut.Bool(userWeb.RequirePasswordChange)); sbRow.Append(")"); if (sbCommands.Length + sbRow.Length + 1 > TableBase.MaxAllowedPacketCount) { Db.NonQ(sbCommands.ToString()); sbCommands = null; } else { if (hasComma) { sbCommands.Append(","); } sbCommands.Append(sbRow.ToString()); if (index == listUserWebs.Count - 1) { Db.NonQ(sbCommands.ToString()); } index++; } } } }
public ActionResult Create(Library.User user) { if (!ModelState.IsValid) { return(View("Create")); } UserWeb userWeb = new UserWeb(); userWeb.AddUser(user); return(RedirectToAction("Index")); }
public UserWeb AddUser(string login, string password) { UserWeb user = new UserWeb { Login = login, Password = password }; if (_userWebDao.Add(user)) { return(user); } throw new ArgumentException("Error. User can't be added."); }
public async Task <ActionResult <UserWeb> > FindAllUsersWeb(int limit) { UserWeb userWeb = new UserWeb(); userWeb.Users = _userBuilder.ListBuild(_adminUseCases.FindAllUsers(limit)); foreach (var user in userWeb.Users) { user.Provinces = _provinceBuilder.Build(_adminUseCases.FindProvinceById(user.ProvincesId)); } userWeb.Count = _adminUseCases.UsersCount(); return(userWeb); }
public async Task <ActionResult <UserWeb> > UserSearchByUserName(string username, int limit) { UserWeb userWeb = new UserWeb(); userWeb.Users = _userBuilder.ListBuild(_adminUseCases.UserSearchByUserName(username, limit)); foreach (var user in userWeb.Users) { user.Provinces = _provinceBuilder.Build(_adminUseCases.FindProvinceById(user.ProvincesId)); } userWeb.Count = _adminUseCases.UserSearchByUserNameCount(username); return(userWeb); }
public async Task <IActionResult> Index(int id, string passw) { var findUser = new UserWeb().GetUsers().FirstOrDefault(x => x.Id == id && x.Password == passw); if (findUser == null) { return(View()); } await AddClaimsLogin(findUser); return(RedirectToAction("Index", "Home")); }
///<summary>Updates one UserWeb in the database.</summary> public static void Update(UserWeb userWeb) { string command = "UPDATE userweb SET " + "FKey = " + POut.Long(userWeb.FKey) + ", " + "FKeyType = " + POut.Int((int)userWeb.FKeyType) + ", " + "UserName = '******', " + "Password = '******', " + "PasswordResetCode = '" + POut.String(userWeb.PasswordResetCode) + "', " + "RequireUserNameChange= " + POut.Bool(userWeb.RequireUserNameChange) + ", " + "DateTimeLastLogin = "******", " + "RequirePasswordChange= " + POut.Bool(userWeb.RequirePasswordChange) + " " + "WHERE UserWebNum = " + POut.Long(userWeb.UserWebNum); Db.NonQ(command); }
///<summary>Inserts one UserWeb into the database. Returns the new priKey. Doesn't use the cache.</summary> public static long InsertNoCache(UserWeb userWeb) { if (DataConnection.DBtype == DatabaseType.MySql) { return(InsertNoCache(userWeb, false)); } else { if (DataConnection.DBtype == DatabaseType.Oracle) { userWeb.UserWebNum = DbHelper.GetNextOracleKey("userweb", "UserWebNum"); //Cacheless method } return(InsertNoCache(userWeb, true)); } }
public ApiResult ModOneCar(UserWeb user) { if (user == null) { return(new ApiResult() { OperationResult = false }); } return(new ApiResult() { OperationResult = this.logic.ChangeUser(user.UserId, user.UserFullName, user.UserEmail, user.UserUsername, user.UserPassword, user.UserType) }); }
public ActionResult Edit([Bind(Include = "UserAccount, UserClass, Email, Password, UserName")] Library.User user) { UserWeb userWeb = new UserWeb(); user.Id = userWeb.Users.Single(g => g.Id == user.Id).Id; if (!ModelState.IsValid) { return(View("Edit", user)); } userWeb.SaveUser(user); return(RedirectToAction("Index")); }
public ActionResult Usersearchpage(string myTextBox) { User w = Lur.Unub(myTextBox); string f = Lur.Unub(myTextBox).username; var otm = new UserWeb { Firstname = w.Firstname, Lastname = w.Lastname, defaultlocationID = w.defaultlocationID, userorderhistory = w.userorderhistory, username = w.username }; return(View(nameof(Details), otm)); }
private async Task AddClaimsLogin(UserWeb user) { var identity = new ClaimsIdentity(CookieAuthenticationDefaults.AuthenticationScheme, ClaimTypes.Name, ClaimTypes.Role); // Adds the values to the claims we create. identity.AddClaim(new Claim(IdentityExtensions.CustomClaimTypes.Id, user.Id.ToString())); identity.AddClaim(new Claim(IdentityExtensions.CustomClaimTypes.Name, user.Name)); identity.AddClaim(new Claim(IdentityExtensions.CustomClaimTypes.Job, user.Job)); // Creates the context of user authentication. var principal = new ClaimsPrincipal(identity); await HttpContext.SignInAsync(CookieAuthenticationDefaults.AuthenticationScheme, principal, new AuthenticationProperties { IsPersistent = true }); }
public bool update(UserWeb entity) { try { var user = db.UserWebs.Find(entity.ID); user.Name = entity.Name; user.Address = entity.Address; user.Email = entity.Email; user.ModifiedBy = entity.ModifiedBy; user.ModifiedDate = DateTime.Now; db.SaveChanges(); return(true); } catch (Exception e) { return(false); } }
public static UserWeb CreateUserWeb(long fKey, UserWebFKeyType fKeyType, string userName = "", string password = "", bool requireUserNameChange = false, bool requirePasswordChange = false, string passwordResetCode = "", DateTime dateTimeLastLogin = default(DateTime)) { UserWeb userWeb = new UserWeb() { IsNew = true, FKey = fKey, FKeyType = fKeyType, UserName = userName, Password = password, RequireUserNameChange = requireUserNameChange, RequirePasswordChange = requirePasswordChange, PasswordResetCode = passwordResetCode, DateTimeLastLogin = dateTimeLastLogin, }; UserWebs.Insert(userWeb); return(userWeb); }
///<summary>Converts a DataTable to a list of objects.</summary> public static List <UserWeb> TableToList(DataTable table) { List <UserWeb> retVal = new List <UserWeb>(); UserWeb userWeb; foreach (DataRow row in table.Rows) { userWeb = new UserWeb(); userWeb.UserWebNum = PIn.Long(row["UserWebNum"].ToString()); userWeb.FKey = PIn.Long(row["FKey"].ToString()); userWeb.FKeyType = (OpenDentBusiness.UserWebFKeyType)PIn.Int(row["FKeyType"].ToString()); userWeb.UserName = PIn.String(row["UserName"].ToString()); userWeb.Password = PIn.String(row["Password"].ToString()); userWeb.PasswordResetCode = PIn.String(row["PasswordResetCode"].ToString()); userWeb.RequireUserNameChange = PIn.Bool(row["RequireUserNameChange"].ToString()); userWeb.DateTimeLastLogin = PIn.DateT(row["DateTimeLastLogin"].ToString()); userWeb.RequirePasswordChange = PIn.Bool(row["RequirePasswordChange"].ToString()); retVal.Add(userWeb); } return(retVal); }
public ApiResult AddOneUser(UserWeb newUser) { bool success = true; try { if (newUser != null) { this.logic.AddUser(newUser.UserFullName, newUser.UserEmail, newUser.UserUsername, newUser.UserPassword, newUser.UserType); } } catch (ArgumentException) { success = false; } return(new ApiResult() { OperationResult = success }); }
public ActionResult Register(RegisterUserViewModel userView) { if (!ModelState.IsValid) { return(View(userView)); } UserWeb user = new UserWeb { Email = userView.Email, Name = userView.FirstName, LastName = userView.LastName, Password = userView.Password }; var validUser = _unit.UserWeb.CreateUser(user); if (validUser == null) { ModelState.AddModelError("Error", "No se pudo crear el usuario"); return(View(user)); } /*sign in*/ /* * var identity = new ClaimsIdentity(new[] * { * new Claim(ClaimTypes.Email, validUser.Email), * new Claim(ClaimTypes.Name, $"{validUser.FirstName} {validUser.LastName}"), * new Claim(ClaimTypes.NameIdentifier, validUser.Email) * }, * "ApplicationCookie"); * * var context = Request.GetOwinContext(); * var authManager = context.Authentication; * authManager.SignIn(identity); */ /*redireccionar al login*/ return(RedirectToAction("Login", "Account")); }
public ActionResult ByUser(UserWeb user) { try { var libUser = MapperWeb.Map(user); var checkUser = Repo.FindUserId(libUser.FirstName, libUser.LastName); if (checkUser > 0) { return(RedirectToAction("SearchResultsUser", "OrderHistory", new { searchID = checkUser, searchOption = user.SearchOption })); //add search option } else { ModelState.AddModelError(string.Empty, "User doesn't exist. Please retype your search"); return(View(user)); } // TODO: Add insert logic } catch { return(View()); } }