public int Index(string posttitle, string text, string useremail, string userkey, string anony) { accountuser user = new accountuser(); user = userstoredb.user.Where(u => u.useremail == useremail).First(); if (!userkey.Equals(user.userkey)) { return(-1); } try { post post = new post(); post.userid = user.userid; post.posttitle = posttitle; post.text = text; post.date = DateTime.Now; post.anonymity = int.Parse(anony); storedb.post.Add(post); storedb.SaveChanges(); return(1); } catch { return(-1); } }
public string Index(string userEmail, string userOldPwd, string userNewPwd) { // user user = new user(); try { accountuser user = storedb.user.Where(u => u.useremail == userEmail).First(); // user = storedb.user.Where(u => u.useremail == userEmail).First(); if (user.userpwd == userOldPwd) { //storedb.user.Remove(user); //storedb.SaveChanges(); user.userpwd = userNewPwd; System.Security.Cryptography.MD5 md5 = new System.Security.Cryptography.MD5CryptoServiceProvider(); byte[] bytResult = md5.ComputeHash(System.Text.Encoding.Default.GetBytes(userEmail + userNewPwd)); string userKey = BitConverter.ToString(bytResult, 4, 8); userKey = userKey.Replace("-", ""); user.userkey = userKey; // storedb.user.Add(user); storedb.SaveChanges(); return(user.userkey); } else { return("0"); } } catch { return("-1"); } }
// // GET: /UserVerify/ public string Index(string userEmail, string captcha) { accountuser user = userstoredb.user.Where(u => u.useremail == userEmail).First(); if (user.captcha.Equals(captcha)) { user.isverify = 1; userstoredb.SaveChanges(); return("验证成功"); } else { return("验证失败"); } }
// // GET: /UserRegister/ public string Index(String userName, String userEmail, String userPwd, String userMobile, String userDepart, String userNum, String userRealName) { accountuser user = new accountuser(); if (storedb.user.Where(u => u.useremail == userEmail).Count() != 0) { return("-1"); } if (storedb.user.Where(u => u.username == userName).Count() != 0) { return("-1"); } System.Security.Cryptography.MD5 userkeymd5 = new System.Security.Cryptography.MD5CryptoServiceProvider(); byte[] userkeybytResult = userkeymd5.ComputeHash(System.Text.Encoding.Default.GetBytes(userEmail + userPwd)); string userKey = BitConverter.ToString(userkeybytResult, 4, 8); userKey = userKey.Replace("-", ""); System.Security.Cryptography.MD5 captchamd5 = new System.Security.Cryptography.MD5CryptoServiceProvider(); byte[] captchabytResult = captchamd5.ComputeHash(System.Text.Encoding.Default.GetBytes(userEmail)); string captcha = BitConverter.ToString(captchabytResult, 0, 4); captcha = captcha.Replace("-", ""); try { user.username = userName; user.useremail = userEmail; user.userpwd = userPwd; user.usermobile = userMobile; user.userdepart = userDepart; user.usernum = userNum; user.userrealname = userRealName; user.userkey = userKey; user.captcha = captcha; user.isverify = 0; if (!sendCaptcha(userEmail, captcha)) { return("-1"); } storedb.user.Add(user); storedb.SaveChanges(); return(userKey); } catch { return("-1"); } }
public string Index(string userEmail, string userPwd) { accountuser user = new accountuser(); try { user = storedb.user.Where(u => u.useremail == userEmail).First(); if (user.userpwd == userPwd) { return(user.username + "," + user.userkey); } else { return("-1"); } } catch { return("-1"); } }
public int Index(string userName, string userEmail) { if (storedb.user.Where(u => u.useremail == userEmail).Count() == 0) { try { accountuser user = new accountuser(); user.username = userName; user.useremail = userEmail; user.userkey = userEmail; user.userpwd = DateTime.Now.ToString(); user.isverify = 1; storedb.user.Add(user); storedb.SaveChanges(); return(1); } catch { return(0); } } return(0); }