public void OnPostSearch() { try { var res = _identityProvider.AdminGetUserAsync(new AdminGetUserRequest() { Username = SearchEmailAddress, UserPoolId = _userPool.PoolID }).Result; Message = "Found a user"; UserInfoSet ui = new UserInfoSet(); ui.Username = res.Username; List <KeyValuePair <string, string> > att = new List <KeyValuePair <string, string> >(); foreach (var a in res.UserAttributes) { att.Add(new KeyValuePair <string, string>(a.Name, a.Value)); } ui.Attributes = att; ui.IsEnabled = res.Enabled; ui.CreatedDate = res.UserCreateDate; UserInfo = ui; } catch (System.AggregateException ex) { if (ex.InnerException.GetType() == typeof(UserNotFoundException)) { Message = $"There is no such user with the email address {SearchEmailAddress}"; } } }
public ActionResult Delete(FormCollection collection) { UserInfoSet user = new UserInfoSet() { UserId = int.Parse(collection["UserId"]), UserName = collection["UserName"] }; userService.Delete(user); return(RedirectToAction("Index")); }
public ActionResult Create(FormCollection collection) { UserInfoSet user = new UserInfoSet() { UserName = collection["UserName"], Email = collection["Email"], UserAge = Int16.Parse(collection["UserAge"]), ClassInfoClassId = int.Parse(collection["ClassInfoClassId"]) }; userService.Add(user); return(RedirectToAction("Index")); }
public void OnPostCreateClaim() { List <AttributeType> att = new List <AttributeType>(); att.Add(new AttributeType() { Name = CustomClaim.Key, Value = CustomClaim.Value }); try { AdminUpdateUserAttributesRequest updateRequest = new AdminUpdateUserAttributesRequest(); updateRequest.Username = UserInfo.Username; updateRequest.UserPoolId = _userPool.PoolID; updateRequest.UserAttributes = att; var res = _identityProvider.AdminUpdateUserAttributesAsync(updateRequest).Result; if (res.HttpStatusCode == System.Net.HttpStatusCode.OK) { Message = "Successfully added the new attribute"; } var newUserInfo = _identityProvider.AdminGetUserAsync(new AdminGetUserRequest() { Username = UserInfo.Username, UserPoolId = _userPool.PoolID }).Result; Message = "Found a user"; UserInfoSet ui = new UserInfoSet(); ui.Username = newUserInfo.Username; List <KeyValuePair <string, string> > newAtt = new List <KeyValuePair <string, string> >(); foreach (var a in newUserInfo.UserAttributes) { newAtt.Add(new KeyValuePair <string, string>(a.Name, a.Value)); } ui.Attributes = newAtt; ui.IsEnabled = newUserInfo.Enabled; ui.CreatedDate = newUserInfo.UserCreateDate; UserInfo = ui; }catch (System.AggregateException ex) { Message = ex.Message; } Console.WriteLine("test"); }
public ContentResult AddUser() { string name = Request.Form["name"]; string pass = Request.Form["pass"]; string detail = (Request.Form["detail"] == "" ? "暂无描述" : Request.Form["detail"]); string phone = Request.Form["phone"]; int comid = int.Parse(Request.Form["compid"]); int roleid = int.Parse(Request.Form["roleid"]); string image = "";//暂时的 string realName = Request.Form["realname"]; if (db.UserInfoSet.Where <UserInfoSet>(u => (u.UserName == name)).FirstOrDefault() != null) { return(Content("ex")); } UserInfoSet user = new UserInfoSet() { UserName = name, UserPass = pass, Detail = detail, Phone = phone, CompId = comid, RoleId = roleid, Image = image, RealName = realName, SubTime = DateTime.Now, ModifTime = DateTime.Now, DelFlag = false }; if (userBll.AddEntity(user) != null) { return(Content("ok")); } else { return(Content("no")); } }
public ContentResult EditUser(string roleid, string username, string realname, string phone, string detail, string id, string userpass) { int uid = int.Parse(id); UserInfoSet user = userBll.LoadEntities(u => u.Id == uid).FirstOrDefault <UserInfoSet>(); user.UserName = username; user.RealName = realname; user.Phone = phone; user.Detail = detail; user.RoleId = int.Parse(roleid); if (!userpass.Equals("在这里输入修改密码")) { user.UserPass = userpass; } if (userBll.EditEntity(user) == true) { return(Content("ok")); } else { return(Content("no")); } }