public IHttpActionResult PutTerminCena(int id, TerminCena terminCena) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != terminCena.Id) { return(BadRequest()); } db.Entry(terminCena).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!TerminCenaExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public ActionResult DeleteConfirmed(int id) { TerminCena terminCena = db.TerminCenas.Find(id); db.TerminCenas.Remove(terminCena); db.SaveChanges(); return(RedirectToAction("Details", "Hotels", new { id = terminCena.HotelId })); }
public IHttpActionResult GetTerminCena(int id) { TerminCena terminCena = db.TerminCenas.Find(id); if (terminCena == null) { return(NotFound()); } return(Ok(terminCena)); }
public ActionResult Edit([Bind(Include = "Id,date,price,HotelId")] TerminCena terminCena) { if (ModelState.IsValid) { db.Entry(terminCena).State = EntityState.Modified; db.SaveChanges(); //return RedirectToAction("Index"); return(RedirectToAction("Details", "Hotels", new { id = terminCena.HotelId })); } return(View(terminCena)); }
public ActionResult Create([Bind(Include = "Id,date,price")] TerminCena terminCena) { if (ModelState.IsValid) { db.TerminCenas.Add(terminCena); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(terminCena)); }
public IHttpActionResult PostTerminCena(TerminCena terminCena) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.TerminCenas.Add(terminCena); db.SaveChanges(); return(CreatedAtRoute("DefaultApi", new { id = terminCena.Id }, terminCena)); }
// GET: TerminCenas/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } TerminCena terminCena = db.TerminCenas.Find(id); if (terminCena == null) { return(HttpNotFound()); } return(View(terminCena)); }
public IHttpActionResult DeleteTerminCena(int id) { //TerminCena terminCena = db.TerminCenas.Include(t => t.hotel).FirstOrDefault(t => t.Id == id); TerminCena terminCena = db.TerminCenas.Find(id); if (terminCena == null) { return(NotFound()); } db.TerminCenas.Remove(terminCena); db.SaveChanges(); return(Ok(terminCena)); }
public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } TerminCena terminCena = db.TerminCenas.Include(t => t.hotel).FirstOrDefault(t => t.Id == id); Hotel hotel = db.Hotels.Include(h => h.destination).FirstOrDefault(h => h.Id == terminCena.HotelId); terminCena.HotelId = hotel.Id; if (terminCena == null) { return(HttpNotFound()); } return(View(terminCena)); }
public ActionResult DodadiTermin(DodadiTermin model) { Hotel hotel = db.Hotels.Find(model.HotelId); TerminCena cena = new TerminCena(); cena.date = model.dateTime; cena.price = model.price; cena.HotelId = model.HotelId; cena.hotel = hotel; db.TerminCenas.Add(cena); db.SaveChanges(); var terminCenaOdBaza = db.TerminCenas.FirstOrDefault(t => t.date == model.dateTime && t.price == model.price); hotel.termini.Add(terminCenaOdBaza); db.SaveChanges(); return(RedirectToAction("Details", new { id = model.HotelId })); }