public ResponseListLesson getListLessons(RequestLesson Parametros) { ResponseListLesson respuesta = new ResponseListLesson(); lessonsCore core = new lessonsCore(); string mensaje = ""; int idProfessor = new professorsCore().validateProfessor(Parametros.RQ.professor_number, Parametros.RQ.professor_password, ref mensaje); if (idProfessor != -1) { List <Lesson> ListLessons = core.getListLesson(Parametros, ref mensaje); if (ListLessons != null && ListLessons.Count > 0) { ResponseLessons Respuesta = new ResponseLessons(); Respuesta.code = CodigosRespuesta.codigo.OK; Respuesta.estatus = mensaje; respuesta.Response = Respuesta; respuesta.Lessons = ListLessons; } else { ResponseLessons Respuesta = new ResponseLessons(); Respuesta.code = CodigosRespuesta.codigo.NOT_FOUND; Respuesta.estatus = MensajesEstados.SIN_RESULTADOS; respuesta.Response = Respuesta; respuesta.Lessons = null; } } else { ResponseLessons Respuesta = new ResponseLessons(); Respuesta.code = CodigosRespuesta.codigo.FORBIDDEN; Respuesta.estatus = MensajesEstados.ErrorAcceso; respuesta.Response = Respuesta; respuesta.Lessons = null; } return(respuesta); }
public String getListLesson() { String JSON; try { Response.ContentType = "application/json; charset=UTF-8"; String metodoDeEnvioHTTP = System.Web.HttpContext.Current.Request.HttpMethod; if (metodoDeEnvioHTTP != "POST") { ResponseLessons Respuesta = new ResponseLessons(); Respuesta.code = CodigosRespuesta.codigo.INTERNAL_SERVER_ERROR; Respuesta.estatus = MensajesEstados.ERROR_POST_REQUEST; JSON = JsonConvert.SerializeObject(new ResponseListLessons(Respuesta, null)); } else { string POST; using (Stream receiveStream = Request.InputStream) { using (StreamReader readStream = new StreamReader(receiveStream, Request.ContentEncoding)) { POST = readStream.ReadToEnd(); } } if (POST == null || POST == "") { ResponseLessons Respuesta = new ResponseLessons(); Respuesta.code = CodigosRespuesta.codigo.INTERNAL_SERVER_ERROR; Respuesta.estatus = MensajesEstados.ErrorFatal; JSON = JsonConvert.SerializeObject(new ResponseListLessons(Respuesta, null)); } else { RequestLesson Parametros = JsonConvert.DeserializeObject <RequestLesson>(POST); string Mensaje = ""; if (parametrosValidosgetList(Parametros, ref Mensaje)) { ADLessons coursesAD = new ADLessons(); ResponseListLesson Respuesta = coursesAD.getListLessons(Parametros); JSON = JsonConvert.SerializeObject(new ResponseListLessons(Respuesta.Response, Respuesta.Lessons)); } else { ResponseLessons Respuesta = new ResponseLessons(); Respuesta.estatus = Mensaje; Respuesta.code = CodigosRespuesta.codigo.BAD_REQUEST; JSON = JsonConvert.SerializeObject(new ResponseListLessons(Respuesta, null)); } } } } catch (Exception e) { ResponseLessons Respuesta = new ResponseLessons(); Respuesta.estatus = MensajesEstados.ErrorFatal + e.Message.ToString(); Respuesta.code = CodigosRespuesta.codigo.INTERNAL_SERVER_ERROR; JSON = JsonConvert.SerializeObject(new ResponseListLessons(Respuesta, null)); } return(JSON); }