public string devuelveHabitaciones() { Data.HotelesEntities db = new HotelesEntities(); try { List <sproc_hoteles_GetHabitacionList_Result> listaHabitacion = db.sproc_hoteles_GetHabitacionList().ToList(); var responseModel = new HabitacionModel() { Success = true, Message = "Lista completa", Data = listaHabitacion }; return(JsonConvert.SerializeObject(responseModel)); } catch (DbEntityValidationException e) { manejoDeErrores.GuardarError(e.ToString()); return(JsonConvert.SerializeObject(manejoDeErrores.errorBaseDeDatos(e))); } catch (Exception ex) { manejoDeErrores.GuardarError(ex.ToString()); return(JsonConvert.SerializeObject(manejoDeErrores.errorGeneral(ex))); } }
public async Task <IActionResult> PutHabitacionModel(string id, HabitacionModel habitacionModel) { if (id != habitacionModel.IdHabitacion) { return(BadRequest()); } _context.Entry(habitacionModel).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!HabitacionModelExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <ActionResult <HabitacionModel> > PostHabitacionModel(HabitacionModel habitacionModel) { _context.Habitaciones.Add(habitacionModel); try { await _context.SaveChangesAsync(); } catch (DbUpdateException) { if (HabitacionModelExists(habitacionModel.IdHabitacion)) { return(Conflict()); } else { throw; } } return(CreatedAtAction("GetHabitacionModel", new { id = habitacionModel.IdHabitacion }, habitacionModel)); }