public ActionResult EditAccountRole(UserRole userrole) { UserRole u = db.UserRole.FirstOrDefault(a => a.fid == userrole.fid); if (u != null) { u.fRole = userrole.fRole; db.SaveChanges(); } return(RedirectToAction("EditAccountRole")); }
// POST: api/Customer public int Post([FromBody] tCustomer data) { int num = 0; try { tCustomer customer = new tCustomer(); customer.fName = data.fName; customer.fPhone = data.fPhone; customer.fEmail = data.fEmail; customer.fAddress = data.fAddress; db.tCustomer.Add(customer); num = db.SaveChanges(); } catch (Exception e) { num = 0; } return num; }
// 新增 // POST: api/Customer public int Post(string fname, string fphone, string femail, string faddress) { int num = 0; try { tCustomer customer = new tCustomer(); customer.fName = fname; customer.fPhone = fphone; customer.fEmail = femail; customer.fAddress = faddress; db.tCustomer.Add(customer); num = db.SaveChanges(); } catch (Exception ex) { num = 0; } return(num); }
//註冊新會員 public void Register(CRegister member) { Member c = new Member(); c.fAccount = member.account; //c.fPassword = HashPassword(member.fPassword); c.fPassword = member.password; c.fBirthday = member.birthday; c.fEmail = member.email; c.fName = member.name; c.fBuildtime = DateTime.Now; c.fRole = 1; //c.fAuthCode = Guid.NewGuid().ToString(); db.Member.Add(c); db.SaveChanges(); }
//註冊驗證 public ActionResult Verify(string AuthCode) { using (dbCustomerEntities db = new dbCustomerEntities()) { var memberData = db.Member.Where(a => a.fAuthCode == AuthCode).FirstOrDefault(); if (memberData != null) { ViewData["Result"] = "會員驗證成功"; memberData.fAuthCode = null; db.SaveChanges(); } else { ViewData["Result"] = "找不到此驗證碼,請確認是否驗證過?"; } } return(View()); }