public IActionResult Create(Integrantes integrantes, Direccion direccion, DocumentoIdentificacion documento, DatosFamiliares familiares, DatosAcademicos academicos, DatosEclesiasticos eclesiasticos, DatosLaborales laborales, ImagesModel imgModel) { //Agregar tipo de Documento string wey = Request.Form["idc"]; if (wey == "Cedula") { documento.TipoDocumento = "Cedula"; } else if (wey == "RNC") { documento.TipoDocumento = "RNC"; } else { documento.TipoDocumento = "Pasaporte"; } bd.DatosFamiliares.Add(familiares); bd.SaveChanges(); bd.DatosAcademicos.Add(academicos); bd.SaveChanges(); bd.DatosEclesiasticos.Add(eclesiasticos); bd.SaveChanges(); bd.DatosLaborales.Add(laborales); bd.SaveChanges(); bd.Direccion.Add(direccion); bd.SaveChanges(); //Adjuntar Documento string stringFileNameDoc = UploadFileDoc(imgModel); var ss = new DocumentoIdentificacion { NombreDocumento = stringFileNameDoc }; documento.NombreDocumento = stringFileNameDoc; bd.DocumentoIdentificacion.Add(documento); bd.SaveChanges(); foreach (var direc in bd.Direccion) { integrantes.DireccionId = direc.DireccionId; } foreach (var fam in bd.DatosFamiliares) { integrantes.DatosFamiliaresId = fam.DatosFamiliaresId; } foreach (var aca in bd.DatosAcademicos) { integrantes.DatosAcademicosId = aca.DatosAcademicosId; } foreach (var ecle in bd.DatosEclesiasticos) { integrantes.DatosEclesiasticosId = ecle.DatosEclesiasticosId; } foreach (var doc in bd.DocumentoIdentificacion) { integrantes.DocIdentidadId = doc.DocIdentidadId; } foreach (var lab in bd.DatosLaborales) { integrantes.DatosLaboralesId = lab.DatosLaboralesId; } //Agregar Imagen string stringFileName = UploadFile(imgModel); var integrante = new Integrantes { Foto = stringFileName }; integrantes.Foto = stringFileName; bd.Integrantes.Add(integrantes); bd.SaveChanges(); return(RedirectToAction("Index")); }
public async Task <IActionResult> Update(int id, Integrantes integrantes, Direccion direccion, DocumentoIdentificacion documento, DatosFamiliares familiares, DatosAcademicos academicos, DatosEclesiasticos eclesiasticos, DatosLaborales laborales, ImagesModel imgModel) { if (id != integrantes.IntegranteId) { return(NotFound()); } //Adjuntar Documento string stringFileNameDoc = UploadFileDoc(imgModel); var ss = new DocumentoIdentificacion { NombreDocumento = stringFileNameDoc }; documento.NombreDocumento = stringFileNameDoc; foreach (var direc in bd.Direccion) { integrantes.DireccionId = direc.DireccionId; } foreach (var fam in bd.DatosFamiliares) { integrantes.DatosFamiliaresId = fam.DatosFamiliaresId; } foreach (var aca in bd.DatosAcademicos) { integrantes.DatosAcademicosId = aca.DatosAcademicosId; } foreach (var ecle in bd.DatosEclesiasticos) { integrantes.DatosEclesiasticosId = ecle.DatosEclesiasticosId; } foreach (var doc in bd.DocumentoIdentificacion) { integrantes.DocIdentidadId = doc.DocIdentidadId; } foreach (var lab in bd.DatosLaborales) { integrantes.DatosLaboralesId = lab.DatosLaboralesId; } bd.DatosFamiliares.Update(familiares); bd.Direccion.Update(direccion); await bd.SaveChangesAsync(); bd.DocumentoIdentificacion.Update(documento); await bd.SaveChangesAsync(); bd.DatosLaborales.Update(laborales); await bd.SaveChangesAsync(); bd.DatosEclesiasticos.Update(eclesiasticos); await bd.SaveChangesAsync(); bd.DatosAcademicos.Update(academicos); await bd.SaveChangesAsync(); bd.Integrantes.Update(integrantes); await bd.SaveChangesAsync(); return(RedirectToAction("Index")); }