public IHttpActionResult PutTipoHotel(int id, TipoHotel tipoHotel) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != tipoHotel.Id) { return(BadRequest()); } db.Entry(tipoHotel).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!TipoHotelExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult GetTipoHotel(int id) { TipoHotel tipoHotel = db.TipoHoteles.Find(id); if (tipoHotel == null) { return(NotFound()); } return(Ok(tipoHotel)); }
public IHttpActionResult DeleteTipoHotel(int id) { TipoHotel tipoHotel = db.TipoHoteles.Find(id); if (tipoHotel == null) { return(NotFound()); } db.TipoHoteles.Remove(tipoHotel); db.SaveChanges(); return(Ok(tipoHotel)); }
public IHttpActionResult PostTipoHotel(TipoHotel tipoHotel) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } try { db.TipoHoteles.Add(tipoHotel); db.SaveChanges(); return(Ok()); } catch (Exception ex) { return(BadRequest(ex.Message.ToString())); } }