예제 #1
0
        public void EnrollStudent(int id, string name)
        {
            _context.Students.Add(new student
            {
                //studentId = id,
                Name = name,
                fine = 0
            });


            _context.SaveChanges();
        }
        public void bookissue(int id, string barcode)
        {
            var b = _context.Books.Where(x => x.barcode == barcode).FirstOrDefault();
            var s = _context.Students.Where(x => x.studentId == id).FirstOrDefault();

            if (b != null && s != null)
            {
                _context.studentbooks.Add(new studentbook()
                {
                    studentId   = id,
                    bookbarcode = barcode,
                    book        = b,
                    student     = s,
                    issuedate   = DateTime.Now
                });
                b.copycount -= 1;
                _context.SaveChanges();
            }
            //b.copycount += 1;
            //_context.SaveChanges();
        }
예제 #3
0
        public void AddBook(book book)
        {
            _context.Books.Add(new book
            {
                title     = book.title,
                author    = book.author,
                barcode   = book.barcode,
                copycount = book.copycount,
                edition   = book.edition
            });

            _context.SaveChanges();
        }