public LibrarianRepositoryTest()
 {
     repositoryFactory           = new T();
     libraryDepartmentRepository = repositoryFactory.CreateLibraryDepartmentRepository();
     librarianRepository         = repositoryFactory.CreateLibrarianRepository(libraryDepartmentRepository);
     countItems = librarianRepository.GetItems().Count();
 }
Example #2
0
        static Unit()
        {
            Context = new MyAppDbContext(
                new DbContextOptionsBuilder <MyAppDbContext>()
                .UseSqlServer(new SqlConnectionStringBuilder
            {
                DataSource         = "127.0.0.1",
                InitialCatalog     = "Univercity",
                IntegratedSecurity = true
            }.ConnectionString)
                .Options);

            Context.Database.EnsureDeleted();
            Context.Database.EnsureCreated();

            AuthorRepository     = new AuthorRepository(Context);
            BookRepository       = new BookRepository(Context);
            CategoryRepository   = new CategoryRepository(Context);
            DepartmentRepository = new DepartmentRepository(Context);
            ECardRepository      = new ECardsRepository(Context);
            EmployeeRepository   = new EmploeeRepository(Context);
            FacultyRepository    = new FacultyRepository(Context);
            GroupRepository      = new GroupRepository(Context);
            LibrarianRepository  = new LibrarianRepository(Context);
            PressRepository      = new PressRepository(Context);
            SCardRepository      = new SCardsRepository(Context);
            StudentRepository    = new StudentRepository(Context);
            ThemeRepository      = new ThemeRepository(Context);
        }
Example #3
0
        public void addButton_Click(object sender, EventArgs e)
        {
            var          addReaderForm = new AddLibrarianForm();
            DialogResult dialogResult  = addReaderForm.ShowDialog(this);

            if (dialogResult == DialogResult.Cancel)
            {
                return;
            }

            string   name       = addReaderForm.nameTextBox.Text;
            string   surname    = addReaderForm.surnameTextBox.Text;
            string   patronymic = addReaderForm.patronymicTextBox.Text;
            DateTime DoB        = addReaderForm.dateTimePicker.Value;
            string   telNumber  = addReaderForm.telNumberTextBox.Text;

            var reader = new Librarian
            {
                Name            = name,
                Surname         = surname,
                Patronymic      = patronymic,
                DateOfBirth     = DoB,
                TelephoneNumber = telNumber
            };

            var readerRepository = new LibrarianRepository();

            readerRepository.Create(reader);

            _db.SaveChanges();
            SetDataGridView();
        }
Example #4
0
        private void findByIdButton_Click(object sender, EventArgs e)
        {
            var librarianRepository = new LibrarianRepository();

            if (string.IsNullOrEmpty(idNumericUpDown.Value.ToString()))
            {
                SetDataGridView();
                return;
            }

            List <Librarian> librarians = new List <Librarian>();
            Librarian        librarian  = librarianRepository.FindById((int)idNumericUpDown.Value);

            librarians.Add(librarian);
            if (librarian == null)
            {
                dataGridView1.DataSource = "No readers found";
                return;
            }

            dataGridView1.DataSource = librarians.Select(r => new
            {
                r.Id,
                r.Name,
                r.Surname,
                r.Patronymic,
                r.DateOfBirth,
                r.TelephoneNumber
            }).ToList();
        }
Example #5
0
        private void findBySurnameButton_Click(object sender, EventArgs e)
        {
            var librarianRepository = new LibrarianRepository();

            if (string.IsNullOrEmpty(surnameTextBox.Text))
            {
                SetDataGridView();
                return;
            }
            List <Librarian> librarians = librarianRepository.FindBySurname(surnameTextBox.Text);

            if (librarians == null)
            {
                dataGridView1.DataSource = "No readers found";
                return;
            }

            dataGridView1.DataSource = librarians.OrderBy(b => b.Id)
                                       .Select(b => new
            {
                b.Id,
                b.Name,
                b.Surname,
                b.Patronymic,
                b.DateOfBirth,
                b.TelephoneNumber
            }).ToList();;
        }
Example #6
0
        private void patronymicLinkLabel_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            var       librarianRepository = new LibrarianRepository();
            LinkLabel thisLinkLabel       = (sender as LinkLabel);

            var readers = librarianRepository.Get().Select(r => new {
                r.Id,
                r.Name,
                r.Surname,
                r.Patronymic,
                r.DateOfBirth,
                r.TelephoneNumber
            });

            if (thisLinkLabel.Text.Contains("˄"))
            {
                dataGridView1.DataSource = readers.OrderBy(r => r.Patronymic).ToList();
                thisLinkLabel.Text       = thisLinkLabel.Text.Split('˄')[0] + "˅";
            }
            else
            {
                dataGridView1.DataSource = readers.OrderByDescending(r => r.Patronymic).ToList();
                thisLinkLabel.Text       = thisLinkLabel.Text.Split('˅')[0] + "˄";
            }
        }
Example #7
0
        bool ConfirmLibrarian()
        {
            ConfirmForm  conForm   = new ConfirmForm();
            DialogResult conResult = conForm.ShowDialog(this);

            if (conResult == DialogResult.Cancel)
            {
                return(false);
            }

            if (conForm.idTextBox.Text.ToUpper().Equals("ADMIN") && conForm.surnameTextBox.Text.ToUpper().Equals("PASSWORD"))
            {
                var          adminForm    = new AdminForm();
                DialogResult dialogResult = adminForm.ShowDialog(this);
                return(true);
            }

            int    id      = int.Parse(conForm.idTextBox.Text);
            string surname = conForm.surnameTextBox.Text;
            LibrarianRepository librRep = new LibrarianRepository();
            var librarian = librRep.FindById(id);

            if (librarian == null || librarian.Surname.ToUpper() != surname.ToUpper())
            {
                return(false);
            }

            _librarianId = id;

            return(true);
        }
 public OrderObjectRepository(ReaderRepository readerRepository, BookRepository bookRepository, 
     LibraryDepartmentRepository libraryDepartmentRepository, LibrarianRepository librarianRepository)
 {
     this.readerRepository = readerRepository;
     this.bookRepository = bookRepository;
     this.libraryDepartmentRepository = libraryDepartmentRepository;
     this.librarianRepository = librarianRepository;
     orders = new List<Order>();
 }
Example #9
0
 public LibrarianRepositoryTest()
 {
     repositoryFactory           = new T();
     libraryDepartmentRepository = repositoryFactory.CreateLibraryDepartmentRepository();
     librarianRepository         = repositoryFactory.CreateLibrarianRepository(libraryDepartmentRepository);
     countItems = librarianRepository.GetItems().Count();
     department = new LibraryDepartment("Абонемент", true);
     librarian1 = new Librarian("John Doe", department);
     librarian2 = new Librarian("Alex Pupkin", department);
 }
        public OrderMSSQLRepository(ReaderRepository readerRepository, BookRepository bookRepository, 
            LibraryDepartmentRepository libraryDepartmentRepository, LibrarianRepository librarianRepository,
            LibraryDataContext context)
        {
            this.readerRepository = readerRepository;
            this.bookRepository = bookRepository;
            this.libraryDepartmentRepository = libraryDepartmentRepository;
            this.librarianRepository = librarianRepository;

            this.context = context;
        }
        public OrderTextRepository(ReaderRepository readerRepository, BookRepository bookRepository, 
            LibraryDepartmentRepository libraryDepartmentRepository, LibrarianRepository librarianRepository)
        {
            this.readerRepository = readerRepository;
            this.bookRepository = bookRepository;
            this.libraryDepartmentRepository = libraryDepartmentRepository;
            this.librarianRepository = librarianRepository;

            if (!Directory.GetParent(FileName).Exists) Directory.GetParent(FileName).Create();
            if (!File.Exists(FileName)) File.Create(FileName).Close();
        }
Example #12
0
        public OrderRepositoryTest()
        {
            repositoryFactory           = new T();
            readerRepository            = repositoryFactory.CreateReaderRepository();
            libraryDepartmentRepository = repositoryFactory.CreateLibraryDepartmentRepository();
            bookRepository      = repositoryFactory.CreateBookRepository(libraryDepartmentRepository);
            librarianRepository = repositoryFactory.CreateLibrarianRepository(libraryDepartmentRepository);

            orderRepository = repositoryFactory.CreateOrderRepository(readerRepository, bookRepository, libraryDepartmentRepository, librarianRepository);

            countItems = orderRepository.GetItems().Count();
        }
Example #13
0
        public void changeButton_Click(object sender, EventArgs e)
        {
            if (!(dataGridView1.SelectedRows.Count > 0))
            {
                return;
            }
            var addLibrarianForm    = new AddLibrarianForm();
            var librarianRepository = new LibrarianRepository();

            int  index     = dataGridView1.SelectedRows[0].Index;
            int  id        = 0;
            bool converted = Int32.TryParse(dataGridView1[0, index].Value.ToString(), out id);

            if (converted == false)
            {
                return;
            }

            Librarian librarian = librarianRepository.FindById(id);

            addLibrarianForm.nameTextBox.Text       = librarian.Name;
            addLibrarianForm.surnameTextBox.Text    = librarian.Surname;
            addLibrarianForm.patronymicTextBox.Text = librarian.Patronymic;
            addLibrarianForm.dateTimePicker.Value   = librarian.DateOfBirth;
            addLibrarianForm.telNumberTextBox.Text  = librarian.TelephoneNumber;

            DialogResult dialogResult = addLibrarianForm.ShowDialog(this);

            if (dialogResult == DialogResult.Cancel)
            {
                return;
            }

            string   name       = addLibrarianForm.nameTextBox.Text;
            string   surname    = addLibrarianForm.surnameTextBox.Text;
            string   patronymic = addLibrarianForm.patronymicTextBox.Text;
            DateTime DoB        = addLibrarianForm.dateTimePicker.Value;
            string   telNumber  = addLibrarianForm.telNumberTextBox.Text;


            librarian.Name            = name;
            librarian.Surname         = surname;
            librarian.Patronymic      = patronymic;
            librarian.DateOfBirth     = DoB;
            librarian.TelephoneNumber = telNumber;


            librarianRepository.Update(librarian);

            _db.SaveChanges();
            SetDataGridView();
        }
Example #14
0
 public Home()
 {
     InitializeComponent();
     _bookRepository        = new BookRepository();
     _librarianRepository   = new LibrarianRepository();
     _authorRepository      = new AuthorRepository();
     _cardholderRepository  = new CardholderRepository();
     _checkoutLogRepository = new CheckoutLogRepository();
     _librarianHelper       = new LibrarianHelper();
     _bookHelper            = new BookHelper();
     _viewHelper            = new ViewHelper();
     SetUp();
 }
Example #15
0
        public void SetDataGridView()
        {
            var librarianRepository = new LibrarianRepository();
            var readers             = from reader in librarianRepository.Get()
                                      select new
            {
                reader.Id,
                reader.Name,
                reader.Surname,
                reader.Patronymic,
                reader.DateOfBirth,
                reader.TelephoneNumber
            };

            this.dataGridView1.DataSource = readers.ToList();
        }
Example #16
0
        static void Main()
        {
            var                     connectionString       = "Data Source = LUNA\\SQLEXPRESS; Initial Catalog = Library; Integrated Security = True";
            IBookRepository         bookRepository         = new BookRepository(new BookContext(connectionString));
            ILibrarianRepository    librarianRepository    = new LibrarianRepository(new LibrarianContext(connectionString));
            ISubscriberRepository   subscriberRepository   = new SubscriberRepository(new SubscriberContext(connectionString));
            IBorrowedBookRepository borrowedBookRepository = new BorrowedBookRepository(new BorrowedBookContext(connectionString));
            IReservedBookRepository reservedBookRepository = new ReservedBookRepository(new ReservedBookContext(connectionString));
            IReturnedBookRepository returnedBookRepository = new ReturnedBookRepository(new ReturnedBookContext(connectionString));
            IService                service = new Service.Service(bookRepository, librarianRepository, subscriberRepository, borrowedBookRepository, reservedBookRepository, returnedBookRepository);


            Application.SetHighDpiMode(HighDpiMode.SystemAware);
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new LogInForm(service));
        }
Example #17
0
        static LibraryUnit()
        {
            _context = new ApplicationDbContext("Library");

            AuthorRepository     = new AuthorRepository(_context);
            BookRepository       = new BookRepository(_context);
            CategoryRepository   = new CategoryRepository(_context);
            PressRepository      = new PressRepository(_context);
            ThemeRepository      = new ThemeRepository(_context);
            DepartmentRepository = new DepartmentRepository(_context);
            TeacherRepository    = new TeacherRepository(_context);
            FacultyRepository    = new FacultyRepository(_context);
            GroupRepository      = new GroupRepository(_context);
            StudentRepository    = new StudentRepository(_context);
            SCardRepository      = new SCardRepository(_context);
            TCardRepository      = new TCardRepository(_context);
            LibrarianRepository  = new LibrarianRepository(_context);
        }
        public OrderXMLRepository(ReaderRepository readerRepository, BookRepository BookRepository, 
            LibraryDepartmentRepository libraryDepartmentRepository, LibrarianRepository librarianRepository)
        {
            this.readerRepository = readerRepository;
            this.bookRepository = BookRepository;
            this.libraryDepartmentRepository = libraryDepartmentRepository;
            this.librarianRepository = librarianRepository;

            if (!Directory.GetParent(FileName).Exists) Directory.GetParent(FileName).Create();
            if (File.Exists(FileName))
            {
                document = XDocument.Load(FileName);
            }
            else
            {
                document = new XDocument(
                    new XDeclaration("1.0", "utf-8", "yes"),
                    new XElement("Orders", null));
                document.Save(FileName);
            }
        }
Example #19
0
        public OrderRepositoryTest()
        {
            repositoryFactory           = new T();
            readerRepository            = repositoryFactory.CreateReaderRepository();
            libraryDepartmentRepository = repositoryFactory.CreateLibraryDepartmentRepository();
            bookRepository      = repositoryFactory.CreateBookRepository(libraryDepartmentRepository);
            librarianRepository = repositoryFactory.CreateLibrarianRepository(libraryDepartmentRepository);

            orderRepository = repositoryFactory.CreateOrderRepository(readerRepository, bookRepository, libraryDepartmentRepository, librarianRepository);

            countItems = orderRepository.GetItems().Count();

            department = new LibraryDepartment("Абонемент", true);
            reader     = new Reader("Reader Name", "Reader Address");
            book       = new Book("Author", "Title", 2000, department);
            librarian  = new Librarian("Name", department);

            order1 = new Order(reader, book);
            order2 = new Order(reader, book)
            {
                TimeGetBook = DateTime.Now, LibrarianOpenOrder = librarian
            };
        }
Example #20
0
        public void deleteButton_Click(object sender, EventArgs e)
        {
            if (dataGridView1.SelectedRows.Count > 0)
            {
                int  index     = dataGridView1.SelectedRows[0].Index;
                int  id        = 0;
                bool converted = Int32.TryParse(dataGridView1[0, index].Value.ToString(), out id);
                if (converted == false)
                {
                    return;
                }

                var librarianRepository      = new LibrarianRepository();
                var dealRepository           = new DealRepository();
                var bookCopyInDealRepository = new BookCopyInDealRepository();

                List <Deal>           deals           = dealRepository.GetDealsByReaderId(id);
                List <BookCopyInDeal> bookCopyInDeals = bookCopyInDealRepository.GetBookCopiesInDealByReaderId(id);

                for (int i = 0; i < bookCopyInDeals.Count; i++)
                {
                    bookCopyInDealRepository.Remove(bookCopyInDeals[i].Id);
                }

                for (int i = 0; i < deals.Count; i++)
                {
                    dealRepository.Remove(deals[i].Id);
                }

                librarianRepository.Remove(id);
                _db.SaveChanges();
                SetDataGridView();

                MessageBox.Show("Объект удален");
            }
        }
Example #21
0
 /// <summary>
 /// Initializes a new instance of the <see cref="LibrarianService"/> class.
 /// </summary>
 /// <param name="extensionRepository">The extension repository.</param>
 public LibrarianService(LibrarianRepository extensionRepository) :
     base(extensionRepository)
 {
 }
Example #22
0
        static void Main(string[] args)
        {
            var serviceProvider = new ServiceCollection()
                                  .AddSingleton <ILibrarianHelper, LibrarianHelper>()
                                  .AddSingleton <IBookHelper, BookHelper>()
                                  .AddTransient <IGenericSqlRepository <Librarian>, LibrarianRepository>()
                                  .AddTransient <IGenericSqlRepository <CheckOutLog>, CheckoutLogRepository>()
                                  .BuildServiceProvider();

            Database.SetInitializer <LibraryContext>(new LibraryInitializer());



            LibrarianRepository librarianRepository = new LibrarianRepository();
            var t = librarianRepository.GetAll();

            #region Check UserName and Password is true
            var librarianHelper = serviceProvider.GetService <ILibrarianHelper>();
            var isUserLogin     = librarianHelper.IsUserLogin("hoyoung", "holim1");
            #endregion

            #region Search Book
            // initialize BookHelper
            var bookHelper = serviceProvider.GetService <IBookHelper>();

            // find books search
            var z = bookHelper.FindBooksSearch("Andrew;Programming");
            var d = bookHelper.FindBooksSearch("Science Fiction");

            #endregion

            #region Check out book
            BookRepository bookRepository = new BookRepository();

            var book            = bookRepository.Find(5);
            var canUserCheckout = librarianHelper.CanCheckOut(book, 16);

            CheckOutLog checkOutLog = new CheckOutLog
            {
                BookID       = 5,
                CardholderID = 10,
                CheckOutDate = DateTime.Now
            };
            CheckoutLogRepository checkoutlogRepository = new CheckoutLogRepository();

            if (canUserCheckout)
            {
                var checkedOut = checkoutlogRepository.Add(checkOutLog);
            }


            var found = checkoutlogRepository.GetAll().Where(x => x.BookID == checkOutLog.BookID &&
                                                             x.CardholderID == checkOutLog.CardholderID)
                        .Select(x => x).ToList();



            #endregion

            #region Update Check Out Log

            checkOutLog.BookID = 7;
            var checkOut = checkoutlogRepository.Update(checkOutLog);


            #endregion

            #region Delete Checkoutlog

            var foundCol = checkoutlogRepository.Find(8);
            checkoutlogRepository.Delete(8);
            foundCol = checkoutlogRepository.Find(8);


            #endregion
        }
 public OrderRepository CreateOrderRepository(ReaderRepository readerRepository, BookRepository bookRepository, 
     LibraryDepartmentRepository libraryDepartmentRepository, LibrarianRepository librarianRepository)
 {
     return new OrderTextRepository(readerRepository, bookRepository, libraryDepartmentRepository, librarianRepository);
 }