public ActionResult UserViewBook(String msg = "", string color = "black", string title = "", string author = "")
        {
            try
            {
                if (ValidateLogin() == false)
                {
                    return(RedirectToAction("Login", "Auth", new { msg = "Session Expired from User DashBoard, plz login again", color = "Red" }));
                }

                List <Book> booklist = new BookBL().GetBookListByUserId(sdto.getId(), db).ToList();
                if (title != "")
                {
                    booklist = booklist.Where(x => x.Title.ToLower().Contains(title.ToLower())).ToList();
                }
                if (author != "")
                {
                    booklist = booklist.Where(x => x.Auther.ToLower().Contains(author.ToLower())).ToList();
                }

                ViewBag.BookList = booklist;
                ViewBag.msg      = msg;
                ViewBag.color    = color;
                ViewBag.title    = title;
                ViewBag.author   = author;
                return(View());
            }
            catch
            {
                return(RedirectToAction("Error", "Auth", new { msg = "search for the page was not found", color = "Red" }));
            }
        }
示例#2
0
 public ActionResult AdminViewUserBook(string Name = "", string Title = "", string Author = "", int id = -1)
 {
     try
     {
         if (ValidateLogin() == false)
         {
             return(RedirectToAction("Login", "Auth", new { msg = "Session Expired from ADMIN DashBoard, plz login again", color = "Red" }));
         }
         if (id == -1)
         {
             List <Book> bookList = new BookBL().GetActiveBookList(db).ToList();
             if (Name != "")
             {
                 bookList = bookList.Where(x => x.User.FirstName.ToLower().Contains(Name.ToLower()) || x.User.LastName.ToLower().Contains(Name.ToLower())).ToList();
             }
             if (Title != "")
             {
                 bookList = bookList.Where(x => x.Title.ToLower().Contains(Title.ToLower())).ToList();
             }
             if (Author != "")
             {
                 bookList = bookList.Where(x => x.Auther.ToLower().Contains(Author.ToLower())).ToList();
             }
             ViewBag.Book   = bookList;
             ViewBag.Name   = Name;
             ViewBag.Title  = Title;
             ViewBag.Author = Author;
             return(View());
         }
         else
         {
             List <Book> bookList = new BookBL().GetActiveBookList(db).Where(x => x.UserId == id).ToList();
             if (Name != "")
             {
                 bookList = bookList.Where(x => x.User.FirstName.ToLower().Contains(Name.ToLower()) || x.User.LastName.ToLower().Contains(Name.ToLower())).ToList();
             }
             if (Title != "")
             {
                 bookList = bookList.Where(x => x.Title.ToLower().Contains(Title.ToLower())).ToList();
             }
             if (Author != "")
             {
                 bookList = bookList.Where(x => x.Auther.ToLower().Contains(Author.ToLower())).ToList();
             }
             ViewBag.Book   = bookList;
             ViewBag.Name   = Name;
             ViewBag.Title  = Title;
             ViewBag.Author = Author;
             return(View());
         }
     }
     catch
     {
         return(RedirectToAction("Error", "Auth", new { msg = "search for the page was not found ", color = "Red" }));
     }
 }