public ActionResult AddBook()
        {
            var profileData = Session["UserProfile"] as UserSession;

            if (profileData == null)
            {
                return(RedirectToAction("Index", "Home"));
            }

            var publicationRepository   = new PublicationRepository();
            var contentRatingRepository = new ContentRatingRepository();
            var authorRepository        = new AuthorRepository();
            var bookDetail = new BookDetails();
            var bookModel  = new BookModel();

            ModelState.Clear();

            bookModel.PublicationList   = publicationRepository.GetAllPublication();
            bookModel.ContentRatingList = contentRatingRepository.GetAllContentRating();
            bookModel.BookTypeList      = new List <String>()
            {
                "Reference Book",
                "Loan Book"
            };

            bookDetail.BookModel  = bookModel;
            bookDetail.AuthorList = authorRepository.GetAllAuthor();

            return(View(bookDetail));
        }
Ejemplo n.º 2
0
        public ActionResult AddContentRating(ContentRatingModel contentRating)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    ContentRatingRepository ContentRatingRepo = new ContentRatingRepository();
                    ContentRatingRepo.AddContentRating(contentRating);

                    var profileData = Session["UserProfile"] as UserSession;
                    var logModel    = new LogModel
                    {
                        UserId    = profileData.UserID,
                        TableName = "Content Rating",
                        Activity  = "Added Content Rating",
                        LogDate   = DateTime.Now
                    };
                    var logRepository = new logRepository();
                    logRepository.AddLog(logModel);
                }

                return(RedirectToAction("GetAllContentRatingDetails"));
            }
            catch
            {
                return(RedirectToAction("GetAllContentRatingDetails"));
            }
        }
Ejemplo n.º 3
0
        //// GET: Delete Book Details
        //[HttpPost]
        public ActionResult DeleteContentRating(int id)
        {
            var profileData = Session["UserProfile"] as UserSession;

            if (profileData == null)
            {
                return(RedirectToAction("Index", "Home"));
            }

            try
            {
                ContentRatingRepository ContentRatingRepo = new ContentRatingRepository();
                if (ContentRatingRepo.DeleteContentRating(id))
                {
                    ViewBag.AlertMsg = "Book details deleted successfully";
                }
                var logModel = new LogModel
                {
                    UserId    = profileData.UserID,
                    TableName = "Author",
                    Activity  = "Deleted Author",
                    LogDate   = DateTime.Now
                };
                var logRepository = new logRepository();
                logRepository.AddLog(logModel);
                return(RedirectToAction("GetAllContentRatingDetails"));
            }
            catch
            {
                return(RedirectToAction("GetAllContentRatingDetails"));
            }
        }
Ejemplo n.º 4
0
        // GET: Update Book Details
        public ActionResult EditContentRatingDetails(int id)
        {
            var profileData = Session["UserProfile"] as UserSession;

            if (profileData == null)
            {
                return(RedirectToAction("Index", "Home"));
            }

            ContentRatingRepository ContentRatingRepo = new ContentRatingRepository();

            return(View(ContentRatingRepo.GetAllContentRating().Find(ContentRatings => ContentRatings.ContentRatingId == id)));
        }
Ejemplo n.º 5
0
        //GET: All Book Details
        public ActionResult GetAllContentRatingDetails()
        {
            var profileData = Session["UserProfile"] as UserSession;

            if (profileData == null)
            {
                return(RedirectToAction("Index", "Home"));
            }

            ContentRatingRepository ContentRatingRepo = new ContentRatingRepository();

            ModelState.Clear();
            return(View(ContentRatingRepo.GetAllContentRating()));
        }
        public ActionResult GetBook(int id)
        {
            var profileData = Session["UserProfile"] as UserSession;

            if (profileData == null)
            {
                return(RedirectToAction("Index", "Home"));
            }

            BookRepository          bookRepository          = new BookRepository();
            BookAuthorRepository    bookAuthorRepository    = new BookAuthorRepository();
            AuthorRepository        authorRepository        = new AuthorRepository();
            PublicationRepository   publicationRepository   = new PublicationRepository();
            ContentRatingRepository contentRatingRepository = new ContentRatingRepository();

            List <BookAuthorModel> bookAuthorList = new List <BookAuthorModel>();
            BookDetails            bookDetail     = new BookDetails();
            BookModel book = new BookModel();

            book = bookRepository.SearchBookById(id);
            bookDetail.BookModel = book;

            bookAuthorList = bookAuthorRepository.GetByBookId(book.BookId);

            if (bookAuthorList.Count == 1)
            {
                bookDetail.AuthorInfo1 = authorRepository.GetByAuthorId(bookAuthorList[0].AuthorId);
            }

            else if (bookAuthorList.Count == 2)
            {
                bookDetail.AuthorInfo1 = authorRepository.GetByAuthorId(bookAuthorList[0].AuthorId);
                bookDetail.AuthorInfo2 = authorRepository.GetByAuthorId(bookAuthorList[1].AuthorId);
            }

            else
            {
                bookDetail.AuthorInfo1 = authorRepository.GetByAuthorId(bookAuthorList[0].AuthorId);
                bookDetail.AuthorInfo2 = authorRepository.GetByAuthorId(bookAuthorList[1].AuthorId);
                bookDetail.AuthorInfo3 = authorRepository.GetByAuthorId(bookAuthorList[2].AuthorId);
            }

            bookDetail.PublicationModel = publicationRepository.GetByPublicationId(book.PublicationId);

            bookDetail.ContentRatingModel = contentRatingRepository.GetByContentId(book.ContentRatingId);

            return(View(bookDetail));
        }
Ejemplo n.º 7
0
 public ActionResult EditContentRatingDetails(int id, ContentRatingModel contentRating)
 {
     try
     {
         ContentRatingRepository ContentRatingRepo = new ContentRatingRepository();
         ContentRatingRepo.UpdateContentRating(contentRating);
         var profileData = Session["UserProfile"] as UserSession;
         var logModel    = new LogModel
         {
             UserId    = profileData.UserID,
             TableName = "Content Rating",
             Activity  = "Updated Rating",
             LogDate   = DateTime.Now
         };
         var logRepository = new logRepository();
         logRepository.AddLog(logModel);
         return(RedirectToAction("GetAllContentRatingDetails"));
     }
     catch
     {
         return(RedirectToAction("GetAllContentRatingDetails"));
     }
 }
Ejemplo n.º 8
0
        public ActionResult AddLoan(LoanModel loanModel)
        {
            try
            {
                LoanRepository          loanRepository          = new LoanRepository();
                copiesRepository        copiesRepository        = new copiesRepository();
                BookRepository          bookRepository          = new BookRepository();
                ContentRatingRepository contentRatingRepository = new ContentRatingRepository();
                MemberRepository        memberRepository        = new MemberRepository();
                MembershipRepository    membershipRepository    = new MembershipRepository();

                List <MemberModel> memberList   = new List <MemberModel>();
                LoanModel          newLoanModel = new LoanModel();
                newLoanModel.MemberList = memberRepository.GetAllMember();

                CopiesModel copiesModel = new CopiesModel();
                copiesModel = copiesRepository.SearchCopyById(loanModel.CopiesId);

                BookModel bookModel = new BookModel();
                bookModel = bookRepository.SearchBookById(copiesModel.BookId);

                if (bookModel.BookType.Equals("Reference Book"))
                {
                    ViewBag.Message = "Reference Books Can't be Loaned";
                    return(View(newLoanModel));
                }

                ContentRatingModel contentRatingModel = new ContentRatingModel();
                contentRatingModel = contentRatingRepository.GetByContentId(bookModel.ContentRatingId);

                MemberModel memberModel = new MemberModel();
                memberModel = memberRepository.SearchMemberById(loanModel.MembershipId);

                if (contentRatingModel.ContentRatingName.Equals("18+"))
                {
                    var today    = DateTime.Today;
                    var age      = Convert.ToDateTime(memberModel.Dob);
                    var todayAge = today.Year - age.Year;
                    if (todayAge < 18)
                    {
                        ViewBag.Message = "Age Restricted Books Are Not Allowed";
                        return(View(newLoanModel));
                    }
                }

                MembershipModel membershipModel = new MembershipModel();
                membershipModel = membershipRepository.GetMembershipByID(memberModel.MembershipId);

                BookCopies bookCopiesModel = new BookCopies();
                bookCopiesModel = loanRepository.GetAllLoanByMemberID(memberModel.MemberId);

                if (bookCopiesModel.Quantities >= membershipModel.NoOfBooks)
                {
                    ViewBag.Message = "No More Books Can be Loaned";
                    return(View(newLoanModel));
                }

                DateTime returnedDate = Convert.ToDateTime(loanModel.LoanDate);
                loanModel.ReturnDate = returnedDate.AddDays(14).ToString("yyyy MMMM dd");
                loanRepository.AddLoan(loanModel);
                copiesRepository.UpdateCopiesStatus(loanModel.CopiesId);

                var profileData = Session["UserProfile"] as UserSession;
                var logModel    = new LogModel
                {
                    UserId    = profileData.UserID,
                    TableName = "Loan",
                    Activity  = "Added Loan",
                    LogDate   = DateTime.Now
                };
                var logRepository = new logRepository();
                logRepository.AddLog(logModel);
                return(RedirectToAction("Dashboard", "Home"));
            }
            catch
            {
                return(RedirectToAction("Index", "Home"));
            }
        }