public HttpResponseMessage createHorario(CreateHorarioRequest newHorario) { var HorarioDA = new HorarioDataAccess(); var HorarioCreado = HorarioDA.CreateHorario(newHorario); return(Request.CreateResponse(HttpStatusCode.OK, HorarioCreado)); }
//METODO CREAR HORARIO public CreateHorarioResponse CreateHorario(CreateHorarioRequest nuevoHorario) { try { using (var context = new BDReservasEntities()) { ObjectParameter RETCODE = new ObjectParameter("RETCODE", typeof(int)); ObjectParameter MENSAJE = new ObjectParameter("MENSAJE", typeof(string)); context.PA_INSERT_HORARIO( nuevoHorario.Nombre, nuevoHorario.Horario, RETCODE, MENSAJE); if ((int)RETCODE.Value < 0) { throw new Exception("Error no controlado"); } if ((int)RETCODE.Value > 0) { throw new Exception(MENSAJE.Value.ToString()); } return(new CreateHorarioResponse() { Retcode = (int)RETCODE.Value, Mensaje = MENSAJE.Value.ToString() }); } } catch (Exception ex) { return(new CreateHorarioResponse() { Mensaje = ex.Message.Trim(), Retcode = -1 }); } }