public ActionResult updateUserInfo([Bind(Include = "userid,language,location,linkavatar,displayname,birthday")] UserInfo userInfo) { if (ModelState.IsValid) { db.Entry(userInfo).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.userid = new SelectList(db.AspNetUsers, "Id", "Email", userInfo.userid); return(View(userInfo)); }
private void addNewUserInfor(string userid) { ProjectDEntities db = new ProjectDEntities(); UserInfo user = new UserInfo(); user.steamid = userid; var client = new WebClient(); var content = client.DownloadString("http://api.steampowered.com/ISteamUser/GetPlayerSummaries/v0002/?key=" + StaticData.Keys + "&steamids=" + userid); JObject result = (JObject)JsonConvert.DeserializeObject(content); user.userid = userid; user.username = (string)result["response"]["players"][0]["personaname"]; user.Totalscore = 0; user.steamid = userid; user.linkavatar = (string)result["response"]["players"][0]["avatarmedium"]; user.displayname = user.username; user.birthday = DateTime.Now; db.UserInfoes.Add(user); db.SaveChanges(); }