public ActionResult Registered(RegisteredViewModel data) { if (ModelState.IsValid) { if (db.B鳥奴.Where(x => x.Email == data.Email).Any()) { ModelState.AddModelError("", "此帳號已被註冊"); return(View(data)); } B鳥奴 bUser = new B鳥奴() { Email = data.Email, UserName = data.UserName, Password = data.Password, Tel = data.Tel }; db.B鳥奴.Add(bUser); db.SaveChanges(); return(RedirectToAction("Index", "Bird")); } return(View(data)); }
public async Task <ActionResult> DeleteConfirmed(int id) { B鳥奴 b鳥奴 = await db.B鳥奴.FindAsync(id); db.B鳥奴.Remove(b鳥奴); await db.SaveChangesAsync(); return(RedirectToAction("Index")); }
public async Task <ActionResult> Edit([Bind(Include = "UserId,Email,UserName,Tel")] B鳥奴 b鳥奴) { if (ModelState.IsValid) { db.Entry(b鳥奴).State = EntityState.Modified; await db.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(b鳥奴)); }
private bool CheckLogin(string Email, string password) { B鳥奴 dUser = db.B鳥奴.Where(x => x.Email == Email).FirstOrDefault(); if (dUser.Password.Equals(password)) { return(true); } ModelState.AddModelError("", "帳號或密碼錯誤"); return(false); }
public async Task <ActionResult> Create([Bind(Include = "Email,UserName,Tel")] B鳥奴 b鳥奴) { if (ModelState.IsValid) { db.B鳥奴.Add(b鳥奴); await db.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(b鳥奴)); }
// GET: BirdSlave/Delete/5 public async Task <ActionResult> Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } B鳥奴 b鳥奴 = await db.B鳥奴.FindAsync(id); if (b鳥奴 == null) { return(HttpNotFound()); } return(View(b鳥奴)); }