public async Task <IActionResult> Edit(long id, [Bind("Id,LokalniNaziv,Lat,Lng,VlasnikId")] Farma farma) { if (id != farma.Id) { return(NotFound()); } if (ModelState.IsValid) { try { farma.VlasnikId = (int)HttpContext.Session.GetInt32("user_id"); _context.Update(farma); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!FarmaExists(farma.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["VlasnikId"] = new SelectList(_context.Vlasnik, "Id", "Id", farma.VlasnikId); return(View(farma)); }
public ActionResult DeleteConfirmed(int id) { Farma farma = db.Farmas.Find(id); db.Farmas.Remove(farma); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "ID_Farma,Farma1,Lokacija,Vlasnik")] Farma farma) { if (ModelState.IsValid) { db.Entry(farma).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(farma)); }
public ActionResult Create([Bind(Include = "ID_Farma,Farma1,Lokacija,Vlasnik")] Farma farma) { if (ModelState.IsValid) { db.Farmas.Add(farma); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(farma)); }
public async Task <IActionResult> Create([Bind("Id,LokalniNaziv,Lat,Lng")] Farma farma) { if (ModelState.IsValid) { farma.VlasnikId = (int)HttpContext.Session.GetInt32("user_id"); _context.Add(farma); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["VlasnikId"] = new SelectList(_context.Vlasnik, "Id", "Id", farma.VlasnikId); return(View(farma)); }
// GET: Farmas/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Farma farma = db.Farmas.Find(id); if (farma == null) { return(HttpNotFound()); } return(View(farma)); }