Ejemplo n.º 1
0
        // GET: Books
        public ActionResult Index()
        {
            _bookEntities = new bookEntities();
            List <books> books = _bookEntities.books.ToList();

            return(View(books));
        }
Ejemplo n.º 2
0
        public ActionResult Update(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(System.Net.HttpStatusCode.BadRequest));
            }
            var db       = new bookEntities();
            var toUpdate = db.books.Find(id);

            return(View(toUpdate));
        }
Ejemplo n.º 3
0
        public ActionResult Delete(int?id)
        {
            var db       = new bookEntities();
            var toDelete = db.books.Find(id);

            if (toDelete != null)
            {
                db.books.Remove(toDelete);
                db.SaveChanges();
            }
            return(RedirectToAction("Show", "Admin"));
        }
Ejemplo n.º 4
0
 public ActionResult Create(book model)
 {
     if (ModelState.IsValid)
     {
         var db = new bookEntities();
         db.books.Add(new book
         {
             Firstname  = model.Firstname,
             Secondname = model.Secondname,
             Bookname   = model.Bookname,
             Author     = model.Author,
             Datetaken  = model.Datetaken
         }); db.SaveChanges();
     }
     return(RedirectToAction("Show", "Admin"));
 }
Ejemplo n.º 5
0
        public ActionResult Update(int?id, book model)
        {
            var db       = new bookEntities();
            var toUpdate = db.books.Find(id);

            if (ModelState.IsValid)
            {
                if (toUpdate != null)
                {
                    toUpdate.Id         = id ?? default(int);
                    toUpdate.Firstname  = model.Firstname;
                    toUpdate.Secondname = model.Secondname;
                    toUpdate.Bookname   = model.Bookname;
                    toUpdate.Author     = model.Author;
                    toUpdate.Datetaken  = model.Datetaken;
                    db.SaveChanges();
                }
            }
            return(RedirectToAction("Show", "Admin"));
        }
Ejemplo n.º 6
0
        public ActionResult Show()
        {
            var entities = new bookEntities();

            return(View(entities.books.ToList()));
        }