Exemple #1
0
        private void loginButton_Click(object sender, EventArgs e)
        {
            try
            {
                Uzivatel uzivatel = us.getLoginUzivatele(prezdivkaBox.Text, hesloBox.Text);


                SessionSingleton.getInstance().setLoggedUser(uzivatel);
                prihlasenyUzivatelLabel.Text = "Jste přihlášen jako " + SessionSingleton.getInstance().getLoggedUser().Prezdivka;

                if (SessionSingleton.getInstance().isLogged())
                {
                    profilButton.Show();
                }
                if (SessionSingleton.getInstance().isLogged())
                {
                    panel1.Hide();
                }
                odhlasitButton.Show();
                kosikButton.Show();

                if (SessionSingleton.getInstance().isAdministrator())
                {
                    objednavkyButton.Show();
                }
            }
            catch (Exception ex)
            {
                prihlasenyUzivatelLabel.Text = "Neplatné přihlašovací údaje";
                SessionSingleton.getInstance().logOut();
            }
        }
        public IActionResult VytvoreniZpracovani(string autor, string text)
        {
            if (text == null || text.Trim().Length == 0)
            {
                return(RedirectToAction("Vytvoreni", "Poznamka"));
            }

            Uzivatel uzivatel = _context.Uzivatele
                                .Where(u => u.Jmeno == HttpContext.Session.GetString("Uzivatel"))
                                .FirstOrDefault();

            if (uzivatel != null)
            {
                DateTime aktualniCas = DateTime.UtcNow;

                _context.Poznamky.Add(new Poznamka {
                    Autor               = uzivatel,
                    Text                = text,
                    DatumVytvoreni      = aktualniCas,
                    DatumPosledniUpravy = aktualniCas
                });
                _context.SaveChanges();
            }

            return(RedirectToAction("Profil", "Uzivatel"));
        }
        public ActionResult Vytvorit(Uzivatel uzivatel, int skupinaId)
        {
            UzivatelDao uzivatelDao  = new UzivatelDao();
            Uzivatel    novyUzivatel = uzivatelDao.GetByLogin(uzivatel.Login);

            if (novyUzivatel != null)
            {
                TempData["error-message"] = "Uživatel s tímto uživ. jménem již existuje";
                return(RedirectToAction("PridatUzivatele"));
            }

            SkupinaDao skupinaDao = new SkupinaDao();
            Skupina    skupina    = skupinaDao.GetById(skupinaId);

            skupinaDao.CloseSession();

            UzivatelskaRoleDao uzivatelskaRoleDao = new UzivatelskaRoleDao();
            UzivatelskaRole    role = uzivatelskaRoleDao.GetRoleWithName("uzivatel");

            uzivatelskaRoleDao.CloseSession();

            Uzivatel admin = uzivatelDao.GetByLogin(User.Identity.Name);

            uzivatel.Skupina  = skupina;
            uzivatel.Vytvoril = admin;
            uzivatel.Role     = role;

            if (ModelState.IsValid)
            {
                uzivatelDao.CreateWithHashedPassword(uzivatel);
                TempData["message-success"] = "Uživatel úspěšne přidán";
            }

            return(RedirectToAction("Index", "Uzivatel"));
        }
        public ActionResult ZmenitHeslo(string stareHeslo, string noveHeslo, string noveHesloZnovu)
        {
            UzivatelDao uzivatelDao   = new UzivatelDao();
            Uzivatel    staryUzivatel = uzivatelDao.GetById(LoggedUser.Id);

            if (Crypto.VerifyHashedPassword(LoggedUser.Heslo, stareHeslo))
            {
                if (noveHeslo == noveHesloZnovu)
                {
                    staryUzivatel.Heslo = Crypto.HashPassword(noveHeslo);
                    uzivatelDao.Update(staryUzivatel);
                    Success("Heslo úspěšně změněno");
                }
                else
                {
                    Error("Nová hesla se neshodují");
                }
            }
            else
            {
                Error("Zadali jste špatné původní heslo");
            }

            return(RedirectToAction("ZmenaHesla"));
        }
        //
        // POST: /Account/LogOff
        public ActionResult LogOff()
        {
            AuthenticationManager.SignOut(DefaultAuthenticationTypes.ApplicationCookie);

            using (ModelContainer db = new ModelContainer())
            {
                //vyhledám přihlášeného uživatele
                int      idPrihlasenehoUzivatele = int.Parse(Session["uzivatelID"].ToString());
                Uzivatel prihlasenyUzivatel      = db.Uzivatele.Where(x => x.Id == idPrihlasenehoUzivatele).First();

                //změním datum a čas poslední aktivity uživatele
                //prihlasenyUzivatel.PosledniAktivita = DateTime.Now;

                //pouze upravuji hodnotu - upravím EntityState
                db.Entry(prihlasenyUzivatel).State = System.Data.Entity.EntityState.Modified;

                //uložím změny do databáze
                db.SaveChanges();
            }

            //ukončím Session
            Session.Abandon();

            return(RedirectToAction("Login"));
        }
Exemple #6
0
        public List <Model> SelectByUser(Uzivatel uzivatel)
        {
            List <Model> result = new List <Model>();

            using (var c = ConnetionFactory.GetOracleConnection())
            {
                using (var cmd = c.CreateCommand())
                {
                    try
                    {
                        cmd.CommandText = SELECT_ALL;
                        cmd.Parameters.Add(":id_uzivatel", uzivatel.Id);
                        OracleDataReader reader = cmd.ExecuteReader();
                        while (reader.Read())
                        {
                            int i = -1;
                            LesniHospodarskyCelek lesniHospodarskyCelek = new LesniHospodarskyCelek
                            {
                                Id  = reader.GetString(++i),
                                Kod = reader.GetString(++i),
                            };
                            result.Add(lesniHospodarskyCelek);
                        }
                        return(result);
                    }
                    catch (OracleException oe)
                    {
                        Log(oe.Message);
                        return(null);
                    }
                }
            }
        }
        public ActionResult Create(Uzivatel collection)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    var dao = new UzivatelDao();
                    collection.WindowsId = collection.WindowsId.ToUpper();
                    collection.Id        = (int)dao.Create(collection);
                    if (collection.Role.Id > 0)
                    {
                        var permDao = new PermissionDao();
                        permDao.Create(new Permission()
                        {
                            Role      = collection.Role,
                            WindowsId = collection.WindowsId
                        });
                    }

                    TempData[MessagesHelper.Success] = Resources.UzivatelTexts.UserAdded;
                    return(RedirectToAction("Index"));
                }
                else
                {
                    TempData[MessagesHelper.Warning] = "Zkontrolujte zadané údaje";
                }
            }
            catch
            {
                TempData[MessagesHelper.Warning] = "Zkontrolujte zadané údaje";
            }
            return(View(collection));
        }
        public IActionResult ZruseniZpracovani(int id, string heslo)
        {
            Uzivatel uzivatel = _context.Uzivatele
                                .Where(u => u.Id == id)
                                .FirstOrDefault();

            if (uzivatel == null)
            {
                return(RedirectToAction("Prihlaseni", "Uzivatel"));
            }

            if (!BCrypt.Net.BCrypt.Verify(heslo, uzivatel.Heslo))
            {
                return(RedirectToAction("Zruseni", "Uzivatel"));
            }

            Poznamka[] poznamky = _context.Poznamky
                                  .Where(p => p.Autor == uzivatel)
                                  .ToArray();

            _context.Poznamky
            .RemoveRange(poznamky);
            _context.Uzivatele
            .Remove(uzivatel);
            _context.SaveChanges();

            return(RedirectToAction("Odhlaseni", "Uzivatel"));
        }
Exemple #9
0
        public ActionResult Index()
        {
            UzivatelDao userDao = new UzivatelDao();
            Uzivatel    user    = userDao.GetByLogin(User.Identity.Name);

            return(View(user));
        }
Exemple #10
0
        public ActionResult Index(int?strana)
        {
            UzivatelDao uzivatelDao = new UzivatelDao();
            Uzivatel    uzivatel    = uzivatelDao.GetByLogin(User.Identity.Name);
            SkupinaDao  skupinaDao  = new SkupinaDao();

            int page = strana.HasValue ? strana.Value : 1;
            int totalItems;

            IList <Skupina> skupiny = skupinaDao.GetMyGroupsPaged(LoggedUser, ItemsOnPage, page, out totalItems);

            ViewBag.Pages       = (int)Math.Ceiling((double)totalItems / (double)ItemsOnPage);
            ViewBag.CurrentPage = page;

            ViewBag.ListJePrazdny = false;

            if (skupiny.Count == 0)
            {
                ViewBag.ListJePrazdny = true;
            }

            ViewBag.MeSkupiny = skupiny;

            return(View());
        }
        /// <summary>
        /// Upraí všetky hodnoty Užívateľa podľa zadaného id
        /// </summary>
        /// <param name="updatedUzivatel"></param>
        /// <returns></returns>
        public async Task <ServiceResponse <GetUzivatelDto> > UpdateUzivatel(UpdateUzivatelDto updatedUzivatel)
        {
            ServiceResponse <GetUzivatelDto> serviceResponse = new ServiceResponse <GetUzivatelDto>();

            try
            {
                Uzivatel uzivatel = await _context.Uzivatelia.FirstOrDefaultAsync(c => c.Id == updatedUzivatel.Id);

                if (updatedUzivatel.Email != null)
                {
                    uzivatel.Email = updatedUzivatel.Email;
                }

                if (updatedUzivatel.TelefonneCislo != null)
                {
                    uzivatel.TelefonneCislo = updatedUzivatel.TelefonneCislo;
                }

                await _context.SaveChangesAsync();

                serviceResponse.Data = _mapper.Map <GetUzivatelDto>(uzivatel);
            }
            catch (Exception ex)
            {
                serviceResponse.Success = false;
                serviceResponse.Message = ex.Message;
            }

            return(serviceResponse);
        }
        public override bool Update(Model obj)
        {
            Uzivatel ins = (Uzivatel)obj;

            using (var c = ConnetionFactory.GetOracleConnection())
            {
                using (var cmd = c.CreateCommand())
                {
                    try
                    {
                        cmd.CommandText = UPDATE;
                        cmd.Parameters.Add(":username", ins.Username);
                        cmd.Parameters.Add(":pass_sha256", ins.Password);
                        cmd.Parameters.Add(":role", ins.Role);
                        cmd.Parameters.Add(":jmeno", ins.Jmeno);
                        cmd.Parameters.Add(":email", ins.Email);
                        cmd.Parameters.Add(":id", ins.Id);
                        cmd.ExecuteNonQuery();
                        return(true);
                    }
                    catch (OracleException oe)
                    {
                        Log(oe.Message);
                        return(false);
                    }
                }
            }
        }
Exemple #13
0
        public new IList <UkolVedeni> GetOnlyDeleted(Uzivatel user) //POUŽÍVAT POUZE PRO LOP, SUBUKOL, UKOLVEDENI, UKOLODDELENI, UKOLVZORKOVANI
        {
            return(Session.CreateCriteria <UkolVedeni>()

                   .CreateAlias("Zadavatel", "zadavatel")
                   .CreateAlias("Resitel", "resitel")

                   //.SetProjection(Projections.Distinct(Projections.ProjectionList())) //DISTINCT ??

                   .Add(Restrictions.Eq("Deleted", true)) //smazané

                   /*
                    * .Add(Restrictions.Disjunction()
                    *  .Add(Restrictions.Eq("subUkoly.Deleted", true)) //nesmazané subúkoly
                    *  .Add(Restrictions.IsNull("subUkoly.Deleted")) //nesmazané subúkoly
                    * )
                    */

                   .Add(

                       Restrictions.Disjunction()                                                                                             //začátek disjunkce

                       .Add(Restrictions.Eq("Zadavatel", user)).Add(Restrictions.Eq("Resitel", user))                                         //jde o toho uzivatele
                       .Add(Restrictions.Eq("zadavatel.Oddeleni", user.Oddeleni)).Add(Restrictions.Eq("resitel.Oddeleni", user.Oddeleni))     //jde o stejné oddělení

                       .Add(Restrictions.Eq("subUkoly.Zadavatel", user)).Add(Restrictions.Eq("subUkoly.Resitel", user))                       //jde o stejné oddělení subúkolu
                       .Add(Restrictions.Eq("suZadavatel.Oddeleni", user.Oddeleni)).Add(Restrictions.Eq("suResitel.Oddeleni", user.Oddeleni)) //jde o stejné oddělení subúkolu


                       )                                                            //konec disjunkce

                   .SetResultTransformer(new DistinctRootEntityResultTransformer()) //DISTINCT .. tohle jediný na tom bylo lehký..

                   .List <UkolVedeni>());
        }
Exemple #14
0
        // GET: Home
        public ActionResult Index()
        {
            if (!Uzivatel.UserExists(User.Identity.Name))
            {
                TempData[MessagesHelper.Info] = Resources.HomeTexts.NotAuthorized;
                return(RedirectToAction("About", "Home"));
            }

            var me = new Uzivatel(User.Identity.Name);  // 1. naštení 28ms

            var me2 = new Uzivatel(User.Identity.Name); // 2. 6ms - jak? jsem frajer..... Jarda

            /*var lops = new LopDao().GetAll(uziv);
             * var ukolved = new UkolVedeniDao().GetAll(uziv);
             * var ukoloddel = new UkolOddeleniDao().GetAll(uziv);
             * var ukolvzork = new UkolVzorkovaniDao().GetAll(uziv);
             *
             * return View(new HomeCollection(lops, ukoloddel, ukolved, ukolvzork));
             */
            var lopDao = new LopDao();

            ViewBag.lopMeAsZadavatel = lopDao.GetAll();
            ViewBag.lopMeAsResitel   = lopDao.GetAll();
            return(View());
        }
Exemple #15
0
        protected override Uzivatel select(Uzivatel uzivatel)          //login
        {
            Database db = new Database();

            db.Connect();
            OracleCommand cmd = db.CreateCommand(SELECT);

            cmd.Parameters.Add("uzivatelId", uzivatel.UzivatelId);

            OracleDataReader readshit = db.Select(cmd);

            readshit.Read();
            Uzivatel tmp = new Uzivatel();

            tmp.Heslo = readshit.GetString(2);
            if (BCrypt.Net.BCrypt.Verify(uzivatel.Heslo, tmp.Heslo))
            {
                tmp.UzivatelId    = readshit.GetInt32(0);
                tmp.Nick          = readshit.GetString(1);
                tmp.Email         = readshit.GetString(3);
                tmp.DatumNarozeni = readshit.GetDateTime(4);
                tmp.Ban           = readshit.GetInt32(5);
                tmp.ObecId        = readshit.GetInt32(6);
            }
            else
            {
                readshit.Close();
                db.Close();
                return(null);
            }

            readshit.Close();
            db.Close();
            return(tmp);
        }
Exemple #16
0
        public async Task <IActionResult> Edit(int id, [Bind("idUzivatele,jmeno,prijmeni,stredisko,email,idJazyka,nt,heslo")] Uzivatel uzivatel)
        {
            ViewData["adminVolba"] = 5;
            if (id != uzivatel.idUzivatele)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(uzivatel);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!UzivatelExists(uzivatel.idUzivatele))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }

            return(View(UzivateleServ.getUzivatelFillViewModel(_context, uzivatel)));
        }
        public void TestPrihazovani()
        {
            DateTime datum = DateTime.Now;
            Auto     a     = new Auto("bmw", Skupina.A, datum, 650, 3);
            Drazba   d     = new Drazba(a, "popis");

            DatabazeUzivatelu db = DatabazeUzivatelu.Instance;
            //var setValidator = new SimpleSetValidator(db.uzivatele);
            Uzivatel u = new Uzivatel("karel", "Lilecek1", "*****@*****.**", "Pri 25", "605 897 123");
            Nabidka  n = new Nabidka(u, 50);

            d.pridej(n);

            Assert.AreEqual(n, d.prihozy.Peek());

            Nabidka mensi = new Nabidka(u, 15);

            d.pridej(mensi);

            Assert.AreEqual(n, d.prihozy.Peek());
            Assert.AreEqual(1, d.prihozy.Count);

            Nabidka vetsi = new Nabidka(u, 150);

            d.pridej(vetsi);

            Assert.AreEqual(vetsi, d.prihozy.Peek());
            Assert.AreEqual(2, d.prihozy.Count);
        }
        public ActionResult PridatKontakt(String prezdivkaUzivatele)
        {
            using (ModelContainer db = new ModelContainer())
            {
                //existuje hledány uživatel?
                bool existujeUzivatel = db.Uzivatele.Any(x => x.Prezdivka == prezdivkaUzivatele);

                if (existujeUzivatel)
                {
                    //pokud uživatel existuje
                    Uzivatel hledanyUzivatel = db.Uzivatele.Where(x => x.Prezdivka == prezdivkaUzivatele).First();

                    //zašlu první oznamovací zprávu - tím se mi zobrazí v kontaktech
                    Zprava prvniZprava = new Zprava();
                    prvniZprava.Text           = "Pozdravte uživatele " + hledanyUzivatel.Prezdivka + "!";
                    prvniZprava.UzivatelKomuId = int.Parse(Session["uzivatelID"].ToString());
                    prvniZprava.UzivatelOdId   = hledanyUzivatel.Id;
                    prvniZprava.CasOdeslani    = DateTime.Now;

                    //vložím první zprávu
                    db.Zpravy.Add(prvniZprava);

                    //uložím změny
                    db.SaveChanges();

                    return(Json(new { success = true }, JsonRequestBehavior.AllowGet));
                }
                else //uživatel s danou přezdívkou neexistuje
                {
                    //vrátím informaci o neúspěšné operaci přidání kontaktu
                    return(Json(new { success = false, responseText = "Uživatel se zadanou přezdívkou neexistuje!" }, JsonRequestBehavior.AllowGet));
                }
                //return View("Index", new RouteValueDictionary(new { controller = "Zprava", action = "Index", idUzivatele = int.Parse(Session["aktualniKontakt"].ToString()) }));
            }
        }
Exemple #19
0
        public async Task <IActionResult> Index([Bind("idUzivatele,jmeno,prijmeni,stredisko,email,idJazyka,nt,heslo")] Uzivatel uzivatel)
        {
            ViewData["mainVolba"] = 3;

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(uzivatel);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!UzivatelExists(uzivatel.idUzivatele))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }


                ViewBag.uspesne = "Úspěšně uloženo";
            }

            return(View(UzivateleServ.getUzivatelFillViewModel(_context, uzivatel)));
        }
Exemple #20
0
        public ActionResult Update(Uzivatel u)
        {
            UzivatelDao ud  = new UzivatelDao();
            AdresaDao   ad  = new AdresaDao();
            PscDao      pd  = new PscDao();
            PSC         psc = pd.FindPsc(u.adresa.psc.psc);

            if (psc != null)
            {
                u.adresa.psc = psc;
            }
            else
            {
                pd.Create(u.adresa.psc);
            }
            Adresa adresa = ad.FindAdresa(u.adresa.mesto, u.adresa.ulice, u.adresa.cp, u.adresa.psc);

            if (adresa != null)
            {
                u.adresa = adresa;
            }
            else
            {
                ad.Create(u.adresa);
            }
            u.prava = u.prava;
            ud.Update(u);
            TempData["x"] = "Profil upraven";
            return(RedirectToAction("Index", "Profil"));
        }
        public void Login_ClickedCommand(object param)
        {
            Uzivatel u = new Uzivatel();

            u.Username = Username;
            u.Password = Password;

            var      uzivatelModule = new UzivatelTableModule(db);
            Uzivatel sgn            = uzivatelModule.TrySignIn(u);

            if (sgn != null && sgn.Role == 2)
            {
                MainWindow main = new MainWindow(sgn);

                main.Show();
                Close();
            }
            else if (sgn != null && sgn.Role != 2)
            {
                MessageBox.Show("Přihlášení selhalo. Nejste registrován/a jako lesní hospodář.");
            }
            else
            {
                MessageBox.Show("Přihlášení selhalo. Zkontrolujte prosím své přihlašovací údaje.");
            }
        }
        public ActionResult UpravitInformace()
        {
            UzivatelDao uzivatelDao = new UzivatelDao();
            Uzivatel    uzivatel    = uzivatelDao.GetById(LoggedUser.Id);

            return(View(uzivatel));
        }
Exemple #23
0
        protected override List <Uzivatel> select()
        {
            Database db = new Database();

            db.Connect();
            OracleCommand    cmd      = db.CreateCommand(SELECT_ALL);
            List <Uzivatel>  vystup   = new List <Uzivatel>();
            OracleDataReader readshit = db.Select(cmd);

            while (readshit.Read())
            {
                Uzivatel tmp = new Uzivatel();
                tmp.Heslo         = readshit.GetString(2);
                tmp.UzivatelId    = readshit.GetInt32(0);
                tmp.Nick          = readshit.GetString(1);
                tmp.Email         = readshit.GetString(3);
                tmp.DatumNarozeni = readshit.GetDateTime(4);
                tmp.Ban           = readshit.GetInt32(5);
                tmp.ObecId        = readshit.GetInt32(6);
                vystup.Add(tmp);
            }

            readshit.Close();
            db.Close();
            return(vystup);
        }
        public override bool ValidateUser(string username, string password)
        {
            UzivatelDao userDao = new UzivatelDao();
            Uzivatel    user    = userDao.GetByLoginAndPassword(username, password);

            return(user != null);
        }
Exemple #25
0
        //vypíše všechny články na požadované stránce
        public ActionResult Index(int cisloStranky = 1)
        {
            //uložím si hodnotu aktuální stránky pro výpis ve view
            Session["aktualniStranka"] = cisloStranky;

            //seznam který naplním články z databáze dle čísla stránky
            var seznamClanku = new List <Clanek>();

            using (ModelContainer db = new ModelContainer())
            {
                //přeskočím články které jsou na předcházejích stránkách pomocí Skip
                seznamClanku = db.Clanky.Include(x => x.Autor).OrderByDescending(x => x.DatumVytvoreni).Skip((cisloStranky - 1) * POCET_CLANKU).Take(POCET_CLANKU).ToList();

                //zjistím maximální počet stránek dle počtu článků
                double maxPocetStranek = db.Clanky.Count() / POCET_CLANKU;

                //uložím maximální počet stránek do Session, pomocí metody Ceiling zaokrouhlím nahoru
                Session["maxPocetStranek"] = Math.Ceiling(maxPocetStranek);

                //zjistím nový počet nepřečtených zpráv
                int      idPrihlaseneho         = int.Parse(Session["uzivatelID"].ToString());
                Uzivatel prihlasenyUzivatel     = db.Uzivatele.Where(x => x.Id == idPrihlaseneho).First();
                var      pocetNeprectenychZprav = db.Zpravy.Where(x => x.UzivatelKomuId == prihlasenyUzivatel.Id).Where(x => x.CasOdeslani > prihlasenyUzivatel.PosledniAktivita).ToList();
                Session["neprecteneZpravy"] = pocetNeprectenychZprav.Count();

                //vrátím seznam do View
                return(View(seznamClanku));
            }
        }
Exemple #26
0
        public ActionResult Index(HttpPostedFileBase file)
        {
            using (ModelContainer db = new ModelContainer())
            {
                //ověření typu souboru
                if (!JeValidniTyp(file.ContentType))
                {
                    TempData["ChybaNahraniSouboru"] = "Je možné nahrát pouze JPG, JPEG, PNG.";
                    return(RedirectToAction("Index"));
                }
                //ověření zda je něco nahráváno
                else if (file.ContentLength == 0)
                {
                    TempData["ChybaNahraniSouboru"] = "Nelze nahrát NIC.";
                    return(RedirectToAction("Index"));
                    //ověření zda není překročena maximální velikost
                }
                else if (!JeValidniVelikost(file.ContentLength))
                {
                    TempData["ChybaNahraniSouboru"] = "Velikost souboru překročila povolenou velikost " + MAX_VELIKOST_SOUBORU + "MB.";
                    return(RedirectToAction("Index"));
                }
                //vše prošlo - nahraji soubor
                else
                {
                    var fileName = Path.GetFileName(file.FileName);
                    var path     = Path.Combine(Server.MapPath("/Images/upload"), fileName);


                    int      idPrihlasenyUzivatel = int.Parse(Session["uzivatelID"].ToString());
                    Uzivatel prihlasenyUzivatel   = db.Uzivatele.Where(x => x.Id == idPrihlasenyUzivatel).First();


                    //uložím nový soubor
                    file.SaveAs(path);

                    //přejmenuji nové nahraný soubor do potřebné podoby - přejmenuji dle názvu uživatele
                    String novyNazev = prihlasenyUzivatel.Prezdivka + Path.GetExtension(path);

                    //smažu uživateli starou profilovou fotku
                    if (System.IO.File.Exists(@"C:\Users\krajt\Desktop\DiplomPrace\DiplomovaPrace" + prihlasenyUzivatel.Avatar))
                    {
                        System.IO.File.Delete(@"C:\Users\krajt\Desktop\DiplomPrace\DiplomovaPrace" + prihlasenyUzivatel.Avatar);
                    }

                    //přejmenuji novou profilovou fotku - zajištění jedinečnosti názvu fotky
                    System.IO.File.Move(Path.Combine(Server.MapPath("/Images/upload"), fileName), Path.Combine(Server.MapPath("/Images/upload"), novyNazev));

                    //upravím adresu k profilové fotce uživatele
                    prihlasenyUzivatel.Avatar = "/Images/upload/" + prihlasenyUzivatel.Prezdivka + Path.GetExtension(path);

                    //uložím změny
                    db.SaveChanges();

                    //přesměruji na Index view [httpget] tohoto controlleru
                    return(RedirectToAction("Index"));
                }
            }
        }
Exemple #27
0
        public Uzivatel getUzivatel(int param)
        {
            //UzivatelGateway uzivatelGateway = new UzivatelFinder().SelectId(param);
            IUzivatelGateway uzivatelGateway = finder.SelectId(param);
            Uzivatel         uzivatel        = new Uzivatel(uzivatelGateway);

            return(uzivatel);
        }
        public MainWindow(Uzivatel uzivatel)
        {
            var vm = new MainWindowViewModel(((App)App.Current).StorageContext, uzivatel);

            vm.OnRequestClose += (s, e) => this.Close();
            DataContext        = vm;
            InitializeComponent();
        }
Exemple #29
0
 public CustomTableSetting Get(Uzivatel u, string tableName, string collumn)
 {
     return(Session.CreateCriteria <CustomTableSetting>()
            .Add(Restrictions.Eq("Uzivatel", u))
            .Add(Restrictions.Eq("Tabulka", tableName))
            .Add(Restrictions.Eq("Sloupec", collumn))
            .UniqueResult <CustomTableSetting>());
 }
Exemple #30
0
 public IList <Notifikace> GetByUser(Uzivatel uzivatel, bool seen = true)
 {
     return(Session.CreateCriteria <Notifikace>()
            .AddOrder(Order.Desc("Created"))
            .Add(Restrictions.Eq("Seen", seen))
            .Add(Restrictions.Eq("Uzivatel", uzivatel))
            .List <Notifikace>());
 }