Exemple #1
0
 // GET: Clanovi/Edit/5
 public ActionResult Edit(int?id)
 {
     try
     {
         if (id == null)
         {
             return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
         }
         Clanovi clanovi = db.Clanovi.Find(id);
         if (clanovi == null)
         {
             return(HttpNotFound());
         }
         return(View(clanovi));
     }
     catch (SqlException se)
     {
         ViewBag.DuplicateMessage = "Унето корисничко име / e-mail је већ регистровано у бази, унесите ново.";
         return(View("Edit"));
     }
     catch (Exception Stana)
     {
         ViewBag.SQLMessage = Stana.Message.ToString();
         return(View("Edit"));
     }
 }
Exemple #2
0
        public ActionResult Login(Clanovi clan)
        {
            //ako su u bazi hash passwords:
            //clan.Lozinka = Encrypt.GetMD5Hash(clan.Lozinka);

            using (ProjekatEntities db = new ProjekatEntities())
            {
                var user = db.Clanovi.SingleOrDefault(u => u.KorisnickoIme == clan.KorisnickoIme && u.Lozinka == clan.Lozinka);


                if (user != null)
                {
                    Session["KorisnickoIme"] = user.KorisnickoIme.ToString();
                    Session["Lozinka"]       = user.Lozinka.ToString();
                    Session["Email"]         = user.Email.ToString();
                    Session["Uloga"]         = user.Uloga.ToString();
                    return(RedirectToAction("Index", "Home"));
                }
                else
                {
                    ModelState.AddModelError("", "Pogresno korisnicko ime ili lozinka");
                }
            }
            return(View());
        }
Exemple #3
0
        public IHttpActionResult PostClan(Clanovi clan)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.Clanovi.Add(clan);
            db.SaveChanges();



            var noviClan = new ApiModel.ClanoviApi()
            {
                //ClanID = clan.ClanID,
                Ime           = clan.Ime,
                Prezime       = clan.Prezime,
                KorisnickoIme = clan.KorisnickoIme,
                Status        = clan.Status,
                Lozinka       = clan.Lozinka,
                Email         = clan.Email,
                Uloga         = clan.Uloga
            };

            return(CreatedAtRoute("DefaultApi", new { id = clan.ClanID }, clan));
        }
        public IActionResult Unos_novog(Clanovi clanovi)
        {
            Clanovi c = clanovi;

            if (c.ClanId.Equals(null))
            {
            }
            if (ModelState.IsValid)
            {
                db.Clanovi.Add(c);
                db.SaveChanges();

                List <Clanovi> clanoviList = findClanovi();
                ViewBag.Clanovi = clanoviList;

                return(ClanoviView());
            }
            List <Svojstvo> svojstva = findSvojstva();

            ViewBag.Svojstva = svojstva;

            List <Grupa> grupe = findGrupa();

            ViewBag.Grupe = grupe;

            return(View(c));
        }
Exemple #5
0
        public ActionResult DeleteConfirmed(int id)
        {
            Clanovi clanovi = db.Clanovi.Find(id);

            db.Clanovi.Remove(clanovi);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Exemple #6
0
 public ActionResult Edit([Bind(Include = "ClanID,ImePrezime,Email,Status,KorisnickoIme,Lozinka")] Clanovi clanovi)
 {
     if (ModelState.IsValid)
     {
         db.Entry(clanovi).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(clanovi));
 }
 public ActionResult Edit(Clanovi clanovi)
 {
     if (ModelState.IsValid)
     {
         db.Entry(clanovi).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(clanovi));
 }
Exemple #8
0
 public ActionResult Edit(Clanovi clanovi)
 {
     if (ModelState.IsValid)
     {
         db.Entry(clanovi).State = EntityState.Modified;
         db.SaveChanges();
         Session["Email"] = db.Clanovi.Find(clanovi.ClanID).Email.ToString();
         return(RedirectToAction("Index"));
     }
     return(View(clanovi));
 }
Exemple #9
0
        public ActionResult Create([Bind(Include = "ClanID,ImePrezime,Email,Status,KorisnickoIme,Lozinka")] Clanovi clanovi)
        {
            if (ModelState.IsValid)
            {
                db.Clanovi.Add(clanovi);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(clanovi));
        }
Exemple #10
0
 public ActionResult Edit([Bind(Include = "ClanID,Ime,Prezime,Email,Status,KorisnickoIme,Lozinka,Uloga")] Clanovi clanovi)
 {
     if (ModelState.IsValid)
     {
         //ako se u bazu upisuje hash password:
         //clanovi.Lozinka = Encrypt.GetMD5Hash(clanovi.Lozinka);
         db.Entry(clanovi).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(clanovi));
 }
Exemple #11
0
        // GET: Promena/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Clanovi clanovi = db.Clanovi.Find(id);

            if (clanovi == null)
            {
                return(HttpNotFound());
            }
            return(View(clanovi));
        }
Exemple #12
0
        public void BrisiClana(int sifra)
        {
            foreach (int k in vratiClanaSaSifrom(sifra).Iznajmljene_knjige)
            {
                foreach (Knjiga k2 in Knjige)
                {
                    if (k == k2.Sifra_knjige)
                    {
                        k2.Iznajmljena = false;
                    }
                }
            }
            int vel = Clanovi.Count;

            Clanovi.RemoveAll(x => x.Sifra == sifra);
            if (vel == Clanovi.Count)
            {
                throw new Exception("Nije pronadjena osoba.");
            }
        }
Exemple #13
0
        public ActionResult Registration(Clanovi clan)
        {
            using (NNVContext context = new NNVContext())
            {
                //ovo sam nesto probao preko operatora upita ali nisam istestirao da li radi;
                //var KorisnickoIme = from c in context.Clanovi
                //                    where c.KorisnickoIme == clan.KorisnickoIme
                //                    select c;
                //var Email = from c in context.Clanovi
                //            where c.Email == clan.Email
                //            select c;
                //if(KorisnickoIme!=null)
                //{
                //    ViewBag.DuplicateMessage = "Унето корисничко име је већ регистровано у бази, унесите ново.";
                //    return View("Registration", clan);
                //}
                //if(Email != null)
                //{
                //    ViewBag.SameMailMessage = "Унети E-mail је већ регистрован у бази, унесите нови.";
                //    return View("Registration", clan);
                //}
                //context.Clanovi.Add(clan);
                //context.SaveChanges();

                if (context.Clanovi.Any(x => x.KorisnickoIme == clan.KorisnickoIme))
                {
                    ViewBag.DuplicateMessage = "Унето корисничко име је већ регистровано у бази, унесите ново.";
                    return(View("Registration", clan));
                }
                if (context.Clanovi.Any(x => x.Email == clan.Email))
                {
                    ViewBag.SameMailMessage = "Унети E-mail је већ регистрован у бази, унесите нови.";
                    return(View("Registration", clan));
                }
                context.Clanovi.Add(clan);
                context.SaveChanges();
            }
            ModelState.Clear();
            ViewBag.SuccessMessage = "Успешна регистрација!";
            return(View("Registration", new Clanovi()));
        }
Exemple #14
0
 public ActionResult Edit([Bind(Include = "ClanID,ImePrezime,Email,Status,KorisnickoIme,Lozinka")] Clanovi clanovi)
 {
     try
     {
         if (ModelState.IsValid)
         {
             db.Entry(clanovi).State = EntityState.Modified;
             db.SaveChanges();
             return(RedirectToAction("AdminPageView"));
         }
         return(View(clanovi));
     }
     catch (SqlException se)
     {
         ViewBag.DuplicateMessage = "Унето корисничко име / e-mail је већ регистровано у бази, унесите ново.";
         return(View("Edit"));
     }
     catch (Exception ex)
     {
         ViewBag.SQLMessage = ex.Message.ToString();
         return(View("Edit"));
     }
 }
Exemple #15
0
        public void RegistrujClana(Clan o)
        {
            List <int> lista_sifri = new List <int>();

            foreach (Clan c in Clanovi)
            {
                lista_sifri.Add(c.Sifra);
            }
            foreach (Uposleni u in Uposlenici)
            {
                lista_sifri.Add(u.Sifra);
            }
            o.Sifra = lista_sifri.Max() + 1;
            Clanovi.Add(o);
            if (o.Metod == metoda_placanja.godisnje)
            {
                balans += godisnja_clanarina - godisnja_clanarina * o.Popust;
            }
            else if (o.Metod == metoda_placanja.mjesecno)
            {
                balans += mjesecna_clanarina - mjesecna_clanarina * o.Popust;
            }
            o.Clanstvo = true;
        }
Exemple #16
0
        public ActionResult Autorizacija(Clanovi userModel)
        {
            using (NNVContext context = new NNVContext())
            {
                //var userDetails = context.Clanovi.Where(x => x.KorisnickoIme == userModel.KorisnickoIme && x.Lozinka == userModel.Lozinka && x.admin == false).FirstOrDefault();
                //var userAdmin = context.Clanovi.Where(x => x.KorisnickoIme == userModel.KorisnickoIme && x.Lozinka == userModel.Lozinka && x.admin == true).FirstOrDefault();

                var userDetails = (from c in context.Clanovi
                                   where (c.KorisnickoIme == userModel.KorisnickoIme && c.Lozinka == userModel.Lozinka && c.admin == false)
                                   select c).FirstOrDefault();
                var userAdmin = (from c in context.Clanovi
                                 where (c.KorisnickoIme == userModel.KorisnickoIme && c.Lozinka == userModel.Lozinka && c.admin == true)
                                 select c).FirstOrDefault();


                if (userDetails == null && userAdmin == null)
                {
                    //userModel.LoginErrorMessage = "Погрешно корисничко име или лозинка.";
                    if (userModel.KorisnickoIme != null || userModel.Lozinka != null)
                    {
                        ViewBag.Message = string.Format("Погрешно корисничко име или лозинка.");
                    }
                    return(View("Index", userModel));
                }
                else
                {
                    if (userAdmin != null)
                    {
                        return(RedirectToAction("Index", "Admin"));
                    }
                    //Session["ClanID"] = userDetails.ClanID;
                    Session["KorisnickoIme"] = userDetails.KorisnickoIme;
                    return(RedirectToAction("Index", "Promena"));
                }
            }
        }
Exemple #17
0
 private void UpisiClana()
 {
     Clanovi clan = new Clanovi();
 }
Exemple #18
0
        // GET: Registration
        public ActionResult Registration(int id = 0)
        {
            Clanovi clan = new Clanovi();

            return(View(clan));
        }
Exemple #19
0
 public void AddClan(Vatrogasac clan)
 {
     Clanovi.Add(clan);
 }
Exemple #20
0
 public void RemoveClan(Vatrogasac clan)
 {
     Clanovi.Remove(clan);
 }