Ejemplo n.º 1
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.º 2
0
        public ActionResult AddAuthor(AuthorModel author)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    AuthorRepository AuthorRepo = new AuthorRepository();
                    AuthorRepo.AddAuthor(author);

                    var profileData = Session["UserProfile"] as UserSession;
                    var logModel    = new LogModel
                    {
                        UserId    = profileData.UserID,
                        TableName = "Author",
                        Activity  = "Added Author",
                        LogDate   = DateTime.Now
                    };
                    var logRepository = new logRepository();
                    logRepository.AddLog(logModel);
                }
                return(RedirectToAction("GetAllAuthorDetails"));
            }
            catch
            {
                return(RedirectToAction("GetAllAuthorDetails"));
            }
        }
Ejemplo n.º 3
0
        public ActionResult DeleteCopy(int id)
        {
            var profileData = Session["UserProfile"] as UserSession;

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

            try
            {
                copiesRepository copiesRepository = new copiesRepository();
                if (copiesRepository.DeleteCopies(id))
                {
                    ViewBag.AlertMsg = "Copies deleted successfully";
                }

                var logModel = new LogModel
                {
                    UserId    = profileData.UserID,
                    TableName = "Copies",
                    Activity  = "Deleted Copies",
                    LogDate   = DateTime.Now
                };
                var logRepository = new logRepository();
                logRepository.AddLog(logModel);
                return(RedirectToAction("Dashboard", "Home"));
            }
            catch
            {
                return(RedirectToAction("Dashboard", "Home"));
            }
        }
        public ActionResult EditMembershipDetails(int id, MembershipModel obj)
        {
            try
            {
                MembershipRepository MemshipRepo = new MembershipRepository();
                MemshipRepo.UpdateMembership(obj);

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

                return(RedirectToAction("GetAllMembershipDetails"));
            }
            catch
            {
                return(RedirectToAction("GetAllMembershipDetails"));
            }
        }
        public ActionResult DeleteMembership(int id)
        {
            var profileData = this.Session["UserProfile"] as UserSession;

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

            try
            {
                MembershipRepository CrgRepo = new MembershipRepository();
                if (CrgRepo.DeleteMembership(id))
                {
                    ViewBag.AlertMsg = "Employee details deleted successfully";
                }
                LogModel logModel = new LogModel()
                {
                    UserId    = profileData.UserID,
                    TableName = "Membership",
                    Activity  = "Deleted Membership",
                    LogDate   = DateTime.Now
                };
                logRepository logRepository = new logRepository();
                logRepository.AddLog(logModel);
                return(RedirectToAction("GetAllMembershipDetails"));
            }
            catch
            {
                return(RedirectToAction("GetAllMembershipDetails"));
            }
        }
Ejemplo n.º 6
0
 public logController()
 {
     _logRepository       = new logRepository();
     _warehouseRepository = new warehouseRepository();
     _reasonRepository    = new reasonRepository();
     _itemRepository      = new itemRepository();
 }
        public ActionResult AddPublication(PublicationModel publication)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    PublicationRepository publicationRepository = new PublicationRepository();
                    publicationRepository.AddPublication(publication);

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

                return(RedirectToAction("GetAllPublicationDetails"));
            }
            catch
            {
                return(RedirectToAction("GetAllPublicationDetails"));
            }
        }
Ejemplo n.º 8
0
        public ActionResult AddCopies(BookCopies bookCopies)
        {
            try
            {
                copiesRepository copiesRepository = new copiesRepository();
                for (int i = 0; i < bookCopies.Quantities; i++)
                {
                    CopiesModel copiesModel = new CopiesModel()
                    {
                        BookId     = bookCopies.BookModel.BookId,
                        CopyNo     = i + 1,
                        DateBought = bookCopies.CopiesModel.DateBought,
                        Location   = bookCopies.CopiesModel.Location
                    };
                    copiesRepository.AddCopies(copiesModel);

                    var profileData = Session["UserProfile"] as UserSession;
                    var logModel    = new LogModel
                    {
                        UserId    = profileData.UserID,
                        TableName = "Copies",
                        Activity  = "Copies Added",
                        LogDate   = DateTime.Now
                    };
                    var logRepository = new logRepository();
                    logRepository.AddLog(logModel);
                }
                return(RedirectToAction("Dashboard", "Home"));
            }
            catch
            {
                return(RedirectToAction("Dashboard", "Home"));
            }
        }
        public ActionResult AddShelf(ShelfModel shelf)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    ShelfRepository ShelfRepo = new ShelfRepository();
                    ShelfRepo.AddShelf(shelf);

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

                return(RedirectToAction("GetAllShelfDetails"));
            }
            catch
            {
                return(RedirectToAction("GetAllShelfDetails"));
            }
        }
        public ActionResult AddBook(BookDetails book)
        {
            try
            {
                BookRepository bookRepository = new BookRepository();
                bookRepository.AddBook(book);

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

                return(RedirectToAction("Dashboard", "Home"));
            }
            catch
            {
                return(RedirectToAction("Dashboard", "Home"));
            }
        }
Ejemplo n.º 11
0
        public ActionResult AddUser(UserModel User)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    UserRepository userRepository = new UserRepository();
                    userRepository.AddUser(User);

                    var profileData = Session["UserProfile"] as UserSession;
                    var logModel    = new LogModel
                    {
                        UserId    = profileData.UserID,
                        TableName = "User",
                        Activity  = "Added User",
                        LogDate   = DateTime.Now
                    };
                    var logRepository = new logRepository();
                    logRepository.AddLog(logModel);
                }
                return(RedirectToAction("GetAllUserDetails"));
            }
            catch
            {
                return(View());
            }
        }
        //// GET: Delete Book Details
        //[HttpPost]
        public ActionResult DeleteBooks(int id)
        {
            try
            {
                var profileData = Session["UserProfile"] as UserSession;
                if (profileData == null)
                {
                    return(RedirectToAction("Index", "Home"));
                }

                BookRepository       bookRepository       = new BookRepository();
                BookAuthorRepository bookAuthorRepository = new BookAuthorRepository();

                bookAuthorRepository.DeleteBookAuthorByBookId(id);
                bookRepository.DeleteBooks(id);

                var logModel = new LogModel
                {
                    UserId    = profileData.UserID,
                    TableName = "Book",
                    Activity  = "Deleted Book",
                    LogDate   = DateTime.Now
                };
                var logRepository = new logRepository();
                logRepository.AddLog(logModel);

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

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

            try
            {
                AuthorRepository AuthorRepo = new AuthorRepository();
                if (AuthorRepo.DeleteAuthor(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("GetAllAuthorDetails"));
            }
            catch
            {
                return(RedirectToAction("GetAllAuthorDetails"));
            }
        }
        public ActionResult AddMembership(MembershipModel Memship)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    MembershipRepository MemshipRepo = new MembershipRepository();
                    MemshipRepo.AddMembership(Memship);

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

                return(RedirectToAction("GetAllMembershipDetails"));
            }
            catch
            {
                return(RedirectToAction("GetAllMembershipDetails"));
            }
        }
Ejemplo n.º 15
0
        public static void error(Exception ex, string usuario, string metodo)
        {
            errorDto _error = new errorDto();

            _error.vchUsuario          = usuario;
            _error.vchMetodo           = metodo;
            _error.vchMessageError     = ex.Message;
            _error.vchInnerTracerError = ex.StackTrace.ToString();
            IlogRepository _logError = new logRepository();

            _logError.error(_error);
        }
        public ActionResult GetAllLog()
        {
            var profileData = Session["UserProfile"] as UserSession;

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

            logRepository logRepository = new logRepository();

            ModelState.Clear();
            return(View(logRepository.GetAllLog()));
        }
Ejemplo n.º 17
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.º 18
0
        public ActionResult EditUserDetails(int id, UserModel User)
        {
            try
            {
                var userRepository = new UserRepository();
                userRepository.UpdateUser(User);
                var profileData = Session["UserProfile"] as UserSession;
                var logModel    = new LogModel
                {
                    UserId    = profileData.UserID,
                    TableName = "User",
                    Activity  = "Updated User",
                    LogDate   = DateTime.Now
                };
                var logRepository = new logRepository();
                logRepository.AddLog(logModel);

                return(RedirectToAction("GetAllUserDetails"));
            }
            catch
            {
                return(View());
            }
        }
        public ActionResult EditPublicationDetails(int id, PublicationModel obj)
        {
            try
            {
                PublicationRepository publicationRepository = new PublicationRepository();
                publicationRepository.UpdatePublication(obj);
                var profileData = Session["UserProfile"] as UserSession;
                var logModel    = new LogModel
                {
                    UserId    = profileData.UserID,
                    TableName = "Publication",
                    Activity  = "Updated Publication",
                    LogDate   = DateTime.Now
                };
                var logRepository = new logRepository();
                logRepository.AddLog(logModel);

                return(RedirectToAction("GetAllPublicationDetails"));
            }
            catch
            {
                return(RedirectToAction("GetAllPublicationDetails"));
            }
        }
Ejemplo n.º 20
0
        public ActionResult ReturnLoan(LoanModel loanModel)
        {
            try
            {
                LoanRepository   loanRepository   = new LoanRepository();
                copiesRepository copiesRepository = new copiesRepository();
                BookRepository   bookRepository   = new BookRepository();
                MemberRepository memberRepository = new MemberRepository();

                LoanModel newLoanModel = new LoanModel();
                newLoanModel = loanRepository.GetAllLoanByID(loanModel.LoanId);
                MemberModel memberModel = memberRepository.SearchMemberById(newLoanModel.MembershipId);
                CopiesModel copiesModel = copiesRepository.SearchCopyById(newLoanModel.CopiesId);
                BookModel   bookModel   = bookRepository.SearchBookById(copiesModel.BookId);

                BookLoaned bookLoaned = new BookLoaned();

                bookLoaned.LoanID           = newLoanModel.LoanId;
                bookLoaned.LoanDate         = newLoanModel.LoanDate;
                bookLoaned.ReturnDate       = newLoanModel.ReturnDate;
                bookLoaned.MemberName       = memberModel.MemberName;
                bookLoaned.BookName         = bookModel.BookName;
                bookLoaned.ActualReturnDate = loanModel.ActualReturnDate;

                DateTime _returnDate       = Convert.ToDateTime(newLoanModel.ReturnDate);
                DateTime _actualReturnDate = Convert.ToDateTime(loanModel.ActualReturnDate);

                double _numberOfDays = (_actualReturnDate - _returnDate).TotalDays;
                int    numberOfDays  = Convert.ToInt32(_numberOfDays);

                if (numberOfDays < 0 || numberOfDays == 0)
                {
                    bookLoaned.Charge = 0;
                }
                else
                {
                    bookLoaned.Charge = numberOfDays * 10;
                }

                TempData["BookLoaned"] = bookLoaned;
                bool returnedData = loanRepository.UpdateLoan(newLoanModel.LoanId);
                bool updatedData  = copiesRepository.ChangeCopiesStatus(newLoanModel.CopiesId);

                if (returnedData && updatedData)
                {
                    var profileData = Session["UserProfile"] as UserSession;
                    var logModel    = new LogModel
                    {
                        UserId    = profileData.UserID,
                        TableName = "Loan",
                        Activity  = "Loan Returned",
                        LogDate   = DateTime.Now
                    };
                    var logRepository = new logRepository();
                    logRepository.AddLog(logModel);
                    return(RedirectToAction("ShowReturnedDetails"));
                }
                return(RedirectToAction("Dashboard", "Home"));
            }
            catch
            {
                return(RedirectToAction("Dashboard", "Home"));
            }
        }
Ejemplo n.º 21
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"));
            }
        }