public AddCategoryController(ICategoryCreate view, ReadOnlyContext context)
 {
     _settingsRepository = context.GetRepository<CategorySettings>();
     _view = view;
     _view.CreateCategory += CreateCategory;
     _view.Show();
 }
        public DetailBookController(Views.Book.BookDetailsView view, ReadOnlyContext context, int bookID, int userID)
        {
            this.userID = userID;
            this.bookID = bookID;
            _context = context;
            _detailBookView = view;

            _booksRepository = context.GetRepository<DataInterface.Entities.Copy>();
            _leasesRepository = context.GetRepository<DataInterface.Entities.Lease>();
            _usersRepository = context.GetRepository<DataInterface.Entities.User>();
            _reservationsRepository = context.GetRepository<DataInterface.Entities.Reservation>();
            selectedBook = _booksRepository.GetById(bookID);

            var userBorrowedBooks = _leasesRepository.GetByQuery(x => x.Copy.Book.Id == bookID);
            var userBookingBooks = _reservationsRepository.GetByQuery(x => x.ReservedCopy.Book.Id == bookID);
            Views.Book.BookDetailsView example = new Views.Book.BookDetailsView(selectedBook, userBorrowedBooks, userBookingBooks);

            if (_context.CurrentUser.Role == DataInterface.Enums.Role.Reader)
            {
                Return.Visible = false;
                Title.Enabled = false;
                Author.Enabled = false;
                ISBN.Enabled = false;
                PublishingYear.Enabled = false;
                Publisher.Enabled = false;
                Format.Enabled = false;
            }

            _detailBookView = example;

            Return.Click += ReturnBook_Click;
            Borrow.Click += Borrow_Click;

            _detailBookView.Show();
        }
Ejemplo n.º 3
0
 public void ToStream(ZetboxStreamWriter sw, HashSet <IStreamable> auxObjects, bool eagerLoadLists)
 {
     sw.Write(ReadOnlyContext.GetInterfaceType(this).ToSerializableType());
     sw.Write(ID);
     sw.Write(StringProperty);
     sw.Write(IntProperty);
     sw.Write(BoolProperty);
 }
 public DeleteUserController(IDeleteUser view, ReadOnlyContext context)
 {
     _usersRepository = context.GetRepository<DataInterface.Entities.User>();
     _view = view;
     _view.DeleteUser += DeleteUser;
     _view.fillListView(RepoDataToList());
     _view.Show();
 }
 public BrowseCategoryController(IBrowseCategory view, ReadOnlyContext context)
 {
     _settingsRepository = context.GetRepository<CategorySettings>();
     _view = view;
     _view.EditCategory += EditCategory;
     _view.fillComboBox(RepoDataToList());
     _view.Show();
 }
        public ReportController(IReportView view, ReadOnlyContext context)
        {
            _leaseRepository = context.GetRepository<Lease>();
            _view = view;
            _view.GenerateReport += GenerateReport;

            _view.Show();
        }
 public MainView(ReadOnlyContext context, UserManager userManager)
 {
     _context = context;
     _userManager = userManager;
     InitializeUserSignIn();
     BindEvents();
     InitializeComponent();
 }
        public ScheduleController(ICreateUserSchedule view, DataInterface.Entities.User user, ReadOnlyContext context)
        {
            _view = view;
            _user = user;
            _timetableRepository = context.GetRepository<Timetable>();
            _view.CreateSchedule += CreateSchedule;

            _view.Show();
        }
 public SignIn(ReadOnlyContext context, UserManager userManager)
 {
     _context = context;
     _userManager = userManager;
     InitializeComponent();
     userManager.UserSignedIn += SetControlState;
     userManager.UserSignedOut += SetControlState;
     userManager.UserSignedIn += SetupSignedInUserDisplay;
 }
 public ListingFoundBooksController(IListingFoundBooksView view, ReadOnlyContext context,
             IEnumerable<DataInterface.Entities.Book> foundBooks)
 {
     _view = view;
     _foundBooks = foundBooks;
     _foundBooks.ToList().ForEach(book => _booksCache.Add(MapBookToViewModel(book)));
     _view.UpdateBookDataGrid(_booksCache);
     _view.ChooseBook += ChooseBook;
     _view.Show();
 }
Ejemplo n.º 11
0
        /// <summary>
        /// Base method for serializing this Object.
        /// </summary>
        /// <param name="sw">Stream to serialize to</param>
        /// <param name="auxObjects">pass a List here to collect auxiliary, eagerly loaded objects. Ignored if null.</param>
        /// <param name="eagerLoadLists">True if Lists should be eager loaded.</param>
        public virtual void ToStream(ZetboxStreamWriter sw, HashSet <IStreamable> auxObjects, bool eagerLoadLists)
        {
            if (sw == null)
            {
                throw new ArgumentNullException("sw");
            }

            sw.Write(ReadOnlyContext.GetInterfaceType(this.GetImplementedInterface()).ToSerializableType());
            sw.Write(this.ID);
        }
 public CopyController(ICreateCopy view, Library_Enterprise_University_Project.DataInterface.Entities.Book book,
     ReadOnlyContext context, bool withNewBook)
 {
     _view = view;
     _book = book;
     _copyRepository = context.GetRepository<Copy>();
     _withNewBook = withNewBook;
     _view.CreateCopies += CreateCopies;
     _view.InitControls(TagsToString(), _book.CategorySetting.Category, _book.Title, ConvertAuthorsToString());
     _view.Show();
 }
 public UserController(ICreateUser view, ReadOnlyContext context)
 {
     _context = context;
     _view = view;
     _view.AddUser += AddUser;
     _usersRepository = context.GetRepository<DataInterface.Entities.User>();
     _cityRepository = context.GetRepository<DataInterface.Entities.City>();
     _view.SetComboBoxItemList(ConvertToObject());
     _view.AddRoleComboBoxItems(_context.CurrentUser.Role == DataInterface.Enums.Role.Admin ? 1 : 0);
     _view.Show();
 }
 public ManageUserScheduleController(IMenageSchedule view, ReadOnlyContext context)
 {
     _usersRepository = context.GetRepository<DataInterface.Entities.User>();
     _timetableOverrideRepository = context.GetRepository<TimetableOverride>();
     _timetableRepository = context.GetRepository<Timetable>();
     _view = view;
     _view.MenageSchedule += MenageSchedule;
     _view.fillListView(RepoDataToList());
     _view.moveRepoDataToView(_timetableRepository.GetAll(), _timetableOverrideRepository.GetAll(),
         _usersRepository.GetAll());
     _view.Show();
 }
        public LibrarianPanelController(ILibrarianPanelView view, ReadOnlyContext context)
        {
            _view = view;
            _context = context;

            _view.ManageBooks += ManageBooks;
            _view.ManageUsers += ManageUsers;
            _view.CreateBook += CreateBook;
            _view.CreateUser += CreateUser;

            _view.Show();
        }
        public AdminPanelController(IAdminPanelView view, ReadOnlyContext context)
        {
            this._context = context;
            this._view = view;
            this._view.GenerateReport += GenerateReport;
            this._view.BrowseCategories += BrowseCategories;
            this._view.AddLibrarian += AddLibrarian;
            this._view.DeleteLibrarian += DeleteLibrarian;
            this._view.MenageSchedules += MenageSchedules;
            this._view.CreateCategory += CreateCategory;

            _view.Show();
        }
        public SearchUserController(SearchUserView searchUserView, ReadOnlyContext context)
        {
            _context = context;
            _usersRepository = _context.GetRepository<DataInterface.Entities.User>();
            _searchUserView = searchUserView;
            _usersRepository.GetAll().ToList().ForEach(user => _usersCache.Add(MapUserToViewModel(user)));

            SetDefaultFilters();
            BindEvents();
            UpdateSearchResults(this, new EventArgs());
            _searchUserView.FormClosing += new FormClosingEventHandler(Form1_FormClosing);
            closeByXButton = true;
            _searchUserView.ShowDialog();
        }
 public BookController(ICreateBook view, ReadOnlyContext context)
 {
     _context = context;
     _bookRepository = context.GetRepository<DataInterface.Entities.Book>();
     _copyRepository = context.GetRepository<Copy>();
     _tagsRepository = context.GetRepository<Tag>();
     _settingsRepository = context.GetRepository<CategorySettings>();
     _view = view;
     _view.AddBook += AddBook;
     _view.AddCopies += AddCopies;
     _view.UpdateTagsAutocompleteFieldValues(TagsToStringArray());
     _view.UpdateBorrowCategoriesComboBox(CategoriesToStringArray());
     _view.Show();
 }
        public DetailUserController(Views.User.UserDetailView view, ReadOnlyContext context, int userID)
        {
            _detailUserView = view;
            _view = (IDetailView)view;
            _usersRepository = context.GetRepository<DataInterface.Entities.User>();
            _leasesRepository = context.GetRepository<DataInterface.Entities.Lease>();
            _reservationsRepository = context.GetRepository<DataInterface.Entities.Reservation>();
            _bookCopiesRepository = context.GetRepository<DataInterface.Entities.Copy>();
            selectedUser = _usersRepository.GetById(userID);

            var userBorrowedBooks = _leasesRepository.GetByQuery(x => x.User.Id == userID);
            var userReservedBooks = _reservationsRepository.GetByQuery(x => x.ReservedBy.Id == userID);

            Views.User.UserDetailView example = new Views.User.UserDetailView(selectedUser, userBorrowedBooks, userReservedBooks);
            _detailUserView = example;
            _view = example;
            if (context.CurrentUser.Role == DataInterface.Enums.Role.Reader)
            {
                Name.Enabled = false;
                Surname.Enabled = false;
                PESEL.Enabled = false;
                Mail.Enabled = false;
                Phone.Enabled = false;
                Role.Enabled = false;
                Address.Enabled = false;
                Postal.Enabled = false;
                City.Enabled = false;
                State.Enabled = false;
                Country.Enabled = false;
                Active.Enabled = false;
                Update.Enabled = false;
                Return.Enabled = false;
            }

            if (context.CurrentUser.Role == DataInterface.Enums.Role.Librarian)
            {
                Role.Enabled = false;
            }

            isRegistered = Active.Checked;
            Update.Click += Update_Click;
            Return.Click += ReturnBook_Click;
            CancelReservation.Click += CancelReservation_Click;
            ExtendLease.Click += ExtendLease_Click;
            _detailUserView.Show();
        }
Ejemplo n.º 20
0
        private void AddDBReadonly(string connStringName = "readonlyConnection")
        {
            if (_dbFactory == null)
            {
                throw new InvalidOperationException("You must first initialize the database.");
            }
            var db         = _dbFactory.Get();
            var connection = db.Database.GetDbConnection();

            using (var command = connection.CreateCommand())
            {
                command.CommandText = "sp_executesql";
                command.CommandType = CommandType.StoredProcedure;
                var param = command.CreateParameter();
                param.ParameterName = "@statement";
                param.Value         = @"
CREATE LOGIN readonlyLogin WITH PASSWORD='******'
CREATE USER readonlyUser FROM LOGIN readonlyLogin
EXEC sp_addrolemember 'db_datareader', 'readonlyUser';
                    ";
                command.Parameters.Add(param);
                connection.Open();
                try
                {
                    command.ExecuteNonQuery();
                }
                catch (SqlException ex)
                {
                    // user already exists
                    if (ex.Errors[0].Number.Equals(15025))
                    {
                    }
                    else
                    {
                        throw ex;
                    }
                }
            }

            _dbReadOnly = new ReadOnlyContext(connStringName);
        }
        public DetailBookController(Views.Book.BookDetailsView view, ReadOnlyContext context, int bookID)
        {
            // _view = view;
            _detailBookView = view;
            this.bookID = bookID;
            this.userID = -1;
            _context = context;
            _booksRepository = context.GetRepository<DataInterface.Entities.Copy>();
            _leasesRepository = context.GetRepository<DataInterface.Entities.Lease>();
            _usersRepository = context.GetRepository<DataInterface.Entities.User>();
            _reservationsRepository = context.GetRepository<DataInterface.Entities.Reservation>();
            selectedBook = _booksRepository.GetById(bookID);

            var userBorrowedBooks = _leasesRepository.GetByQuery(x => x.Copy.Book.Id == bookID);
            var userBookingBooks = _reservationsRepository.GetByQuery(x => x.ReservedCopy.Book.Id == bookID);
            Views.Book.BookDetailsView example = new Views.Book.BookDetailsView(selectedBook, userBorrowedBooks, userBookingBooks);
            _detailBookView = example;
            Return.Enabled = false;
            Return.Click += ReturnBook_Click;
            Borrow.Click += Borrow_Click;

            _detailBookView.Show();
        }
        public SearchBookController(SearchBookView searchBookView, ReadOnlyContext context)
        {
            _context = context;
            _booksRepository = _context.GetRepository<DataInterface.Entities.Book>();
            _bookCopiesRepository = _context.GetRepository<Copy>();
            _leasesRepository = _context.GetRepository<Lease>();
            _settingsRepository = _context.GetRepository<CategorySettings>();
            _usersRepository = _context.GetRepository<DataInterface.Entities.User>();
            _reservationsRepository = _context.GetRepository<Reservation>();

            _searchBookView = searchBookView;

            _booksRepository.GetAll().ToList().ForEach(book => _booksCache.Add(MapBookToViewModel(book)));
            _bookCopiesRepository.GetAll().ToList().ForEach(bookCopy => _bookCopiesCache.Add(MapBookCopyToViewModel(bookCopy)));

            SetButtonsBasedOnContext();
            SetDefaultFilters();
            BindEvents();
            UpdateBooksSearchResults(this, new EventArgs());
            UpdateBookCopiesSearchResults(this, new EventArgs());

            _searchBookView.Show();
        }
 /// <summary>
 /// This method is called for each element in the (non-broadcast) <see cref="DataStream{TElement}"/>.
 /// </summary>
 /// <param name="value">The stream element.</param>
 /// <param name="context">A context that allows querying the timestamp of the element, querying the current processing/event time and updating the broadcast state.
 /// The context is only valid during the invocation of this method, do not store it.</param>
 /// <param name="output">The collector to emit resulting elements to</param>
 /// <exception cref="Exception">The function may throw exceptions which cause the streaming program to fail and go into recovery.</exception>
 public abstract void ProcessElement(TInput1 value, ReadOnlyContext context, ICollector <TOutput> output);
Ejemplo n.º 24
0
		public void SetReadOnlyContext (ReadOnlyContext context)
		{
			flags |= Flags.ReadOnly;
			ro_context = context;
		}
 public ReaderPanelController(IReaderPanel panelView, ReadOnlyContext context)
 {
     _panelView = panelView;
     _context = context;
     BindEvents();
 }