public string Insertar_imagen_ave(string imagen, string nombreCientifico, string nombreComun, int especie) { tbl_Ave tblAv = new tbl_Ave(); tblAv.Nombre_cientifico = nombreCientifico; tblAv.Nombre_comun = nombreComun; tblAv.id_Especie_ave = especie; tbl_Fotos_aves tblfA = new tbl_Fotos_aves(); tblfA.id_Aves = new tbl_AveCAD().Buscar_id_ave(tblAv); tblfA.Fotos_aves = nombreCientifico + ".txt"; string fil = HttpContext.Current.Server.MapPath(@"~/images/Fotos_Ave/" + nombreCientifico + ".txt"); StreamWriter file = new StreamWriter(fil); file.WriteLine(imagen); file.Close(); Boolean foto = System.IO.File.Exists(fil); string mensaje = ""; if (foto) { mensaje = new tbl_Foto_avesCAD().insert_foto_aves(tblfA); } StreamReader sr = new StreamReader(fil); return(mensaje); }
public List <tbl_Fotos_aves> Llamar_fotos_aves(String idAve) { tbl_Ave ar = new tbl_Ave(); ar.id_Ave = int.Parse(idAve); List <tbl_Fotos_aves> listaFo = new List <tbl_Fotos_aves>(); List <tbl_Fotos_aves> listaF = new tbl_Foto_avesCAD().Buscar_fotos_aves(ar); foreach (var item in listaF) { String fil = HttpContext.Current.Server.MapPath(@"~/images/Fotos_Ave/" + item.Fotos_aves); bool existe = File.Exists(fil); if (existe) { tbl_Fotos_aves fa = new tbl_Fotos_aves(); StreamReader img = new StreamReader(fil); string imagenes = img.ReadLine(); String[] arregloimg = imagenes.Split('~'); for (int i = 0; i < arregloimg.Length - 1; i++) { fa.Fotos_aves = arregloimg[i]; fa.id_Fotos_aves = item.id_Fotos_aves; listaFo.Add(fa); } } } return(listaFo); }
public string Modificar_foto_ave(String imagen) { tbl_Ave tblAv = new tbl_Ave(); tblAv.Nombre_cientifico = HttpContext.Current.Session["ave"].ToString(); tbl_Fotos_aves tblfA = new tbl_Fotos_aves(); Random rn = new Random(); tblfA.id_Aves = new tbl_AveCAD().Buscar_id_ave_cient(tblAv); tblfA.Fotos_aves = tblAv.Nombre_cientifico + rn.Next(1, 9999) + ".txt"; string fil = HttpContext.Current.Server.MapPath(@"~/images/Fotos_Ave/" + tblfA.Fotos_aves); StreamWriter file = new StreamWriter(fil); file.WriteLine(imagen); file.Close(); Boolean foto = System.IO.File.Exists(fil); string mensaje = ""; if (foto) { mensaje = new tbl_Foto_avesCAD().Modificar_foto_aves(tblfA); } return(mensaje); }