public async Task <ActionResult> DeleteConfirmedOtpad(string id) { otpad otpad = await db.otpad.FindAsync(int.Parse(id)); db.otpad.Remove(otpad); await db.SaveChangesAsync(); return(RedirectToAction("IndexOtpad")); }
// GET: otpads/Delete/5 public async Task <ActionResult> DeleteOtpad(string id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } otpad otpad = await db.otpad.FindAsync(int.Parse(id)); if (otpad == null) { return(HttpNotFound()); } return(View("~/Views/Administrator/Otpad/DeleteOtpad.cshtml", otpad)); }
public async Task <ActionResult> EditOtpad([Bind(Include = "idOtpad,vrstaOtpad")] otpad otpad) { if (ModelState.IsValid) { var otpadMatch = from c in db.otpad where c.vrstaOtpad.Equals(otpad.vrstaOtpad) select c; if (otpadMatch.Count() != 0) { ModelState.AddModelError(string.Empty, "Već postoji otpad sa istim imenom."); return(View("~/Views/Administrator/Otpad/EditOtpad.cshtml", otpad)); } db.Entry(otpad).State = EntityState.Modified; await db.SaveChangesAsync(); return(RedirectToAction("IndexOtpad")); } return(View("~/Views/Administrator/Otpad/EditOtpad.cshtml", otpad)); }
public async Task <ActionResult> CreateOtpad([Bind(Include = "idOtpad,vrstaOtpad")] otpad otpad) { var rezOtpad = db.otpad.OrderBy(x => x.idOtpad).AsEnumerable().Select(x => x.idOtpad); int rezIDInt; if (ModelState.IsValid) { if (rezOtpad.Count() != 0) { var otpadMatch = from c in db.otpad where c.vrstaOtpad.Equals(otpad.vrstaOtpad) select c; if (otpadMatch.Count() != 0) { ModelState.AddModelError(string.Empty, "Već postoji otpad sa istim imenom."); return(View("~/Views/Administrator/Otpad/CreateOtpad.cshtml", otpad)); } var rezID = rezOtpad.Last(); rezIDInt = (rezID); rezIDInt++; } else { rezIDInt = 1; } otpad otpadFinal = new otpad { idOtpad = rezIDInt, vrstaOtpad = otpad.vrstaOtpad }; db.otpad.Add(otpadFinal); await db.SaveChangesAsync(); return(RedirectToAction("IndexOtpad")); } return(View("~/Views/Administrator/Otpad/CreateOtpad.cshtml", otpad)); }