//Menja korisnika iz baze public ActionResult IzmeniKorisnika(KorisnikViewModel korisnik, long?id) { var k = _context.Korisnik.Find(id); if (k == null) { return(new HttpNotFoundResult()); } k.KorisnickoIme = korisnik.KorisnickoIme; k.Lozinka = korisnik.Lozinka; k.PravoPristupa = korisnik.PravoPristupa; _context.Entry(k).State = EntityState.Modified; _context.SaveChanges(); return(View(korisnik)); }
//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)); }
public ActionResult IzmeniSkolu(SkolaViewModel skola, long?id) { var validImageTypes = new string[] { "image/gif", "image/jpeg", "image/pjpeg", "image/png" }; if (skola.ImageUpload == null || skola.ImageUpload.ContentLength == 0) { ModelState.AddModelError("ImageUpload", "This field is required"); } else if (!validImageTypes.Contains(skola.ImageUpload.ContentType)) { ModelState.AddModelError("ImageUpload", "Please choose either a GIF, JPG or PNG image."); } var s = _context.Skola.Find(id); if (s == null) { return(new HttpNotFoundResult()); } s.Naziv = skola.Naziv; s.Adresa = skola.Adresa; s.Opstina = skola.Opstina; s.PostanskiBroj = skola.PostanskiBroj; s.MaticniBroj = skola.MaticniBroj; s.PIB = skola.PIB; s.BrojRacuna = skola.BrojRacuna; s.WebStranica = skola.WebStranica; s.Beleska = skola.Beleska; if (skola.ImageUpload != null && skola.ImageUpload.ContentLength > 0) { var uploadDir = "~/Slike"; var imagePath = Path.Combine(Server.MapPath(uploadDir), skola.ImageUpload.FileName); var imageUrl = Path.Combine(uploadDir, skola.ImageUpload.FileName); skola.ImageUpload.SaveAs(imagePath); s.Pecat = imageUrl; } _context.Entry(s).State = EntityState.Modified; _context.SaveChanges(); return(View(skola)); }
public ActionResult Izmeni(Osoba osoba, long?id) { if (osoba == null) { return(HttpNotFound()); } if (!ModelState.IsValid) { var viewModel = new OsobaViewModel { Osoba = osoba, Skole = _context.Skola.ToList() }; return(View("Izmeni", viewModel)); } _context.Entry(osoba).State = EntityState.Modified; _context.SaveChanges(); return(RedirectToAction("Index", "Osoba")); }