Exemple #1
0
        public ActionResult Create(Book book)
        {
            if (!User.Identity.Name.Equals("admin"))
            {
                WebSecurity.Logout();
                return RedirectToAction("Login", "Account");
            }
            if (ModelState.IsValid)
            {
                db.Books.Add(book);
                db.SaveChanges();
                return RedirectToAction("Index");
            }

            return View(book);
        }
Exemple #2
0
 public ActionResult Edit(Book book)
 {
     if (!User.Identity.Name.Equals("admin"))
     {
         WebSecurity.Logout();
         return RedirectToAction("Login", "Account");
     }
     if (ModelState.IsValid)
     {
         db.Entry(book).State = EntityState.Modified;
         db.SaveChanges();
         return RedirectToAction("Index");
     }
     return View(book);
 }