Beispiel #1
0
        public ActionResult AutocompleteAuthor(string term)
        {
            var authors      = authorManager.GetAuthorList(Active.active);
            var authorModels = authors.ConvertAll(obj => new AutoCompleteAuthorModel(obj));

            var filteredItems = authorModels.Where(author => author.label.ToLower().Contains(term.ToLower())).ToList();

            return(Json(filteredItems, JsonRequestBehavior.AllowGet));
        }
Beispiel #2
0
        // lists all the authors on the db and sends as paged list
        public ActionResult ListAuthors(int?page)
        {
            IList <Author> allAuthors       = AuthorManager.GetAuthorList();
            int            currentPageIndex = page.HasValue ? page.Value - 1 : 0;

            return(View("ListAuthors", allAuthors.ToPagedList(currentPageIndex, DefaultPageSize)));
        }
Beispiel #3
0
        public RedirectToRouteResult AddAuthor(Author newAuthor)
        {
            bool isAuthorized = Administrator.IsAuthorized((string)(Session["UserSession"]), (int)(Session["UserRank"]), (int)Authorization.Rank.administrator);

            if (isAuthorized)
            {
                newAuthor.Aid = AuthorManager.GetAuthorList().Count();
                // string fname, string lname, string byear
                if (ModelState.IsValid)
                {
                    AuthorManager.AddAnAuthor(newAuthor);
                    return(RedirectToAction("ListAuthors", "Author"));
                }
            }
            TempData["Error"] = "Something went wrong!";
            return(RedirectToAction("AddAuthor"));
        }