Example #1
0
        public ActionResult DodajMail()
        {
            var mlvm = new MailListeViewModel()
            {
                Osobe  = _context.Osoba.ToList(),
                Tipovi = _context.TipMaila.ToList()
            };

            return(View(mlvm));
        }
Example #2
0
        public ActionResult Izmeni(long?id)
        {
            var mail      = _context.MailListe.SingleOrDefault(c => c.IdMaila == id);
            var viewModel = new MailListeViewModel
            {
                MailListe = mail,
                Tipovi    = _context.TipMaila.ToList(),
                Osobe     = _context.Osoba.ToList()
            };

            return(View("Izmeni", viewModel));
        }
Example #3
0
        //Metoda koja nam pomaze da vrsimo brisanje u bazi
        public ActionResult IzmeniMail(MailListeViewModel mail, long?id)
        {
            var m = _context.MailListe.Find(id);

            if (m == null)
            {
                return(new HttpNotFoundResult());
            }
            m.Adresa                = mail.Adresa;
            m.IdTipaMaila           = mail.IdTipaMaila;
            m.IdOsobe               = mail.IdOsobe;
            _context.Entry(m).State = EntityState.Modified;
            _context.SaveChanges();
            return(View(mail));
        }
Example #4
0
        public ActionResult DodajMail(MailListe mailListe)
        {
            if (!ModelState.IsValid)
            {
                var viewModel = new MailListeViewModel
                {
                    IdMaila = mailListe.IdMaila,
                    Adresa  = mailListe.Adresa,
                    Osobe   = _context.Osoba.ToList(),
                    Tipovi  = _context.TipMaila.ToList()
                };
                return(View("DodajMail", viewModel));
            }

            _context.MailListe.Add(mailListe);
            _context.SaveChanges();
            return(RedirectToAction("Index", "MailListe"));
        }
Example #5
0
        //Metoda koja ucitava sve osobe iz baze
        public void UcitajOsobe()
        {
            var mlvm = new MailListeViewModel();

            mlvm.Osobe = _context.Osoba.ToList();
        }
Example #6
0
        //Metoda koja ucitava sve mailove iz baze
        public void UcitajTipoveMaila()
        {
            var mlvm = new MailListeViewModel();

            mlvm.Tipovi = _context.TipMaila.ToList();
        }
Example #7
0
 public ActionResult Izmeni(MailListeViewModel mail, long?id)
 {
     IzmeniMail(mail, id);
     return(RedirectToAction("Index", "MailListe"));
 }