Пример #1
0
        public ActionResult EditRole(int id)
        {
            LibraryManagementSystemContext context = new LibraryManagementSystemContext();
            RolesRepository rolesRepository        = new RolesRepository(context);
            AuthenticatingActionsRepository authenticatingActionsRepository = new AuthenticatingActionsRepository(context);

            RolesEditRoleVM model = new RolesEditRoleVM();

            if (id > 0)
            {
                Role role = rolesRepository.GetAll(filter: r => r.ID == id, includeProperties: "AuthenticatingActions").FirstOrDefault();
                PopulateAssignedAuthenticatingActions(role, authenticatingActionsRepository);

                model.ID   = role.ID;
                model.Name = role.Name;
            }
            else
            {
                Role role = new Role();
                role.AuthenticatingActions = new List <AuthenticatingAction>();
                PopulateAssignedAuthenticatingActions(role, authenticatingActionsRepository);
            }

            return(View(model));
        }
Пример #2
0
        public ActionResult EditCustomer(int id)
        {
            LibraryManagementSystemContext context             = new LibraryManagementSystemContext();
            CustomersRepository            customersRepository = new CustomersRepository(context);
            CustomersEditCustomerVM        model = new CustomersEditCustomerVM();

            Customer customer = customersRepository.GetByID(id);

            if (id > 0)
            {
                model.ID             = customer.ID;
                model.PersonalNumber = customer.PersonalNumber;
                model.FirstName      = customer.FirstName;
                model.LastName       = customer.LastName;
                model.Email          = customer.Email;
                model.Address        = customer.Address;
                model.PicturePath    = customer.PicturePath;
                model.Birthday       = customer.Birthday;
                model.DateIn         = customer.DateIn;
                if (customer.DateOut != null)
                {
                    model.DateOut = customer.DateOut.Value;
                }
            }
            else
            {
                customer      = new Customer();
                model.DateOut = null;
            }

            return(View(model));
        }
Пример #3
0
        public ActionResult EditPublisher(PublishersEditPublisherVM model)
        {
            LibraryManagementSystemContext context = new LibraryManagementSystemContext();
            PublishersRepository           publishersRepository = new PublishersRepository(context);

            Publisher publisher = null;

            if (!ModelState.IsValid)
            {
                return(View(model));
            }
            else
            {
                if (model.ID > 0)
                {
                    publisher = publishersRepository.GetByID(model.ID);
                }
                else
                {
                    publisher = new Publisher();
                }

                publisher.ID      = model.ID;
                publisher.Name    = model.Name;
                publisher.Address = model.Address;

                publishersRepository.Save(publisher);
            }

            return(RedirectToAction("Index", "Publishers"));
        }
Пример #4
0
        public ActionResult ReturnBook(string bookInfo, BooksReturnBookVM model)
        {
            LibraryManagementSystemContext context = new LibraryManagementSystemContext();
            BooksRepository booksRepository        = new BooksRepository(context);

            // makes an book info array in format {Barcode No.}{Empty}{Empty}{Book title}
            string[] bookInfoSplitted = bookInfo.Split(' ', '-');

            if (string.IsNullOrEmpty(bookInfo) || bookInfoSplitted[0] == "")
            {
                ModelState.AddModelError("BookBarcodeNumber", "* barcode required");
            }
            if (!ModelState.IsValid)
            {
                model.DateReturned = DateTime.Now;
                model.Books        = booksRepository.GetAll();

                return(View(model));
            }

            model.BookBarcodeNumber = int.Parse(bookInfoSplitted[0]);
            Book book = booksRepository
                        .GetAll(filter: b => b.Barcodes.FirstOrDefault().BarcodeNumber == model.BookBarcodeNumber)
                        .FirstOrDefault();

            book.StockCount++;
            booksRepository.Save(book);

            return(RedirectToAction("Index", "Books"));
        }
Пример #5
0
        public ActionResult EditBook(int id)
        {
            LibraryManagementSystemContext context    = new LibraryManagementSystemContext();
            BooksRepository      booksRepository      = new BooksRepository(context);
            PublishersRepository publishersRepository = new PublishersRepository(context);
            BooksEditBookVM      model = new BooksEditBookVM();

            Book book = booksRepository.GetByID(id);

            if (id > 0)
            {
                if (book == null)
                {
                    return(RedirectToAction("Index", "Books"));
                }

                model.ID            = book.ID;
                model.Title         = book.Title;
                model.PublisherID   = book.Publisher.ID;
                model.StockCount    = book.StockCount;
                model.DeliveryPrice = book.DeliveryPrice;
                model.DateReceived  = book.DateReceived;
                model.DatePublished = book.DatePublished;
            }
            else
            {
                book = new Book();
            }

            model.Publishers = model.Publishers ?? new List <SelectListItem>();
            model.Publishers = SelectListHandler.Create <Publisher>(
                publishersRepository.GetAll(), p => p.Name, p => p.ID.ToString(), model.PublisherID.ToString());

            return(View(model));
        }
Пример #6
0
        public ActionResult EditAuthor(AuthorsEditAuthorVM model)
        {
            LibraryManagementSystemContext context = new LibraryManagementSystemContext();
            AuthorsRepository authorsRepository    = new AuthorsRepository(context);

            Author author = null;

            if (!ModelState.IsValid)
            {
                return(View(model));
            }
            else
            {
                if (model.ID > 0)
                {
                    author = authorsRepository.GetByID(model.ID);
                }
                else
                {
                    author = new Author();
                }

                author.ID        = model.ID;
                author.FirstName = model.FirstName;
                author.LastName  = model.LastName;

                authorsRepository.Save(author);
            }

            return(RedirectToAction("Index", "Authors"));
        }
Пример #7
0
        public override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            LibraryManagementSystemContext context = new LibraryManagementSystemContext();
            RolesRepository rolesRepository        = new RolesRepository(context);

            if (AuthenticationManager.LoggedUser == null)
            {
                filterContext.HttpContext.Response.Redirect("~/?RedirectUrl=" + filterContext.HttpContext.Request.Url);
                filterContext.Result = new EmptyResult();
                return;
            }
            else
            {
                foreach (var role in AuthenticationManager.LoggedUser.Roles)
                {
                    if (!rolesRepository.Exists(role.ID, filterContext.RouteData.Values["Controller"].ToString(), filterContext.RouteData.Values["Action"].ToString()))
                    {
                        filterContext.HttpContext.Response.Redirect("~/");
                    }
                    else
                    {
                        base.OnActionExecuting(filterContext);
                    }
                }
            }
        }
Пример #8
0
        public ActionResult Details(int id, string sortOrder)
        {
            LibraryManagementSystemContext context = new LibraryManagementSystemContext();
            PublishersRepository           publishersRepository = new PublishersRepository(context);
            BooksRepository     booksRepository = new BooksRepository(context);
            PublishersDetailsVM model           = new PublishersDetailsVM();

            this.TryUpdateModel(model);

            var publisher = publishersRepository.GetByID(id);

            if (publisher != null)
            {
                model.ID                           = publisher.ID;
                model.PublisherName                = publisher.Name;
                model.Address                      = publisher.Address;
                model.BooksPager                   = model.BooksPager ?? new GenericPagerVM();
                model.BooksPager.CurrentPage       = model.BooksPager.CurrentPage == 0 ? 1 : model.BooksPager.CurrentPage;
                model.BooksPager.Action            = "Details";
                model.BooksPager.Controller        = "Publishers";
                model.BooksPager.Prefix            = "BooksPager";
                model.BooksPager.CurrentParameters = new Dictionary <string, object>()
                {
                    { "BookTitle", model.BookTitle },
                    { "BooksPager.CurrentPage", model.BooksPager.CurrentPage }
                };

                #region Sorting and Filtering

                Expression <Func <Book, bool> > filter = b =>
                                                         (string.IsNullOrEmpty(model.BookTitle) || b.Title.Contains(model.BookTitle));
                model.BooksPager.PagesCount = GetPagesCount(filter);

                ViewBag.BookSortParam = string.IsNullOrEmpty(sortOrder) ? "book_desc" : "";
                switch (sortOrder)
                {
                case "book_desc":
                    model.Books = booksRepository
                                  .GetAll(model.BooksPager.CurrentPage, ApplicationConfiguration.ItemsPerPage, filter, x => x.OrderByDescending(b => b.Title))
                                  .Where(b => b.PublisherID == id)
                                  .ToList();
                    break;

                default:
                    model.Books = booksRepository
                                  .GetAll(model.BooksPager.CurrentPage, ApplicationConfiguration.ItemsPerPage, filter, x => x.OrderBy(b => b.Title))
                                  .Where(b => b.PublisherID == id)
                                  .ToList();
                    break;
                }
                #endregion

                return(View(model));
            }
            else
            {
                return(RedirectToAction("Index", "Publishers"));
            }
        }
Пример #9
0
        public bool AuthenticateUser(string email, string password)
        {
            LibraryManagementSystemContext context = new LibraryManagementSystemContext();
            UsersRepository usersRepository        = new UsersRepository(context);

            LoggedUser = usersRepository.GetAll(filter: u => u.Email == email && u.Password == password).FirstOrDefault();
            return(LoggedUser != null);
        }
Пример #10
0
        public ActionResult Index(string sortOrder)
        {
            LibraryManagementSystemContext context = new LibraryManagementSystemContext();
            PublishersRepository           publishersRepository = new PublishersRepository(context);
            PublishersIndexVM model = new PublishersIndexVM();

            this.TryUpdateModel(model);

            model.PublishersPager                   = model.PublishersPager ?? new GenericPagerVM();
            model.PublishersPager.CurrentPage       = model.PublishersPager.CurrentPage == 0 ? 1 : model.PublishersPager.CurrentPage;
            model.PublishersPager.Action            = "Index";
            model.PublishersPager.Controller        = "Publishers";
            model.PublishersPager.Prefix            = "PublishersPager";
            model.PublishersPager.CurrentParameters = new Dictionary <string, object>()
            {
                { "PublisherName", model.PublisherName },
                { "PublisherAddress", model.PublisherAddress },
                { "PublishersPager.CurrentPage", model.PublishersPager.CurrentPage }
            };

            #region Sorting and Filtering
            Expression <Func <Publisher, bool> > filter = p =>
                                                          (string.IsNullOrEmpty(model.PublisherName) || p.Name.Contains(model.PublisherName)) &&
                                                          (string.IsNullOrEmpty(model.PublisherAddress) || p.Address.Contains(model.PublisherAddress));
            model.PublishersPager.PagesCount = GetPagesCount(filter);

            ViewBag.PublisherSortParam = string.IsNullOrEmpty(sortOrder) ? "publisher_desc" : "";
            ViewBag.AddressSortParam   = sortOrder == "Address" ? "address_desc" : "Address";
            switch (sortOrder)
            {
            case "publisher_desc":
                model.PublishersList = publishersRepository
                                       .GetAll(model.PublishersPager.CurrentPage, ApplicationConfiguration.ItemsPerPage, filter, x => x.OrderByDescending(p => p.Name))
                                       .ToList();
                break;

            case "Address":
                model.PublishersList = publishersRepository
                                       .GetAll(model.PublishersPager.CurrentPage, ApplicationConfiguration.ItemsPerPage, filter, x => x.OrderBy(p => p.Address))
                                       .ToList();
                break;

            case "address_desc":
                model.PublishersList = publishersRepository
                                       .GetAll(model.PublishersPager.CurrentPage, ApplicationConfiguration.ItemsPerPage, filter, x => x.OrderByDescending(p => p.Address))
                                       .ToList();
                break;

            default:
                model.PublishersList = publishersRepository
                                       .GetAll(model.PublishersPager.CurrentPage, ApplicationConfiguration.ItemsPerPage, filter, x => x.OrderBy(p => p.Name))
                                       .ToList();
                break;
            }
            #endregion

            return(View(model));
        }
Пример #11
0
        public ActionResult ReturnBook()
        {
            LibraryManagementSystemContext context = new LibraryManagementSystemContext();
            BooksRepository   booksRepository      = new BooksRepository(context);
            BooksReturnBookVM model = new BooksReturnBookVM();

            model.DateReturned = DateTime.Now.Date;
            model.Books        = booksRepository.GetAll();

            return(View(model));
        }
Пример #12
0
        public ActionResult DeleteBarcode(int id)
        {
            LibraryManagementSystemContext context            = new LibraryManagementSystemContext();
            BarcodesRepository             barcodesRepository = new BarcodesRepository(context);
            BarcodesDeleteBarcodeVM        model = new BarcodesDeleteBarcodeVM();

            Barcode barcode = barcodesRepository.GetByID(id);

            model.ID            = barcode.ID;
            model.BarcodeNumber = barcode.BarcodeNumber;

            return(View(model));
        }
Пример #13
0
        public ActionResult DeleteBook(int id)
        {
            LibraryManagementSystemContext context = new LibraryManagementSystemContext();
            BooksRepository   booksRepository      = new BooksRepository(context);
            BooksDeleteBookVM model = new BooksDeleteBookVM();

            Book book = booksRepository.GetByID(id);

            model.ID    = book.ID;
            model.Title = book.Title;

            return(View(model));
        }
Пример #14
0
        public ActionResult DeleteUser(int id)
        {
            LibraryManagementSystemContext context = new LibraryManagementSystemContext();
            UsersRepository   usersRepository      = new UsersRepository(context);
            UsersDeleteUserVM model = new UsersDeleteUserVM();

            User user = usersRepository.GetByID(id);

            model.ID       = user.ID;
            model.FullName = user.ToString();

            return(View(model));
        }
Пример #15
0
        public ActionResult DeleteRole(int id)
        {
            LibraryManagementSystemContext context = new LibraryManagementSystemContext();
            RolesRepository rolesRepository        = new RolesRepository(context);

            RolesDeleteRoleVM model = new RolesDeleteRoleVM();
            Role role = rolesRepository.GetAll(filter: r => r.ID == id, includeProperties: "AuthenticatingActions").FirstOrDefault();

            model.ID   = role.ID;
            model.Name = role.Name;

            return(View(model));
        }
Пример #16
0
        public ActionResult EditRent()
        {
            LibraryManagementSystemContext context  = new LibraryManagementSystemContext();
            BooksRepository     booksRepository     = new BooksRepository(context);
            CustomersRepository customersRepository = new CustomersRepository(context);
            RentsEditRentVM     model = new RentsEditRentVM();

            model.Customers = customersRepository.GetAll();
            model.Books     = booksRepository.GetAll();
            model.RentDate  = DateTime.Now.Date;
            model.UserID    = AuthenticationManager.LoggedUser.ID;

            return(View(model));
        }
Пример #17
0
        public ActionResult Index()
        {
            LibraryManagementSystemContext context = new LibraryManagementSystemContext();
            UsersRepository usersRepo = new UsersRepository(context);
            HomeIndexVM     model     = new HomeIndexVM();

            TryUpdateModel(model);

            if (AuthenticationManager.LoggedUser != null)
            {
                model.ID = AuthenticationManager.LoggedUser.ID;
            }

            return(View(model));
        }
Пример #18
0
        public int GetPagesCount()
        {
            LibraryManagementSystemContext context = new LibraryManagementSystemContext();
            RolesRepository rolesRepository        = new RolesRepository(context);

            int pagesCount   = 0;
            int rolesCount   = rolesRepository.Count();
            int itemsPerPage = ApplicationConfiguration.ItemsPerPage;

            pagesCount = rolesCount / itemsPerPage;
            if ((rolesCount % itemsPerPage) > 0)
            {
                pagesCount++;
            }
            return(pagesCount);
        }
Пример #19
0
        public ActionResult DeleteRole(RolesDeleteRoleVM model)
        {
            LibraryManagementSystemContext context = new LibraryManagementSystemContext();
            RolesRepository rolesRepository        = new RolesRepository(context);

            Role role = rolesRepository.GetAll(filter: r => r.ID == model.ID, includeProperties: "AuthenticatingActions").FirstOrDefault();

            if (role == null)
            {
                return(HttpNotFound());
            }

            role.AuthenticatingActions = null;
            rolesRepository.Delete(role);

            return(RedirectToAction("Index", "Roles"));
        }
Пример #20
0
        public ActionResult DeleteUser(UsersDeleteUserVM model)
        {
            LibraryManagementSystemContext context = new LibraryManagementSystemContext();
            UsersRepository usersRepository        = new UsersRepository(context);

            User user = usersRepository.GetAll(filter: u => u.ID == model.ID, includeProperties: "Roles").FirstOrDefault();

            if (user == null)
            {
                return(HttpNotFound());
            }

            user.Roles = null;
            usersRepository.Delete(user);

            return(RedirectToAction("Index", "Users"));
        }
Пример #21
0
        public ActionResult AddBookAuthor(int id)
        {
            LibraryManagementSystemContext context = new LibraryManagementSystemContext();
            BooksRepository      booksRepository   = new BooksRepository(context);
            AuthorsRepository    authorsRepository = new AuthorsRepository(context);
            BooksAddBookAuthorVM model             = new BooksAddBookAuthorVM();

            Book book = booksRepository.GetByID(id);

            model.ID      = book.ID;
            model.Title   = book.Title;
            model.Authors = model.Authors ?? new List <SelectListItem>();
            model.Authors = SelectListHandler.Create <Author>(
                authorsRepository.GetAll(), a => (a.FirstName + " " + a.LastName), a => a.ID.ToString(), model.AuthorID.ToString());

            return(View(model));
        }
Пример #22
0
        public int GetPagesCount(Expression <Func <Book, bool> > filter = null)
        {
            LibraryManagementSystemContext context = new LibraryManagementSystemContext();
            BooksRepository booksRepository        = new BooksRepository(context);

            int pagesCount = 0;
            int pageSize   = ApplicationConfiguration.ItemsPerPage;
            int booksCount = 0;

            booksCount = booksRepository.Count(filter);
            pagesCount = booksCount / pageSize;
            if ((booksCount % pageSize) > 0)
            {
                pagesCount++;
            }

            return(pagesCount);
        }
Пример #23
0
        public ActionResult DeleteBook(BooksDeleteBookVM model)
        {
            LibraryManagementSystemContext context = new LibraryManagementSystemContext();
            BooksRepository booksRepository        = new BooksRepository(context);

            Book book = booksRepository.GetByID(model.ID);

            if (book == null)
            {
                return(HttpNotFound());
            }
            else
            {
                booksRepository.Delete(book);
            }

            return(RedirectToAction("Index"));
        }
Пример #24
0
        public int GetPagesCount(Expression <Func <Customer, bool> > filter = null)
        {
            LibraryManagementSystemContext context             = new LibraryManagementSystemContext();
            CustomersRepository            customersRepository = new CustomersRepository(context);

            int pagesCount     = 0;
            int pageSize       = ApplicationConfiguration.ItemsPerPage;
            int customersCount = 0;

            customersCount = customersRepository.Count(filter);
            pagesCount     = customersCount / pageSize;
            if ((customersCount % pageSize) > 0)
            {
                pagesCount++;
            }

            return(pagesCount);
        }
Пример #25
0
        public ActionResult DeleteBarcode(BarcodesDeleteBarcodeVM model)
        {
            LibraryManagementSystemContext context            = new LibraryManagementSystemContext();
            BarcodesRepository             barcodesRepository = new BarcodesRepository(context);

            Barcode barcode = barcodesRepository.GetByID(model.ID);

            if (barcode == null)
            {
                return(HttpNotFound());
            }
            else
            {
                barcodesRepository.Delete(barcode);
            }

            return(RedirectToAction("ListBookBarcodes/" + barcode.BookID, "Books"));
        }
Пример #26
0
        public int GetPagesCount(Expression <Func <Rent, bool> > filter)
        {
            LibraryManagementSystemContext context = new LibraryManagementSystemContext();
            RentsRepository rentsRepository        = new RentsRepository(context);

            int pagesCount = 0;
            int pageSize   = ApplicationConfiguration.ItemsPerPage;
            int rentsCount = 0;

            rentsCount = rentsRepository.Count(filter);
            pagesCount = rentsCount / pageSize;
            if ((rentsCount % pageSize) > 0)
            {
                pagesCount++;
            }

            return(pagesCount);
        }
Пример #27
0
        public ActionResult EditCustomer(CustomersEditCustomerVM model)
        {
            LibraryManagementSystemContext context             = new LibraryManagementSystemContext();
            CustomersRepository            customersRepository = new CustomersRepository(context);

            ModelState.Remove("DateOut");

            if (model.Email != null && customersRepository.GetAll().Any(c => c.Email == model.Email) &&
                model.ID != customersRepository.GetAll(filter: c => c.Email == model.Email).FirstOrDefault().ID)
            {
                ModelState.AddModelError("Email", "* email already exists");
            }
            if (!ModelState.IsValid)
            {
                return(View(model));
            }
            else
            {
                Customer customer = null;
                if (model.ID > 0)
                {
                    customer = customersRepository.GetByID(model.ID);
                    customer.PersonalNumber = model.PersonalNumber;
                }
                else
                {
                    customer = new Customer();
                    customer.PersonalNumber = customersRepository.GetAll().LastOrDefault().PersonalNumber + 1;
                }

                customer.ID        = model.ID;
                customer.FirstName = model.FirstName;
                customer.LastName  = model.LastName;
                customer.Email     = model.Email;
                customer.Address   = model.Address;
                customer.Birthday  = model.Birthday;
                customer.DateIn    = model.DateIn;
                customer.DateOut   = model.DateOut != null ? model.DateOut : null;

                customersRepository.Save(customer);
            }

            return(RedirectToAction("Index", "Customers"));
        }
Пример #28
0
        public ActionResult Index(string sortOrder)
        {
            LibraryManagementSystemContext context = new LibraryManagementSystemContext();
            AuthorsRepository authorsRepository    = new AuthorsRepository(context);
            AuthorsIndexVM    model = new AuthorsIndexVM();

            this.TryUpdateModel(model);

            model.AuthorsPager                   = model.AuthorsPager ?? new GenericPagerVM();
            model.AuthorsPager.CurrentPage       = model.AuthorsPager.CurrentPage == 0 ? 1 : model.AuthorsPager.CurrentPage;
            model.AuthorsPager.Action            = "Index";
            model.AuthorsPager.Controller        = "Authors";
            model.AuthorsPager.Prefix            = "AuthorsPager";
            model.AuthorsPager.CurrentParameters = new Dictionary <string, object>()
            {
                { "AuthorName", model.AuthorName },
                { "AuthorsPager.CurrentPage", model.AuthorsPager.CurrentPage }
            };

            #region Sorting and Filtering
            Expression <Func <Author, bool> > filter = a =>
                                                       string.IsNullOrEmpty(model.AuthorName) || (a.FirstName.Contains(model.AuthorName) || a.LastName.Contains(model.AuthorName));
            model.AuthorsPager.PagesCount = GetPagesCount(filter);

            ViewBag.NameSortParam = string.IsNullOrEmpty(sortOrder) ? "name_desc" : "";
            switch (sortOrder)
            {
            case "name_desc":
                model.AuthorsList = authorsRepository
                                    .GetAll(model.AuthorsPager.CurrentPage, ApplicationConfiguration.ItemsPerPage, filter,
                                            order: x => x.OrderByDescending(a => a.FirstName));
                break;

            default:
                model.AuthorsList = authorsRepository
                                    .GetAll(model.AuthorsPager.CurrentPage, ApplicationConfiguration.ItemsPerPage, filter,
                                            order: x => x.OrderBy(a => a.FirstName));
                break;
            }
            #endregion

            return(View(model));
        }
Пример #29
0
        public ActionResult Details(int id)
        {
            LibraryManagementSystemContext context = new LibraryManagementSystemContext();
            BooksRepository   booksRepository      = new BooksRepository(context);
            AuthorsRepository authorsRepository    = new AuthorsRepository(context);
            BooksDetailsVM    model = new BooksDetailsVM();

            this.TryUpdateModel(model);

            Book   book   = booksRepository.GetByID(id);
            Author author = new Author();

            if (book != null)
            {
                model.ID                       = book.ID;
                model.Title                    = book.Title;
                model.Publisher                = book.Publisher;
                model.StockCount               = book.StockCount;
                model.DeliveryPrice            = book.DeliveryPrice;
                model.DateReceived             = book.DateReceived;
                model.DatePublished            = book.DatePublished;
                model.AuthorsPager             = model.AuthorsPager ?? new GenericPagerVM();
                model.AuthorsPager.PagesCount  = GetPagesCount();
                model.AuthorsPager.CurrentPage =
                    model.AuthorsPager.CurrentPage == 0 ? 1 : model.AuthorsPager.CurrentPage;
                model.Authors = authorsRepository
                                .GetAll(model.AuthorsPager.CurrentPage, ApplicationConfiguration.ItemsPerPage, a => a.Books.Any(b => b.ID == id), order: x => x.OrderBy(a => a.FirstName))
                                .ToList();
                model.AuthorsPager.Action            = "Details";
                model.AuthorsPager.Controller        = "Books";
                model.AuthorsPager.Prefix            = "AuthorsPager";
                model.AuthorsPager.CurrentParameters = new Dictionary <string, object>()
                {
                    { "AuthorsPager.CurrentPage", model.AuthorsPager.CurrentPage }
                };

                return(View(model));
            }
            else
            {
                return(RedirectToAction("Index", "Authors"));
            }
        }
Пример #30
0
        public void PopulateAssignedAuthenticatingActions(Role role, AuthenticatingActionsRepository authenticatingActionsRepository)
        {
            LibraryManagementSystemContext context = new LibraryManagementSystemContext();
            RolesRepository rolesRepository        = new RolesRepository(context);

            var authenticatingActions     = authenticatingActionsRepository.GetAll();
            var roleAuthenticatingActions = new HashSet <int>(role.AuthenticatingActions.Select(r => r.ID));
            var model = new List <AuthenticatingActionsVM>();

            foreach (var action in authenticatingActions)
            {
                model.Add(new AuthenticatingActionsVM
                {
                    ID         = action.ID,
                    Name       = action.Name,
                    IsAssigned = roleAuthenticatingActions.Contains(action.ID)
                });
            }

            ViewBag.AuthenticatingActions = model;
        }