public fwUser Insert(fwUser obj) { var ID = DataUtilities.Insert(@"insert into fwUser([AspnetUserID], [UserName], [Name], [Email], [Status], [Locked], [Avata], [NotiCount], [Pass]) values(@AspnetUserID, @UserName, @Name, @Email, @Status, @Locked, @Avata, @NotiCount, @Pass)", CommandType.Text, "@AspnetUserID", obj.AspnetUserID, "@UserName", obj.UserName, "@Name", obj.Name, "@Email", obj.Email, "@Status", obj.Status, "@Locked", obj.Locked, "@Avata", obj.Avata, "@NotiCount", obj.NotiCount, "@Pass", obj.Pass); obj.ID = ID; return obj; }
private fwUser CreateObj(DataRow row) { var obj = new fwUser(); obj.ID = (int)row["ID"]; obj.AspnetUserID = row["AspnetUserID"].ToString(); obj.UserName = (string)row["UserName"]; obj.Name = GetString(row["Name"]); obj.Email = GetString(row["Email"]); obj.PhoneNumber = GetString(row["PhoneNumber"]); obj.Address = GetString(row["Address"]); obj.Status = (int)row["Status"]; obj.Locked = (bool)row["Locked"]; obj.Avata = GetString(row["Avata"]); obj.NotiCount = GetInt(row["NotiCount"]); obj.Avata = GetString(row["Pass"]); return obj; }
public bool UserInRole(fwUser user, params string[] roles) { if (user == null) return false; return UserInRole(user.ID, roles); }
public fwUser Update(fwUser obj) { var ID = DataUtilities.ExcuteNonQuery(@"update fwUser set [UserName]=@UserName, [Email]=@Email, [Status]=@Status, [Locked]=@Locked, [Avata]=@Avata, [NotiCount] = @NotiCount, [Pass]=@Pass where ID=@ID", CommandType.Text, "@UserName", obj.UserName, "@Name", obj.Name, "@Email", obj.Email, "@Status", obj.Status, "@Locked", obj.Locked, "@Avata", obj.Avata, "@NotiCount", obj.NotiCount, "@Pass", obj.Pass, "@ID", obj.ID); return obj; }
public ActionResult EditUser(fwUser model, string returnUrl) { if (model.ID == 0) new fwUserDAL().Insert(model); else new fwUserDAL().Update(model); return Redirect(returnUrl); }
public async Task<ActionResult> Register(RegisterViewModel model) { if (ModelState.IsValid) { var user = new ApplicationUser() { UserName = model.UserName }; var result = await UserManager.CreateAsync(user, model.Password); if (result.Succeeded) { var fwUser = new fwUser { AspnetUserID = user.Id, UserName = user.UserName, Locked = false, Status = 1 }; new fwUserDAL().Insert(fwUser); await SignInAsync(user, isPersistent: false); return RedirectToAction("Index", "Home"); } else { AddErrors(result); } } // If we got this far, something failed, redisplay form return View(model); }