Ejemplo n.º 1
0
        // GET: Account
        public ActionResult Index()
        {
            AccountVM      userBL = new AccountVM();
            List <Account> list   = userBL.Get_list();

            return(View(list));
        }
Ejemplo n.º 2
0
        public ActionResult Edit(int id)
        {
            AccountVM      vm    = new AccountVM();
            List <Account> lista = vm.Get_list();
            Account        a     = lista.Where(s => s.AccountID == id).FirstOrDefault();

            return(View(a));
        }
Ejemplo n.º 3
0
        public ActionResult SendMails()
        {
            AccountVM   acc  = new AccountVM();
            BorrowingVM bor  = new BorrowingVM();
            BookVM      book = new BookVM();

            List <Book>      books    = book.Get_list();
            List <Account>   accounts = acc.Get_list();
            List <Borrowing> borrows  = bor.Get_list();

            var emails = from b in books
                         from o in borrows
                         from a in accounts
                         where o.BookID == b.BookID && a.AccountID == o.ReaderID && o.Returned == false && o.Return_date < DateTime.Now
                         select new
            {
                a.Email,
                b.Title
            };

            GMailer.GmailUsername = "******";
            GMailer.GmailPassword = "******";
            GMailer mailer = new GMailer();


            Parallel.ForEach(emails, e =>
            {
                mailer.ToEmail = e.Email;
                mailer.Subject = "BIBLIOTEKA - Zwrot książki";
                mailer.Body    = "Prosimy o zwrot książki '" + e.Title + "' !";
                mailer.IsHtml  = true;
                mailer.Send();
            });
            ViewBag.Mails1 = "Wysłano próśb " + emails.Count();

            var emails1 = from b in books
                          from o in borrows
                          from a in accounts
                          where o.BookID == b.BookID && a.AccountID == o.ReaderID && o.Returned == false && o.Return_date.Date == DateTime.Now.Date.AddDays(1)
                          select new
            {
                a.Email,
                b.Title
            };

            Parallel.ForEach(emails, e =>
            {
                mailer.ToEmail = e.Email;
                mailer.Subject = "BIBLIOTEKA - Przypomnienie o zwrocie książki!";
                mailer.Body    = "Został jeden dzień do zwrotu książki '" + e.Title + "' ! Po upływie czasu kara zastanie naliczona!";
                mailer.IsHtml  = true;
                mailer.Send();
            });

            ViewBag.Mails2 = "Wysłano przypomnień " + emails1.Count();

            return(View("Admin"));
        }
Ejemplo n.º 4
0
        // GET: Home
        public ActionResult Index()
        {
            NewsVM      vm        = new NewsVM();
            List <News> list_news = vm.Get_list().ToList();

            list_news.Reverse();
            ViewBag.News = list_news.Take(3);
            //-----
            AccountVM      userBL = new AccountVM();
            List <Account> list   = userBL.Get_list();

            return(View(list));
        }
Ejemplo n.º 5
0
        public ActionResult Activation()
        {
            AccountVM vm = new AccountVM();
            //var list = (from i in vm.Get_list()
            //            where i.Active==false
            //            select new Activa( i.AccountID, i.Name, i.Surname,  i.Active));
            var list = vm.Get_list().Where(x => x.Active == false);


            ViewBag.ac = list.ToList();

            return(View(list.ToList()));
        }
Ejemplo n.º 6
0
        public override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            DB             db = new DB();
            AccountVM      vm = new AccountVM();
            List <Account> userList;

            userList = vm.Get_list().Where(r => r.Role == Role.Reader).ToList();

            if (!userList.Any(u => u.Login == filterContext.HttpContext.User.Identity.Name))
            {
                //filterContext.Controller.TempData["Message"] = "Zaloguj się na konto z odpowiednimi uprawnieniami by poznać sekret ;) ";
                filterContext.Result = new RedirectToRouteResult(new RouteValueDictionary(new { controller = "Home", action = "Index" }));
            }
        }
Ejemplo n.º 7
0
        public ActionResult Add(Account p)
        {
            AccountVM      userBL = new AccountVM();
            List <Account> list   = userBL.Get_list();

            if (list.Any(x => x.Login == p.Login))
            {
                ViewBag.DuplicateMessage = "Taka nazwa już istnieje!";
                return(View("Add", p));
                //o co chodzi co ma być w account?
            }

            userBL.Dodaj(p);
            ViewBag.Succesmessage = "Rejestracja pomyślna!";
            return(RedirectToAction("Index", "Home"));
        }