Exemplo n.º 1
0
        public async Task <IActionResult> Edit(int id, [Bind("DeweyID,Name,Number")] Dewey dewey)
        {
            if (id != dewey.DeweyID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(dewey);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!DeweyExists(dewey.DeweyID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction("Index"));
            }
            return(View(dewey));
        }
        public ActionResult DeleteConfirmed(int id)
        {
            Dewey dewey = db.Dewey.Find(id);

            db.Dewey.Remove(dewey);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
 public ActionResult Edit([Bind(Include = "id,dewey_number,dewey_name")] Dewey dewey)
 {
     if (ModelState.IsValid)
     {
         db.Entry(dewey).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(dewey));
 }
        public ActionResult Create([Bind(Include = "id,dewey_number,dewey_name")] Dewey dewey)
        {
            if (ModelState.IsValid)
            {
                db.Dewey.Add(dewey);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(dewey));
        }
Exemplo n.º 5
0
        public async Task <IActionResult> Create([Bind("DeweyID,Name,Number")] Dewey dewey)
        {
            if (ModelState.IsValid)
            {
                _context.Add(dewey);
                await _context.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            return(View(dewey));
        }
        // GET: Deweys/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Dewey dewey = db.Dewey.Find(id);

            if (dewey == null)
            {
                return(HttpNotFound());
            }
            return(View(dewey));
        }
Exemplo n.º 7
0
 public BoekInformation(
     Tietel tietel,
     Skrywer skrywer,
     Genres genre,
     OuderdomsGroepe ouderdomsGroep,
     BoekNommer boekNommer,
     Dewey dewey,
     Tale taal)
 {
     this.Tietel         = tietel;
     this.Skrywer        = skrywer;
     this.Genre          = genre;
     this.OuderdomsGroep = ouderdomsGroep;
     this.BoekNommer     = boekNommer;
     this.Dewey          = dewey;
     this.Taal           = taal;
 }
Exemplo n.º 8
0
        public static void Initialize(LibraryContext context)
        {
            //context.Database.EnsureDeleted();
            //context.Database.EnsureCreated();

            /*The following is if you want to check befoe deleting
             * this will be removed before version 1.0.0 beta release
             * if you see this in the code after the release please
             * remove it. */

            /*if(context.Students.Any())
             * {
             *  return; //DB has been seeded
             * }*/

            var teachers = new Teacher[]
            {
                new Teacher {
                    FirstName = "Erik2", LastName = "Henderson", Grade = 3
                }
            };

            foreach (Teacher s in teachers)
            {
                context.Teachers.Add(s);
            }

            context.SaveChanges();

            var students = new Student[]
            {
                new Student {
                    FirstName = "John", LastName = "Tell", Email = "*****@*****.**", Grade = 3, TeacherID = 1, Fines = 01.50M, IssuedID = 10254
                },
                new Student {
                    FirstName = "Mike", LastName = "Hest", Email = "*****@*****.**", Grade = 5, TeacherID = 1, Fines = 01.50M, IssuedID = 13254
                }
            };

            foreach (Student s in students)
            {
                context.Students.Add(s);
            }

            context.SaveChanges();

            var genres = new Genre[]
            {
                new Genre {
                    Name = "Horror"
                },
                new Genre {
                    Name = "Romance"
                },
                new Genre {
                    Name = "Blah "
                },
                new Genre {
                    Name = "Blah2"
                }
            };

            foreach (Genre s in genres)
            {
                context.Genres.Add(s);
            }

            context.SaveChanges();

            var deweys = new Dewey[]
            {
                new Dewey {
                    Name = "Computer Science, Information & General Works", Number = 000
                },
                new Dewey {
                    Name = "Philosophy & Psychology", Number = 100
                },
                new Dewey {
                    Name = "Religion", Number = 200
                }
            };

            foreach (Dewey s in deweys)
            {
                context.Deweys.Add(s);
            }

            context.SaveChanges();

            var books = new Book[]
            {
                new Book {
                    Title = "Moby Dick", SubTitle = "", Author = "Author Guy", ISBN = 12345, GenreID = 4, DeweyID = 1
                },
                new Book {
                    Title = "Book 2", SubTitle = "", Author = "James Dean", ISBN = 12346, GenreID = 2, DeweyID = 2
                },
                new Book {
                    Title = "Book3", SubTitle = "", Author = "Alex Ander", ISBN = 12347, GenreID = 1, DeweyID = 3
                }
            };

            foreach (Book s in books)
            {
                context.Books.Add(s);
            }

            context.SaveChanges();

            var bookloans = new BookLoan[]
            {
                new BookLoan {
                    BookID = 1, StudentID = 1, CheckedOutOn = new DateTime(2016, 9, 21), DueOn = new DateTime(2016, 10, 21)
                }
            };

            foreach (BookLoan s in bookloans)
            {
                context.BookLoans.Add(s);
            }

            context.SaveChanges();


            var settings = new Setting[]
            {
                new Setting {
                    FineAmountPerDay = 00.25M, CheckoutDurationInDays = 30, AreFinesEnabled = true
                }
            };

            foreach (Setting s in settings)
            {
                context.Settings.Add(s);
            }

            context.SaveChanges();
        }