//[ValidateAntiForgeryToken] public ActionResult Create(string ID, string Password, string Name, string AccountContent, bool IsEnable) { Rio_Account rio_Account = new Rio_Account(); string createID = string.Empty; if (HttpContext.Session["UserID"] != null) { createID = HttpContext.Session["UserID"].ToString(); } DateTime dt = DateTime.Now; rio_Account.ID = ID; rio_Account.Name = Name; rio_Account.Password = App_Code.Coding.stringToSHA512(Password); rio_Account.AccountContent = AccountContent; rio_Account.Email = string.Empty; rio_Account.PicSN = 0; rio_Account.CreateID = createID; rio_Account.CreateName = createID; rio_Account.ModifyID = createID; rio_Account.ModifyName = createID; rio_Account.CreateDate = dt; rio_Account.ModifyDate = dt; rio_Account.IsEnable = IsEnable; rio_Account.IsDelete = false; AccountModel.Insert(rio_Account); return(RedirectToAction("Index")); }
public ActionResult Edit(int SN, string Name, string Password, string AccountContent, int PicSN, bool IsEnable) { if (ModelState.IsValid) { Rio_Account rio_Account = db.Rio_Account.Find(SN); string modifyID = string.Empty; DateTime dt = DateTime.Now; if (HttpContext.Session["UserID"] != null) { modifyID = HttpContext.Session["UserID"].ToString(); } rio_Account.Name = Name; rio_Account.Password = App_Code.Coding.stringToSHA512(Password); rio_Account.AccountContent = AccountContent; rio_Account.PicSN = PicSN; rio_Account.ModifyID = modifyID; rio_Account.ModifyName = modifyID; rio_Account.ModifyDate = dt; rio_Account.IsEnable = IsEnable; AccountModel.Update(rio_Account); } return(RedirectToAction("Index")); }
private Rio_Account saveFBAccount(string email, string name) { Rio_Account rio_Account = new Rio_Account(); string createID = "FaceBookRegister"; DateTime dt = DateTime.Now; Random random = new Random(); int randomNumber = random.Next(1000, 9999); email = email.Split('@')[0]; rio_Account.ID = email + randomNumber; rio_Account.Name = name; rio_Account.Password = string.Empty; rio_Account.AccountContent = string.Empty; rio_Account.Email = string.Empty; rio_Account.PicSN = 0; rio_Account.CreateID = createID; rio_Account.CreateName = createID; rio_Account.ModifyID = createID; rio_Account.ModifyName = createID; rio_Account.CreateDate = dt; rio_Account.ModifyDate = dt; rio_Account.IsEnable = true; rio_Account.IsDelete = false; rio_Account.IsFBAccount = true; AccountModel.Insert(rio_Account); return(rio_Account); }
public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; string UserID = string.Empty; if (context.Session["UserID"] != null) { UserID = context.Session["UserID"].ToString(); } if (context.Request.QueryString["s"] != null && context.Request.QueryString["t"] != null) { int SN = 0; int picSN = 0; string type = string.Empty; SN = AccountModel.getAccountByID(UserID).SN; type = context.Request.QueryString["t"].ToString(); int.TryParse(context.Request.QueryString["s"], out picSN); if (type.Equals("Account")) { Rio_Account Account = AccountModel.getAccountByID(UserID); Account.PicSN = picSN; AccountModel.Update(Account); } else if (type.Equals("Index")) { Rio_UserIndexSetting userSetting = UserIndexSettingMode.getUserIndexSettingBySN(SN); userSetting.CoverSN = picSN; UserIndexSettingMode.Update(userSetting); } } }
public ActionResult DeleteConfirmed(int id) { Rio_Account rio_Account = db.Rio_Account.Find(id); //db.Rio_Account.Remove(rio_Account); rio_Account.IsDelete = true; AccountModel.Update(rio_Account); return(RedirectToAction("Index")); }
public ActionResult RioAccountRegister(string ID, string Password, string Name, string AccountContent) { #region Google reCAPTCHA驗證 var response = Request["g-recaptcha-response"]; string secretKey = "6LdrUTgUAAAAAC-zzRKYaXa4KjCJSon9K6K9gaJr"; var client = new WebClient(); var result = client.DownloadString(string.Format("https://www.google.com/recaptcha/api/siteverify?secret={0}&response={1}", secretKey, response)); var obj = JObject.Parse(result); var status = (bool)obj.SelectToken("success"); #endregion if (status == true) { Vw_Account Account = AccountModel.getVwAccountByID(ID); if (Account == null) { if (!ID.Equals(string.Empty) && !Password.Equals(string.Empty) && !Name.Equals(string.Empty)) { Rio_Account rio_Account = new Rio_Account(); string createID = "UserRegister"; DateTime dt = DateTime.Now; rio_Account.ID = ID; rio_Account.Name = Name; rio_Account.Password = App_Code.Coding.stringToSHA512(Password); rio_Account.AccountContent = AccountContent; rio_Account.Email = string.Empty; rio_Account.PicSN = 0; rio_Account.CreateID = createID; rio_Account.CreateName = createID; rio_Account.ModifyID = createID; rio_Account.ModifyName = createID; rio_Account.CreateDate = dt; rio_Account.ModifyDate = dt; rio_Account.IsEnable = true; rio_Account.IsDelete = false; AccountModel.Insert(rio_Account); HttpContext.Session["UserID"] = ID; HttpContext.Session["IsLogin"] = "******"; } } else { ModelState.AddModelError("ID", "已有相同帳號。"); } } return(View()); }
// GET: Rio_Account/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Rio_Account rio_Account = db.Rio_Account.Find(id); if (rio_Account == null) { return(HttpNotFound()); } return(View(rio_Account)); }
// GET: Rio_Account/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Rio_Account rio_Account = db.Rio_Account.Find(id); rio_Account.Password = string.Empty; if (rio_Account == null) { return(HttpNotFound()); } return(View(rio_Account)); }
public ActionResult SelectCover(string type, int SN) { int accountSN = 0; int.TryParse(Session["UserSN"].ToString(), out accountSN); string userID = Session["UserID"].ToString() ?? string.Empty; if (type.Equals("Account")) { Rio_Account Account = AccountModel.getAccountByID(userID); Account.PicSN = SN; AccountModel.Update(Account); } else if (type.Equals("Index")) { Rio_UserIndexSetting userSetting = UserIndexSettingMode.getUserIndexSettingBySN(accountSN); userSetting.CoverSN = SN; UserIndexSettingMode.Update(userSetting); } return(Content("Save Success")); }
//[ValidateAntiForgeryToken] public ActionResult UserSetting(string Password, string Name, string AccountContent) { string UserID = string.Empty; if (Session["UserID"] != null) { UserID = Session["UserID"].ToString(); } int SN = AccountModel.getAccountByID(UserID).SN; Rio_Account Account = db.Rio_Account.Find(SN); if (!Password.Equals(string.Empty)) { Account.Password = App_Code.Coding.stringToSHA512(Password); } Account.Name = Name; Account.AccountContent = AccountContent; AccountModel.Update(Account); return(RedirectToAction("UserSetting")); }
public ActionResult fbLogin(string id, string name, string email) { if (email != null) { Vw_Account account = AccountModel.getVwAccountByFBEmail(email); if (account == null) { Rio_Account rio_Account = saveFBAccount(email, name); //註冊新帳號 int accountSN = AccountModel.getVwAccountByID(rio_Account.ID).SN; // get帳號SN saveFacebookAccount(accountSN, email, id, name); //加入FB使用者資訊(id, name, email) Session["UserSN"] = accountSN; Session["UserID"] = rio_Account.ID; } else { Session["UserSN"] = account.SN; Session["UserID"] = account.ID; } } return(RedirectToAction("Login")); }