Esempio n. 1
0
        public IActionResult PersonDetail(int id)
        {
            Person person = _bookcontext.People.Include(q => q.BookPeople).ThenInclude(BookPeople => BookPeople.Book).ThenInclude(BookPeople => BookPeople.BookPersons).Include(q => q.PersonDuties).FirstOrDefault(q => q.ID == id);

            PersonVM model = new PersonVM();

            model.Name       = person.Name;
            model.SurName    = person.SurName;
            model.BirthDate  = person.BirthDate;
            model.Biography  = person.Biography;
            model.Duties     = person.PersonDuties.Where(q => q.IsDeleted == false).Select(q => q.DutyID == Convert.ToInt32(EnumDuty.Writer) ? EnumDuty.Writer.ToString() : EnumDuty.Interpreter.ToString()).ToList();
            model.Imagepath  = person.Imagepath;
            model.BookPeople = person.BookPeople;


            List <Category> modelcategory = _bookcontext.Categories.Where(q => q.IsDeleted == false).OrderBy(q => q.CategoryName).ToList();

            List <Person> modelpeople = _bookcontext.People.Include(q => q.BookPeople.Where(q => q.DutyID == 0)).Where(q => q.IsDeleted == false).OrderBy(q => q.Name).ToList();



            SiteBookVM sitebook = new SiteBookVM();

            sitebook.Categories   = modelcategory;
            sitebook.people       = modelpeople;
            sitebook.PersonDetail = model;

            return(View(sitebook));
        }
Esempio n. 2
0
        public IActionResult Index(int?page)
        {
            var pagenumber = page ?? 1;

            List <PersonVM> people = _bookcontext.People.Include(q => q.BookPeople).ThenInclude(BookPeople => BookPeople.Book).Where(q => q.IsDeleted == false).OrderBy(q => q.Name).Select(q => new PersonVM()
            {
                PersonID   = q.ID,
                Name       = q.Name,
                SurName    = q.SurName,
                Biography  = q.Biography,
                BirthDate  = q.BirthDate,
                Imagepath  = q.Imagepath,
                BookPeople = q.BookPeople.Where(q => q.IsDeleted == false).ToList(),
                Duties     = q.PersonDuties.Where(q => q.IsDeleted == false).Select(q => q.DutyID == Convert.ToInt32(EnumDuty.Writer) ? EnumDuty.Writer.ToString() : EnumDuty.Interpreter.ToString()).ToList(),
            }).ToList();

            List <Category> modelcategory = _bookcontext.Categories.Where(q => q.IsDeleted == false).OrderBy(q => q.CategoryName).ToList();

            List <Person> modelpeople = _bookcontext.People.Include(q => q.BookPeople.Where(q => q.DutyID == 0)).Where(q => q.IsDeleted == false).OrderBy(q => q.Name).ToList();

            SiteBookVM sitebook = new SiteBookVM();

            sitebook.Categories = modelcategory;
            sitebook.people     = modelpeople;
            sitebook.PeopleVM   = people.ToPagedList(pagenumber, 9);

            return(View(sitebook));
        }
Esempio n. 3
0
        public IActionResult EditComment(SiteBookVM model)
        {
            Comment comment = _bookcontext.Comments.FirstOrDefault(q => q.ID == model.Comment.ID);

            comment.Header     = model.Comment.Header;
            comment.Content    = model.Comment.Content;
            comment.UpdateDate = DateTime.Now;

            _bookcontext.SaveChanges();

            return(RedirectToAction("BookDetail", "SiteBook", new { id = comment.BookID }));
        }
Esempio n. 4
0
        public IActionResult Search(string keywords, int?catalog, int?category, int?scategory, int?page)
        {
            var pagenumber = page ?? 1;

            List <Category> modelcategory = _bookcontext.Categories.Where(q => q.IsDeleted == false).OrderBy(q => q.CategoryName).ToList();



            List <Person> modelpeople = _bookcontext.People.Include(q => q.BookPeople.Where(q => q.DutyID == 0)).Where(q => q.IsDeleted == false).OrderBy(q => q.Name).ToList();

            var data = _bookcontext.Books.Include(x => x.BookCategories).ThenInclude(BookCategory => BookCategory.Category).Include(x => x.BookPersons).ThenInclude(BookPerson => BookPerson.Person).OrderBy(q => q.Name).Where(x => x.IsDeleted == false).ToList();



            if (!String.IsNullOrEmpty(keywords))
            {
                data = data.Where(x => x.Name.ToLower().Contains(keywords.ToLower()) || x.BookPersons.Where(x => x.Person.Name.ToLower().Contains(keywords.ToLower())).Any() || x.BookPersons.Where(x => x.Person.SurName.ToLower().Contains(keywords.ToLower())).Any() && x.IsDeleted == false).Where(Book => Book.IsDeleted == false).ToList();
            }

            if (catalog != null)
            {
                data = data.Where(x => x.BookCategories.Where(x => x.Category.TopCategory == catalog || x.CategoryID == catalog).Any())
                       .Where(Book => Book.IsDeleted == false).ToList();
            }

            if (category != null)
            {
                data = data.Where(x => x.BookCategories.Where(x => x.CategoryID == category || x.Category.TopCategory == category).Any())
                       .Where(Book => Book.IsDeleted == false).ToList();
            }

            if (scategory != null)
            {
                data = data.Where(x => x.BookCategories.Where(x => x.CategoryID == scategory).Any())
                       .Where(Book => Book.IsDeleted == false).ToList();
            }


            SiteBookVM sitebook = new SiteBookVM();

            sitebook.books      = data.ToPagedList(pagenumber, 9);
            sitebook.Categories = modelcategory;
            sitebook.people     = modelpeople;



            return(View("Index", new SiteBookVM {
                books = data.ToPagedList(pagenumber, 9), Categories = modelcategory, people = modelpeople
            }));
        }
Esempio n. 5
0
        public IActionResult AddComment(SiteBookVM model)
        {
            Comment comment = new Comment();

            comment.UserID  = Convert.ToInt32(TempData["UserID"]);
            comment.Header  = model.Comment.Header;
            comment.Content = model.Comment.Content;
            comment.BookID  = model.Bookdetail.ID;


            _bookcontext.Comments.Add(comment);
            _bookcontext.SaveChanges();


            return(RedirectToAction("BookDetail", "SiteBook", new { id = model.Bookdetail.ID }));
        }
Esempio n. 6
0
        public IActionResult BookDetail(int id)
        {
            List <Category> modelcategory = _bookcontext.Categories.Where(q => q.IsDeleted == false).OrderBy(q => q.CategoryName).ToList();

            Book modelbook = _bookcontext.Books.Include(q => q.BookCategories).ThenInclude(BookCategories => BookCategories.Category).Include(q => q.BookPersons.Where(q => q.IsDeleted == false)).ThenInclude(BookPersons => BookPersons.Person).Include(q => q.Comments.Where(q => q.IsDeleted == false && q.BookID == id)).ThenInclude(Comments => Comments.User).Include(q => q.UserPoints.Where(q => q.IsDeleted == false)).ThenInclude(UserPoints => UserPoints.USer).FirstOrDefault(q => q.ID == id);

            List <Person> modelpeople = _bookcontext.People.Include(q => q.BookPeople.Where(q => q.DutyID == 0)).Where(q => q.IsDeleted == false).OrderBy(q => q.Name).ToList();



            SiteBookVM sitebook = new SiteBookVM();

            sitebook.Bookdetail = modelbook;
            sitebook.Categories = modelcategory;
            sitebook.people     = modelpeople;
            return(View(sitebook));
        }
Esempio n. 7
0
        public IActionResult Index(int?page)
        {
            var pagenumber = page ?? 1;

            List <Book> modelbook = _bookcontext.Books.Include(q => q.BookCategories).ThenInclude(BookCategories => BookCategories.Category).Include(q => q.BookPersons).ThenInclude(BookPerson => BookPerson.Person).Where(q => q.IsDeleted == false).OrderBy(q => q.Name).ToList();

            List <Category> modelcategory = _bookcontext.Categories.Where(q => q.IsDeleted == false).OrderBy(q => q.CategoryName).ToList();

            List <Person> modelpeople = _bookcontext.People.Include(q => q.BookPeople.Where(q => q.DutyID == 0)).Where(q => q.IsDeleted == false).OrderBy(q => q.Name).ToList();

            //var pagedsitebook = modelbook.ToPagedList(pagenumber, 10);

            SiteBookVM sitebook = new SiteBookVM();

            //sitebook.books = pagedsitebook.ToList();
            sitebook.Categories = modelcategory;
            sitebook.people     = modelpeople;
            sitebook.books      = modelbook.ToPagedList(pagenumber, 9);


            return(View(sitebook));
        }
Esempio n. 8
0
        public IActionResult WriterListclick(int id, int?page)
        {
            var             pagenumber    = page ?? 1;
            List <Category> modelcategory = _bookcontext.Categories.Where(q => q.IsDeleted == false).OrderBy(q => q.CategoryName).ToList();

            List <Person> modelpeople = _bookcontext.People.Include(q => q.BookPeople.Where(q => q.DutyID == 0)).Where(q => q.IsDeleted == false).OrderBy(q => q.Name).ToList();

            List <Book> data = _bookcontext.Books.Include(x => x.BookCategories).ThenInclude(BookCategory => BookCategory.Category).Include(x => x.BookPersons).ThenInclude(BookPerson => BookPerson.Person).OrderBy(q => q.Name).Where(x => x.IsDeleted == false).ToList();

            data = data.Where(x => x.BookPersons.Where(x => x.PersonID == id).Any())
                   .Where(Book => Book.IsDeleted == false).ToList();


            SiteBookVM sitebook = new SiteBookVM();

            sitebook.books      = data.ToPagedList(pagenumber, 9);
            sitebook.Categories = modelcategory;
            sitebook.people     = modelpeople;

            return(View("Index", new SiteBookVM {
                books = data.ToPagedList(pagenumber, 9), Categories = modelcategory, people = modelpeople
            }));
        }