Esempio n. 1
0
 /* this method use to instantiate controller to imply that current user log in
  * is from username parameter and pass libRepo to instantiate controller to use
  * preferred LibraryRepository object.
  */
 public void InitialController(string username, LibraryRepository libRepo)
 {
     controller = new BookSearchController(libRepo);
     controller.ControllerContext = new ControllerContext()
     {
         Controller = controller,
         RequestContext = new RequestContext(new MockHttpContext(username), new RouteData())
     };
     controller.Session["LoginUser"] = username;
 }
Esempio n. 2
0
        //This method is work when server start website
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();
            WebApiConfig.Register(GlobalConfiguration.Configuration);
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);

            //Set current exist users from database to AuthenticateController static properties via AddUser method
            DataAccess.LibraryRepository libRepo = new DataAccess.LibraryRepository();
            foreach (Member member in libRepo.MemberRepo.List())
                Controllers.AuthenticateController.AddUser(member.UserName);
            foreach (Librarian librarian in libRepo.LibrarianRepo.List())
                Controllers.AuthenticateController.AddUser(librarian.UserName);

            //Set latestNews that will be load in HomePage
            List<News> newsList = libRepo.NewsRepo.List().OrderByDescending(news => news.PostTime).ToList();
                if (newsList.Count >= 7)
                    newsList = newsList.GetRange(0, 7);
                else
                    newsList = newsList.GetRange(0, newsList.Count);
                Controllers.NewsController.setLatestNews(newsList);

            /* Load configuration of fine penalty from file if it is not exist create new file and set it
             * to default value(5) otherwise load value from file and set it to ConfigurationController's static properties
             * via setFine method.
             */

            if (!File.Exists(HttpRuntime.AppDomainAppPath+"/lib-config"))
            {

                File.AppendAllText(HttpRuntime.AppDomainAppPath + "/lib-config", "5");
            }
            else
            {
                Controllers.ConfigurationController.setFine(int.Parse
                    (File.ReadAllText(HttpRuntime.AppDomainAppPath + "/lib-config")));
            }
        }
Esempio n. 3
0
 /* 4 below methods use to receive related borrow/request entry of book
  * via LibraryRepository object which can pass by reference or not pass parameter
  * but instantiate in these method.
  */
 public List<BorrowEntry> GetRelatedBorrowEntry()
 {
     LibraryRepository libRepo = new LibraryRepository();
     return libRepo.BorrowEntryRepo.ListWhere(entry => entry.BookID == BookID);
 }
Esempio n. 4
0
 public RequestEntry GetRelatedRequestEntry(ref LibraryRepository libRepo)
 {
     return libRepo.RequestEntryRepo.ListWhere(entry => entry.BookID == BookID).SingleOrDefault();
 }
 public MemberTransactionController()
 {
     libRepo = new LibraryRepository();
 }
 /* Both of constructors use to set libRepo properties whether to use default(instantiate new)
  * or via parameter.
  */
 public MemberTransactionController(LibraryRepository libRepo)
 {
     this.libRepo = libRepo;
 }
Esempio n. 7
0
 public Member GetRequestUser(ref LibraryRepository libRepo)
 {
     return libRepo.MemberRepo.ListWhere(member => member.UserID == UserID).SingleOrDefault();
 }
Esempio n. 8
0
 public Book GetRequestBook(ref LibraryRepository libRepo)
 {
     return libRepo.BookRepo.ListWhere(book => book.BookID == BookID).SingleOrDefault();
 }
Esempio n. 9
0
 public Member GetBorrower()
 {
     LibraryRepository libRepo = new LibraryRepository();
     return libRepo.MemberRepo.ListWhere(member => member.UserID == UserID).SingleOrDefault();
 }
Esempio n. 10
0
 /* 4 below methods use to receive related borrowBook and borrower
  * via LibraryRepository object which can pass by reference or not pass parameter
  * but instantiate in these method.
  */
 public Book GetBorrowBook()
 {
     LibraryRepository libRepo = new LibraryRepository();
     return libRepo.BookRepo.ListWhere(book => book.BookID == BookID).SingleOrDefault();
 }
 public BookSearchController(LibraryRepository libRepo)
 {
     this.libRepo = libRepo;
 }
 /* Both of constructors use to set libRepo properties whether to use default(instantiate new)
  * or via parameter.
  */
 public BookSearchController()
 {
     libRepo = new LibraryRepository();
 }
Esempio n. 13
0
 public List<RequestEntry> GetRelatedRequestEntry(ref LibraryRepository libRepo)
 {
     return libRepo.RequestEntryRepo.ListWhere(entry => entry.UserID == UserID);
 }
Esempio n. 14
0
 public List<BorrowEntry> GetRelatedBorrowEntry(ref LibraryRepository libRepo)
 {
     return libRepo.BorrowEntryRepo.ListWhere(entry => entry.UserID == UserID);
 }