public bool Modify( int Codigo ) { Query query = new Query( "api/personal/" + Codigo ); if ( !string.IsNullOrEmpty( this._data.ImageKey ) && !string.IsNullOrEmpty( this._data.ImageSrc ) ) { this._file.Add( this._data.ImageKey, this._data.ImageSrc ); this._data.ImageSrc = string.Empty; } query.RequestParameters = this._data; if ( this._file.Any() ) query.AddRequestFiles( this._file ); try { query.SendRequestPUT(); if ( query.ResponseStatusCode == HttpStatusCode.InternalServerError ) throw new ArgumentNullException( "Existe un error en el servidor:\n" + this._msgExceptionPersonal, "Error en el Servidor" ); else if ( query.ResponseStatusCode == HttpStatusCode.NotFound ) throw new ArgumentNullException( "No se encontro recurso al cual acceder", "Recurso no encontrado" ); msgResponse resp = JsonConvert.DeserializeObject<msgResponse>( query.ResponseContent ); if ( query.ResponseStatusCode == HttpStatusCode.BadRequest ) throw new InvalidOperationException( resp.message ); return Convert.ToBoolean(resp.data); } catch ( Exception e ) { this._msgExceptionPersonal = e.Message; return false; } }
public tPersonal Insert() { Query query = new Query( "api/personal" ); if ( !string.IsNullOrEmpty( this._data.ImageKey ) && !string.IsNullOrEmpty( this._data.ImageSrc ) ) { this._file.Add( this._data.ImageKey, this._data.ImageSrc ); this._data.ImageSrc = string.Empty; } query.RequestParameters = this._data; if ( this._file.Any() ) query.AddRequestFiles( this._file ); try { query.SendRequestPOST(); if ( query.ResponseStatusCode == HttpStatusCode.InternalServerError ) throw new ArgumentNullException( "Existe un error en el servidor:\n" + this._msgExceptionPersonal, "Error en el Servidor" ); else if ( query.ResponseStatusCode == HttpStatusCode.NotFound ) throw new ArgumentNullException( "No se encontro recurso al cual acceder", "Recurso no encontrado" ); msgResponse resp = JsonConvert.DeserializeObject<msgResponse>( query.ResponseContent ); if ( query.ResponseStatusCode == HttpStatusCode.BadRequest ) throw new InvalidOperationException( resp.message ); string[] str = resp.data.Split( '-' ); this._data.Codigo = Convert.ToInt32(str[0]); this._data.Key = str[1]; return this._data; } catch ( Exception e ) { this._msgExceptionPersonal = e.Message; return null; } }
public int CreateStudent( bool Individual = false ) { Query query = new Query( ( ! Individual ) ? this._pAlumnoCtrl : this._AlumnoCtrl ); this._dataMain.Alumno = this._dataAlumno; if ( ! Individual ) //si no solo se registraran datos unicos del alumno { this._dataMain.Documentos = this._dataDocumento; this._dataMain.Apoderado = this._dataApoderado; this._dataMain.CursosExonerados = this._dataCursoExonerado; } //limpiando los datos de imagen de perfil y agregandolo al contenedor de imagenes if ( !string.IsNullOrEmpty( DataAlumno.ImageKey ) && !string.IsNullOrEmpty( DataAlumno.ImageSrc ) ) { this._File.Add( this.DataAlumno.ImageKey, this.DataAlumno.ImageSrc ); this._dataMain.Alumno.ImageSrc = string.Empty; } if ( !Individual ) { int con = 0; //limpiando los datos de imagen de documento y agregandolos al contenedor de imagens foreach ( tDocumentoAlumno items in this._dataMain.Documentos ) { if ( !string.IsNullOrEmpty( items.ImageSrc ) && !string.IsNullOrEmpty( items.ImageKey ) ) { this._File.Add( items.ImageKey, items.ImageSrc ); this._dataMain.Documentos[con].ImageSrc = string.Empty; con++; } } } query.RequestParameters = this._dataMain; if ( this._File.Any() ) query.AddRequestFiles( this._File ); try { query.SendRequestPOST(); if ( query.ResponseStatusCode != HttpStatusCode.OK ) throw new ArgumentNullException( query.MsgExceptionQuery, "ERROR AL REGISTRO" ); return Convert.ToInt32( query.ResponseContent ); } catch ( Exception e ) { this._msgExceptionRegAlumno = e.Message; return 0; } }
public bool ModifyStudent( int Codigo ) { Query query = new Query( this._AlumnoCtrl + "/" + Codigo ); this._dataMain.Alumno = this._dataAlumno; if ( !string.IsNullOrEmpty( this._dataAlumno.ImageKey ) && !string.IsNullOrEmpty( this._dataAlumno.ImageSrc ) ) { this._File.Add( this._dataAlumno.ImageKey, this._dataAlumno.ImageSrc ); this._dataMain.Alumno.ImageSrc = string.Empty; } query.RequestParameters = this._dataMain; if ( this._File.Any() ) query.AddRequestFiles( this._File ); try { query.SendRequestPUT(); if ( query.ResponseStatusCode != HttpStatusCode.Accepted ) throw new ArgumentNullException( query.MsgExceptionQuery, "ERROR AL MODIFICAR EL ESTUDIANTE" ); return true; } catch ( Exception e ) { this._msgExceptionRegAlumno = e.Message; return false; } }
public bool SendDataStudent( DataSet dts ) { Query query = new Query( this._registerController ); this._dataAlumno.Documents = this._dataDocuments; this._dataAlumno.Parents = this._dataParent; if(!string.IsNullOrEmpty(DataAlumno.ImageKey) && !string.IsNullOrEmpty(DataAlumno.Imagesrc)) { this._File.Add(this.DataAlumno.ImageKey, this.DataAlumno.Imagesrc); this._dataAlumno.Imagesrc = string.Empty; } int con = 0; foreach(Document items in this.DataAlumno.Documents) { if ( !string.IsNullOrEmpty( items.Imagesrc ) && !string.IsNullOrEmpty( items.ImageKey ) ) { this._File.Add( items.ImageKey, items.Imagesrc ); this._dataAlumno.Documents[con].Imagesrc = string.Empty; con++; } } query.RequestParameters = this._dataAlumno; query.AddRequestFiles(this._File); try { query.SendRequestPOST(); if ( query.ResponseStatusCode != HttpStatusCode.OK ) throw new ArgumentNullException( query.MsgExceptionQuery, "ERROR AL REGISTRO" ); ResponseAlumno alumno = JsonConvert.DeserializeObject<ResponseAlumno>( query.ResponseContent ); object[] objAlumno = new object[] { alumno.Id, alumno.Names, alumno.LastName, alumno.Sexo, alumno.Birthday, alumno.Imagesrc, alumno.Address, alumno.Usuario, alumno.IdLastSchool }; dts.Tables["student"].Rows.Add( objAlumno ); foreach ( ResponseDocument docs in alumno.Documents ) { object objDocuments = new object[] { docs.TypeDocument, docs.DocumentNumber, docs.Expire, alumno.Id }; dts.Tables["Documents"].Rows.Add( objDocuments ); } foreach ( ResponseParent parent in alumno.Parents ) { object objParents = new object[] { parent.Names, parent.LastName, parent.TypeParent, parent.GenderParent, parent.TypeDocument, parent.DocumentNumber, parent.Phone, parent.Email, alumno.Id }; dts.Tables["Parents"].Rows.Add( objParents ); } return true; } catch ( Exception e ) { this._msgExceptionRegAlumno = e.Message; return false; } }
public bool SendChangePicture( string Source ) { Query oQuery = new Query( this._Controller + "/change_picture/" ); Dictionary<string, string> file = new Dictionary<string, string>(); object obj = new object(); obj = new object[2]{this.getAppSettings( "User" ), 1}; try { file.Add( "Picture", Source ); oQuery.AddRequestFiles(file); oQuery.RequestParameters = obj; oQuery.SendRequestPOST(); if ( oQuery.ResponseStatusCode == HttpStatusCode.InternalServerError ) throw new ArgumentNullException( "Existe un error en el servidor:\n" + this._msgExceptionLogin, "Error en el Servidor" ); else if ( oQuery.ResponseStatusCode == HttpStatusCode.NotFound ) throw new ArgumentNullException( "No se encontro recurso al cual acceder", "Recurso no encontrado" ); msgResponse resp = JsonConvert.DeserializeObject<msgResponse>( oQuery.ResponseContent ); if ( oQuery.ResponseStatusCode == HttpStatusCode.BadRequest ) throw new InvalidOperationException( resp.message ); this.setAppSettings( "UserPictureUrl", Convert.ToString(resp.data) ); return true; } catch ( Exception e ) { this._msgExceptionLogin = e.Message; return false; } }