public Student FindById(int id)
        {
            Student s = null;

            using (var ctx = new UckLibMgrDbEntities())
            {
                s = ctx.Students.Find(id);
            }
            return(s);
        }
Esempio n. 2
0
        public Book FindById(int id)
        {
            Book book;

            using (var ctx = new UckLibMgrDbEntities())
            {
                book = ctx.Books.Find(id);
            }
            return(book);
        }
        public int NewStudent(Student student)
        {
            int rows = 0;

            using (var ctx = new UckLibMgrDbEntities())
            {
                ctx.Students.Add(student);
            }
            return(rows);
        }
        public int NewLogin(Login login)
        {
            int rows = 0;

            using (var ctx = new UckLibMgrDbEntities())
            {
                ctx.Logins.Add(login);
                rows = ctx.SaveChanges();
            }
            return(rows);
        }
Esempio n. 5
0
        public int NewBook(Book book)
        {
            int rows = 0;

            using (var ctx = new UckLibMgrDbEntities())
            {
                ctx.Books.Add(book);
                rows = ctx.SaveChanges();
            }
            return(rows);
        }
        public int NewLog(LogRegister log)
        {
            int rows = 0;

            using (var ctx = new UckLibMgrDbEntities())
            {
                ctx.LogRegisters.Add(log);
                rows = ctx.SaveChanges();
            }
            return(rows);
        }
        public Book FindByTitle(String title)
        {
            Book book = null;

            using (var ctx = new UckLibMgrDbEntities())
            {
                var bk = ctx.Books.Where(b => b.Ttile == title);
                book = (Book)bk.ToList().FirstOrDefault();
            }
            return(book);
        }
Esempio n. 8
0
        public int NewIssue(Issue issue)
        {
            int rows = 0;

            using (var ctx = new UckLibMgrDbEntities())
            {
                ctx.Issues.Add(issue);
                rows = ctx.SaveChanges();
            }
            return(rows);
        }
        public List <Book> GetAllBooks()
        {
            List <Book> books = null;

            using (var ctx = new UckLibMgrDbEntities())
            {
                var bks = from book in ctx.Books
                          select book;
                books = bks.ToList();
            }
            return(books);
        }
        public List <String> GetAllStudentNames()
        {
            List <String> studentNames = null;

            using (var ctx = new UckLibMgrDbEntities())
            {
                var sts = from student in ctx.Students
                          select student.Name;
                studentNames = sts.ToList();
            }
            return(studentNames);
        }
        public Student FindByName(String student)
        {
            Student s = null;

            using (var ctx = new UckLibMgrDbEntities())
            {
                var st = ctx.Students.Where(stu => stu.Name == student);

                s = (Student)st;
            }
            return(s);
        }
Esempio n. 12
0
        public int UpdateIssue(Issue issue)
        {
            int rows = 0;

            using (var ctx = new UckLibMgrDbEntities())
            {
                var i = ctx.Issues.Where(iss => iss.IssueId == issue.IssueId).ToList().FirstOrDefault();
                i.IssueDate    = issue.IssueDate;
                i.ModifiedDate = issue.ModifiedDate;
            }
            return(rows);
        }
        public Login FindByUserName(String userName)
        {
            Login login = null;

            using (var ctx = new UckLibMgrDbEntities())
            {
                var adminLogin = ctx.Logins.Where(l => l.UserName == userName);
                if (adminLogin != null)
                {
                    login = (Login)adminLogin.ToList().FirstOrDefault();
                }
            }
            return(login);
        }
Esempio n. 14
0
        public Issue FIndById(int issueId)
        {
            Issue bookIssue = null;

            using (var ctx = new UckLibMgrDbEntities())
            {
                var i = ctx.Issues.Where(iss => iss.IssueId == issueId);
                if (i != null)
                {
                    bookIssue = (Issue)i.ToList().FirstOrDefault();
                }
            }
            return(bookIssue);
        }
        public int UpdateBook(int bookId, String title, String author,
                              String publisher, DateTime publishDate,
                              String isbn)
        {
            int rows = 0;

            using (var ctx = new UckLibMgrDbEntities())
            {
                var book = ctx.Books.Find(bookId);
                book.Ttile         = title;
                book.Author        = author;
                book.Publisher     = publisher;
                book.PublishedDate = publishDate;
                book.ISBN          = isbn;
                book.ModifiedDate  = DateTime.Now;
                rows = ctx.SaveChanges();
            }
            return(rows);
        }