예제 #1
0
        public Main_Page(Frame frame1, BibliotekaEntities db)
        {
            InitializeComponent();

            this.frame1 = frame1;
            this.db     = db;
        }
예제 #2
0
        public static List <Models.Book.Rental> GetRentalList()
        {
            List <Models.Book.Rental> list = new List <Models.Book.Rental>();
            int userId = Services.UserMethods.GetUserID(System.Web.HttpContext.Current.User.Identity.Name);

            try
            {
                using (BibliotekaEntities db = new BibliotekaEntities())
                {
                    var rental = db.Wypozyczenia.ToList().Where(x => x.idUzytkownika == userId && x.idStatusu == 1);


                    foreach (var x in rental)
                    {
                        list.Add(
                            new Models.Book.Rental
                        {
                            idWypozyczenia     = x.idWypozyczenia,
                            tytul              = x.Ksiazki.tytul,
                            autor              = x.Ksiazki.Autorzy.imie + " " + x.Ksiazki.Autorzy.nazwisko,
                            terminWypozyczenia = x.terminWypozyczenia,
                            terminZwrotu       = x.terminZwrotu,
                            status             = x.Statusy_Wypozyczen.status
                        });
                    }
                }
            }
            catch (Exception ex)
            { }

            return(list);
        }
예제 #3
0
        public static List <Models.Book.Rental> GetUsersRentalList()
        {
            List <Models.Book.Rental> list = new List <Models.Book.Rental>();


            try
            {
                using (BibliotekaEntities db = new BibliotekaEntities())
                {
                    //var rental = db.Wypozyczenia.ToList().Where(x => x.idUzytkownika == userId);
                    var rental = db.Wypozyczenia.ToList();


                    foreach (var x in rental)
                    {
                        list.Add(
                            new Models.Book.Rental
                        {
                            login              = x.Uzytkownicy.login,
                            idWypozyczenia     = x.idWypozyczenia,
                            tytul              = x.Ksiazki.tytul,
                            autor              = x.Ksiazki.Autorzy.imie + " " + x.Ksiazki.Autorzy.nazwisko,
                            terminWypozyczenia = x.terminWypozyczenia,
                            terminZwrotu       = x.terminZwrotu,
                            status             = x.Statusy_Wypozyczen.status
                        });
                    }
                }
            }
            catch (Exception ex)
            { }

            return(list);
        }
예제 #4
0
        public static Models.Book.Rental GetBookDetails(int id)
        {
            List <Models.Book.Rental> list = new List <Models.Book.Rental>();

            try
            {
                using (BibliotekaEntities db = new BibliotekaEntities())
                {
                    //var rental = db.Wypozyczenia.ToList().Where(x => x.idWypozyczenia == id);
                    var rental = db.Wypozyczenia.FirstOrDefault(k => k.idWypozyczenia == id);

                    return(new Models.Book.Rental
                    {
                        idWypozyczenia = id,
                        tytul = rental.Ksiazki.tytul,
                        opis = rental.Ksiazki.opis,
                        autor = rental.Ksiazki.Autorzy.imie + " " + rental.Ksiazki.Autorzy.nazwisko,
                        gatunek = rental.Ksiazki.Gatunki.gatunek,
                        terminWypozyczenia = rental.terminWypozyczenia,
                        terminZwrotu = rental.terminZwrotu,
                        status = rental.Statusy_Wypozyczen.status
                    });
                }
            }
            catch (Exception ex)
            { }

            return(null);
        }
예제 #5
0
        public static Models.RegisterViewModel GetUser(int ID)
        {
            try
            {
                using (BibliotekaEntities db = new BibliotekaEntities())
                {
                    var user = db.Uzytkownicy.FirstOrDefault(f => f.idUzytkownika == ID);

                    if (user != null)
                    {
                        return(new Models.RegisterViewModel
                        {
                            idUzytkownika = user.idUzytkownika,
                            login = user.login,
                            imie = user.imie,
                            nazwisko = user.nazwisko,
                            email = user.email,
                            adres = user.adres,
                            miasto = user.miasto,
                            kodPocztowy = user.kodPocztowy,
                            rola = user.Role.rola
                        });
                    }
                }
            }
            catch (Exception ex)
            { }
            return(null);
        }
예제 #6
0
        public static Models.Book.DetailsBookViewModel GetBook(int id)
        {
            try
            {
                using (BibliotekaEntities db = new BibliotekaEntities())
                {
                    var book = db.Ksiazki.FirstOrDefault(k => k.idKsiazki == id);

                    if (book != null)
                    {
                        return(new Models.Book.DetailsBookViewModel
                        {
                            tytul = book.tytul,
                            opis = book.opis,
                            iloscStron = book.iloscStron,
                            dataWydania = book.dataWydania,
                            ilosc = book.ilosc,
                            gatunek = book.Gatunki.gatunek,
                            autor = book.Autorzy.imie + " " + book.Autorzy.nazwisko
                        });
                    }
                }
            }
            catch (Exception ex)
            { }

            return(null);
        }
        public Page_dodaj_klienta(Frame frame1, BibliotekaEntities db)
        {
            InitializeComponent();

            this.frame1 = frame1;
            this.db     = db;
        }
예제 #8
0
        public ActionResult Login(LoginViewModel model)
        {
            if (ModelState.IsValid)
            {
                using (var db = new BibliotekaEntities())
                {
                    var Verify = db.Uzytkownicy.FirstOrDefault(user => user.login == model.login);
                    if (Verify == null)
                    {
                        ViewBag.Error = "Niepoprawny login lub hasło.";
                    }
                    else if (Verify.czyAktywny == false)
                    {
                        ViewBag.Error = "Konto jest dezaktywowane.";
                    }
                    else
                    {
                        model.hash = new Services.Authentication().GenerateHash(model.haslo);
                        if (Verify.haslo == model.hash)
                        {
                            FormsAuthentication.SignOut();
                            Session.Abandon();

                            Session["imie"]          = Verify.login;
                            Session["email"]         = Verify.email;
                            Session["IdUzytkownika"] = Verify.idUzytkownika;

                            //FormsAuthentication.SetAuthCookie(Verify.u_login, model.remember);
                            // https://stackoverflow.com/questions/1385042/asp-net-mvc-forms-authentication-authorize-attribute-simple-roles link
                            var authTicket = new FormsAuthenticationTicket(
                                1,                                                                     // version
                                model.login,                                                           // user name
                                DateTime.Now,                                                          // created
                                DateTime.Now.AddMinutes(30),                                           // expires
                                model.remember,                                                        // persistent?
                                Models.Roles.GetRole(Verify.idRoli)                                    // can be used to store roles
                                );

                            string encryptedTicket = FormsAuthentication.Encrypt(authTicket);

                            var authCookie = new HttpCookie(FormsAuthentication.FormsCookieName, encryptedTicket);
                            System.Web.HttpContext.Current.Response.Cookies.Add(authCookie);

                            //ViewBag.Error = "Zalogowano!";
                            return(RedirectToAction("Index", "Home"));
                        }
                        else
                        {
                            ViewBag.Error = "Niepoprawne logowanie";
                        }
                    }
                }
            }
            return(View(model));
        }
예제 #9
0
 public static bool checkEmail(string email)
 {
     using (BibliotekaEntities db = new BibliotekaEntities())
     {
         var Verify = db.Uzytkownicy.FirstOrDefault(user => user.email == email);
         if (Verify == null)
         {
             return(false);
         }
         else
         {
             return(true);
         }
     }
 }
예제 #10
0
 //BibliotekaEntities db = new BibliotekaEntities();
 public static bool checkLogin(string login) // true jak istanieje w bazie
 {
     using (BibliotekaEntities db = new BibliotekaEntities())
     {
         var Verify = db.Uzytkownicy.FirstOrDefault(user => user.login == login);
         if (Verify == null)
         {
             return(false);
         }
         else
         {
             return(true);
         }
     }
 }
예제 #11
0
        public Page_edytuj_usun_klient(ClientInfo clientInfo1, Frame frame1, BibliotekaEntities db)
        {
            InitializeComponent();

            this.clientInfo1 = clientInfo1;
            this.frame1      = frame1;
            this.db          = db;


            txt_name.Text     = this.clientInfo1.Firstname.ToString();
            txt_surename.Text = this.clientInfo1.Surename.ToString();
            txt_nrPhone.Text  = this.clientInfo1.NrPhone.ToString();
            txt_info.Text     = this.clientInfo1.Info.ToString();

            client1 = db.Clients.Find(clientInfo1.IdClient);
        }
예제 #12
0
        public ClientPage(Frame frame1, BibliotekaEntities db)
        {
            InitializeComponent();
            this.frame1 = frame1;
            this.db     = db;


            var linqClient = from x in db.Clients
                             join y in db.clientQuantity on x.IdClient equals y.IdClient
                             select new ClientInfo {
                Firstname = x.Firstname, Surename = x.Surename, IdClient = x.IdClient, NrPhone = x.NrPhone, Info = x.Info, quantity = y.quantity.ToString()
            };


            listView.ItemsSource = linqClient.ToList();
            lbl_ilosc.Content    = listView.Items.Count;
        }
예제 #13
0
        public static int GetUserID(string login)
        {
            try
            {
                using (BibliotekaEntities db = new BibliotekaEntities())
                {
                    var user = db.Uzytkownicy.FirstOrDefault(f => f.login == login && (f.czyAktywny == true));

                    if (user != null)
                    {
                        return(user.idUzytkownika);
                    }
                }
            }
            catch (Exception ex)
            { }
            return(0);
        }
예제 #14
0
        public static string GetRole(int id)
        {
            try
            {
                using (BibliotekaEntities db = new BibliotekaEntities())
                {
                    var role = db.Role.FirstOrDefault(x => x.idRoli == id);

                    if (role != null)
                    {
                        return(role.rola);
                    }
                }
            }
            catch (Exception ex)
            { }
            return(null);
        }
예제 #15
0
        public ActionResult Index()
        {
            BibliotekaEntities db = new BibliotekaEntities();

            return(View(db.Ksiazki.ToList().OrderByDescending(ksiazka => ksiazka.idKsiazki).Where(a => a.czyAktywna == true).Take(5)));
        }