public ActionResult DeleteConfirmed(int id) { SobaTip sobaTip = db.SobaTips.Find(id); db.SobaTips.Remove(sobaTip); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "ID,Naziv,Cijena")] SobaTip sobaTip) { if (ModelState.IsValid) { db.Entry(sobaTip).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(sobaTip)); }
public ActionResult Create([Bind(Include = "ID,Naziv,Cijena")] SobaTip sobaTip) { if (ModelState.IsValid) { db.SobaTips.Add(sobaTip); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(sobaTip)); }
public IHttpActionResult GetSobaTip(int id) { SobaTip sobaTip = db.SobaTips.Find(id); if (sobaTip == null) { return(NotFound()); } return(Ok(Mapper.Map <SobaTip, SobaTipDto>(sobaTip))); }
// GET: SobaTip/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } SobaTip sobaTip = db.SobaTips.Find(id); if (sobaTip == null) { return(HttpNotFound()); } return(View(sobaTip)); }
public IHttpActionResult DeleteSobaTip(int id) { SobaTip sobaTip = db.SobaTips.Find(id); if (sobaTip == null) { return(NotFound()); } db.SobaTips.Remove(sobaTip); db.SaveChanges(); return(Ok(Mapper.Map <SobaTip, SobaTipDto>(sobaTip))); }
public IHttpActionResult PostSobaTip(SobaTipDto sobaTipDto) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } SobaTip sobaTip = Mapper.Map <SobaTipDto, SobaTip>(sobaTipDto); db.SobaTips.Add(sobaTip); db.SaveChanges(); return(Created(new Uri(Request.RequestUri + "/" + sobaTip.ID), sobaTipDto)); }
public IHttpActionResult PutSobaTip(int id, SobaTipDto sobaTipDto) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } SobaTip sobaTip = db.SobaTips.SingleOrDefault(st => st.ID == id); if (sobaTip == null) { return(NotFound()); } Mapper.Map(sobaTipDto, sobaTip); db.SaveChanges(); return(Ok()); }