// PUT api/KomentariApi/5 public HttpResponseMessage Putkomentari(int id, komentari komentari) { if (!ModelState.IsValid) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState)); } if (id != komentari.idKomentara) { return(Request.CreateResponse(HttpStatusCode.BadRequest)); } db.Entry(komentari).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException ex) { return(Request.CreateErrorResponse(HttpStatusCode.NotFound, ex)); } return(Request.CreateResponse(HttpStatusCode.OK)); }
public ActionResult DeleteConfirmed(int id) { komentari komentari = db.komentari.Find(id); db.komentari.Remove(komentari); db.SaveChanges(); return(RedirectToAction("Index")); }
// // GET: /Komentari/Details/5 public ActionResult Details(int id = 0) { komentari komentari = db.komentari.Find(id); if (komentari == null) { return(HttpNotFound()); } return(View(komentari)); }
// GET api/KomentariApi/5 public komentari Getkomentari(int id) { komentari komentari = db.komentari.Find(id); if (komentari == null) { throw new HttpResponseException(Request.CreateResponse(HttpStatusCode.NotFound)); } return(komentari); }
public ActionResult Edit(komentari komentari) { if (ModelState.IsValid) { db.Entry(komentari).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.idKorisnika = new SelectList(db.korisnici, "idKorisnika", "imeKorisnika", komentari.idKorisnika); ViewBag.idOglasa = new SelectList(db.oglasi, "idOglasa", "nazivOglasa", komentari.idOglasa); return(View(komentari)); }
// // GET: /Komentari/Edit/5 public ActionResult Edit(int id = 0) { komentari komentari = db.komentari.Find(id); if (komentari == null) { return(HttpNotFound()); } ViewBag.idKorisnika = new SelectList(db.korisnici, "idKorisnika", "imeKorisnika", komentari.idKorisnika); ViewBag.idOglasa = new SelectList(db.oglasi, "idOglasa", "nazivOglasa", komentari.idOglasa); return(View(komentari)); }
public void Postavikomentar(Komentar komentar) { komentari koment = new komentari { tekstKomentara = komentar.TekstKomentara, aktivan = komentar.Aktivan, idKorisnika = komentar.IdKorisnika, idOglasa = komentar.IdKorisnika }; db.komentari.Add(koment); db.SaveChanges(); }
public ActionResult Create(komentari komentari) { if (ModelState.IsValid) { db.komentari.Add(komentari); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.idKorisnika = new SelectList(db.korisnici, "idKorisnika", "imeKorisnika", komentari.idKorisnika); ViewBag.idOglasa = new SelectList(db.oglasi, "idOglasa", "nazivOglasa", komentari.idOglasa); return(View(komentari)); }
// POST api/KomentariApi public HttpResponseMessage Postkomentari(komentari komentari) { if (ModelState.IsValid) { db.komentari.Add(komentari); db.SaveChanges(); HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.Created, komentari); response.Headers.Location = new Uri(Url.Link("DefaultApi", new { id = komentari.idKomentara })); return(response); } else { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState)); } }
// DELETE api/KomentariApi/5 public HttpResponseMessage Deletekomentari(int id) { komentari komentari = db.komentari.Find(id); if (komentari == null) { return(Request.CreateResponse(HttpStatusCode.NotFound)); } db.komentari.Remove(komentari); try { db.SaveChanges(); } catch (DbUpdateConcurrencyException ex) { return(Request.CreateErrorResponse(HttpStatusCode.NotFound, ex)); } return(Request.CreateResponse(HttpStatusCode.OK, komentari)); }