public ResponseServices <Profesor> ConsultarProfesorId(long idEstudiante) { var response = new ResponseServices <Profesor>(); response.Type = Enums.MensajeRespuesta.Consulta.ToStringAttribute(); var result = _ctxModel.Profesor.Find(idEstudiante); if (result != null) { response.Info = result; response.Message = Enums.MensajeRespuesta.Ok.ToStringAttribute(); response.State = true; return(response); } response.Info = result; response.Message = Enums.MensajeRespuesta.Error.ToStringAttribute(); response.State = false; return(response); }
public ResponseServices <List <Profesor> > ConsultarPorfesores() { var response = new ResponseServices <List <Profesor> >(); response.Type = Enums.MensajeRespuesta.Consulta.ToStringAttribute(); var resultList = _ctxModel.Profesor.ToList(); if (resultList.Any()) { response.Info = resultList; response.Message = Enums.MensajeRespuesta.Ok.ToStringAttribute(); response.State = true; return(response); } response.Info = resultList; response.Message = Enums.MensajeRespuesta.Error.ToStringAttribute(); response.State = false; return(response); }
public ResponseServices <int> InsertarNota(NotaDto nota) { var response = new ResponseServices <int>(); response.Type = Enums.MensajeRespuesta.Insert.ToStringAttribute(); _ctxModel.InsertarNotaEstudiante(null, nota.IdProfesor, nota.IdEstudiante, nota.Nombre, nota.Valor); var result = _ctxModel.SaveChanges(); if (result > (int)Enums.Status.Error) { response.Info = result; response.Message = Enums.MensajeRespuesta.Ok.ToStringAttribute(); response.State = true; return(response); } response.Message = Enums.MensajeRespuesta.Error.ToStringAttribute(); response.State = false; return(response); }
public ResponseServices <int> InsertarProfesor(ProfesorDto profesor) { var response = new ResponseServices <int>(); response.Type = Enums.MensajeRespuesta.Insert.ToStringAttribute(); var mapEntidad = AutoMapperConfig.GetMapper <Profesor, ProfesorDto>().Map <Profesor>(profesor); _ctxModel.Profesor.Add(mapEntidad); var result = _ctxModel.SaveChanges(); if (result > (int)Enums.Status.Error) { response.Info = result; response.Message = Enums.MensajeRespuesta.Ok.ToStringAttribute(); response.State = true; return(response); } response.Message = Enums.MensajeRespuesta.Error.ToStringAttribute(); response.State = false; return(response); }
public ResponseServices <int> EliminarPorfesor(long idEstudiante) { var response = new ResponseServices <int>(); response.Type = Enums.MensajeRespuesta.Eliminar.ToStringAttribute(); var result = _ctxModel.Profesor.Find(idEstudiante); if (result != null) { _ctxModel.Profesor.Remove(result); var eliminado = _ctxModel.SaveChanges(); response.Info = eliminado; response.Message = Enums.MensajeRespuesta.Ok.ToStringAttribute(); response.State = true; return(response); } response.Info = (int)Enums.Status.Error; response.Message = Enums.MensajeRespuesta.Error.ToStringAttribute(); response.State = false; return(response); }
public ResponseServices <int> ActualizarPorfesor(ProfesorDto profesor) { var response = new ResponseServices <int>(); response.Type = Enums.MensajeRespuesta.Update.ToStringAttribute(); var mapEntidad = AutoMapperConfig.GetMapper <Profesor, ProfesorDto>().Map <Profesor>(profesor); var result = _ctxModel.Profesor.Find(mapEntidad.idProfesor); if (result != null) { result.nombre = profesor.Nombre; var modificado = _ctxModel.SaveChanges(); response.Info = modificado; response.Message = Enums.MensajeRespuesta.Ok.ToStringAttribute(); response.State = true; return(response); } response.Message = Enums.MensajeRespuesta.Error.ToStringAttribute(); response.State = false; return(response); }
public ResponseServices <int> ActualizarEstudiante(EstudianteDto estudiante) { var response = new ResponseServices <int>(); response.Type = Enums.MensajeRespuesta.Update.ToStringAttribute(); var mapEntidad = AutoMapperConfig.GetMapper <Estudiante, EstudianteDto>().Map <Estudiante>(estudiante); var result = _ctxModel.Estudiante.Find(mapEntidad.idEstudiante); if (result != null) { result.nombre = estudiante.Nombre; var modificado = _ctxModel.SaveChanges(); response.Info = modificado; response.Message = Enums.MensajeRespuesta.Ok.ToStringAttribute(); response.State = true; return(response); } response.Message = Enums.MensajeRespuesta.Error.ToStringAttribute(); response.State = false; return(response); }
public ResponseServices <int> ActualizarNota(NotaDto nota) { var response = new ResponseServices <int>(); response.Type = Enums.MensajeRespuesta.Update.ToStringAttribute(); var mapEntidad = AutoMapperConfig.GetMapper <Nota, NotaDto>().Map <Nota>(nota); var result = _ctxModel.Nota.Find(mapEntidad.idNota); if (result != null) { result.nombre = nota.Nombre; result.valor = nota.Valor; var modificado = _ctxModel.SaveChanges(); response.Info = modificado; response.Message = Enums.MensajeRespuesta.Ok.ToStringAttribute(); response.State = true; return(response); } response.Message = Enums.MensajeRespuesta.Error.ToStringAttribute(); response.State = false; return(response); }