public async Task<IActionResult> GuardarDocumento(IFormFile document) /* HACIENDO PRUEBAS */ { context = HttpContext.RequestServices.GetService(typeof(seygreContext)) as seygreContext; string path = _env.ContentRootPath + Path.DirectorySeparatorChar + "ClientApp" + Path.DirectorySeparatorChar + "dist" /*se agrego para ver en AZURE su trabajo*/ /* + Path.DirectorySeparatorChar + "src" se omite para ver en AZURE su trabajo */ + Path.DirectorySeparatorChar + "assets" + Path.DirectorySeparatorChar + "doc"; if (document.Length > 0) { using (var stream = new FileStream(path + Path.DirectorySeparatorChar + document.FileName, FileMode.Create)) { await document.CopyToAsync(stream); } } var found = (from e in context.Centrosacopio where e.Documento.Equals(document.FileName) select e).LastOrDefault(); found.Documento = document.FileName; context.Centrosacopio.Update(found); context.SaveChanges(); return Ok(); }
public void ModificarPersonal([FromBody] Personal r) { context = HttpContext.RequestServices.GetService(typeof(seygreContext)) as seygreContext; //var found = (from e in context.Personal where e.Id.Equals(r.Id) select e).ToList(); var found = context.Personal.Find(r.Id); if (r.Nombre != null) { found.Nombre = r.Nombre; } if (r.Apellidos != null) { found.Apellidos = r.Apellidos; } if (r.Edad != null) { found.Edad = r.Edad; } if (r.Direccion != null) { found.Direccion = r.Direccion; } if (r.IdCargo != null) { found.IdCargo = r.IdCargo; } context.Update(found); context.SaveChanges(); }
public void ModificarNoticia([FromBody] Noticias r) { context = HttpContext.RequestServices.GetService(typeof(seygreContext)) as seygreContext; var found = context.Noticias.Find(r.Id); if (r.Nombre != null) { found.Nombre = r.Nombre; } if (r.ImagenUrl != null) { found.ImagenUrl = r.ImagenUrl; } if (r.Descripccion != null) { found.Descripccion = r.Descripccion; } if (r.NoticiaUrl != null) { found.NoticiaUrl = r.NoticiaUrl; } context.Update(found); context.SaveChanges(); }
public void InsertarEvento([FromBody] Eventos r) { context = HttpContext.RequestServices.GetService(typeof(seygreContext)) as seygreContext; context.Eventos.Add(r); context.SaveChanges(); }
public void AgregarPersonal([FromBody] Personal r) { context = HttpContext.RequestServices.GetService(typeof(seygreContext)) as seygreContext; context.Personal.Add(r); context.SaveChanges(); }
public void AgregarNoticia([FromBody] Noticias r) { context = HttpContext.RequestServices.GetService(typeof(seygreContext)) as seygreContext; context.Noticias.Add(r); context.SaveChanges(); }
public void EliminarPersonal([FromBody] int id) { context = HttpContext.RequestServices.GetService(typeof(seygreContext)) as seygreContext; var found = context.Personal.Find(id); context.Personal.Remove(found); context.SaveChanges(); }
public int EliminarEvento([FromBody] int id) { context = HttpContext.RequestServices.GetService(typeof(seygreContext)) as seygreContext; var found = context.Eventos.Find(id); context.Eventos.Remove(found); context.SaveChanges(); return(1); }
public int AceptarPeticionCentro([FromBody] int id) { string origen = "*****@*****.**"; string destino; string contraseña = "veracruzrrr"; context = HttpContext.RequestServices.GetService(typeof(seygreContext)) as seygreContext; var found = context.Centrosacopio.Find(id); found.IdEstatus = 1; context.Centrosacopio.Update(found); destino = found.Correo; context.SaveChanges(); MailMessage m = new MailMessage(); SmtpClient s = new SmtpClient(); try { m.From = new MailAddress(origen); m.To.Add(new MailAddress(destino)); m.Subject = "SEyGRE-Aceptado"; m.IsBodyHtml = true; m.Body = Formmato2Html(found); s.Host = "smtp.gmail.com"; s.Port = 587; s.Credentials = new NetworkCredential(origen, contraseña); s.EnableSsl = true; s.Send(m); } catch (Exception ) { throw; } return 1; }
public int InsertarCentros([FromBody] Centrosacopio r) { string origen = "*****@*****.**"; string destino = "*****@*****.**"; string contraseña = "veracruzrrr"; context = HttpContext.RequestServices.GetService(typeof(seygreContext)) as seygreContext; var register = (from e in context.Centrosacopio select e).ToList(); context.Centrosacopio.Add(r); context.SaveChanges(); MailMessage m = new MailMessage(); SmtpClient s = new SmtpClient(); try { m.From = new MailAddress(origen); m.To.Add(new MailAddress(destino)); m.Subject = "Nuevo Registro de C.A."; m.IsBodyHtml = true; m.Body = Formmato1Html(r); s.Host = "smtp.gmail.com"; s.Port = 587; s.Credentials = new NetworkCredential(origen, contraseña); s.EnableSsl = true; s.Send(m); } catch (Exception ) { throw; } //context.Database.ExecuteSqlCommand("call procedimiento (\"ruta\")"); return 1; }
public void HabilitarDeshabilitar([FromBody] Centrosacopio r) { context = HttpContext.RequestServices.GetService(typeof(seygreContext)) as seygreContext; var found = context.Centrosacopio.Find(r.Id); if (r.IdEstatus == 1) { found.IdEstatus = 1; } else { found.IdEstatus = 2; } context.Update(found); context.SaveChanges(); }
public void ModificarEvento([FromBody] Eventos r) { context = HttpContext.RequestServices.GetService(typeof(seygreContext)) as seygreContext; //var found = (from e in context.Personal where e.Id.Equals(r.Id) select e).ToList(); var found = context.Eventos.Find(r.Id); if (r.Nombre != null) { found.Nombre = r.Nombre; } if (r.Organizador != null) { found.Organizador = r.Organizador; } if (r.HorarioInicio != null) { found.HorarioInicio = r.HorarioInicio; } if (r.HorarioFinal != null) { found.HorarioFinal = r.HorarioFinal; } if (r.Telefono != null) { found.Telefono = r.Telefono; } if (r.Fecha != null) { found.Fecha = r.Fecha; } if (found.IdEstatus != null) { found.IdEstatus = r.IdEstatus; } context.Update(found); context.SaveChanges(); }
public async Task<IActionResult> GuardarImagenes(IFormFile file, int id) { context = HttpContext.RequestServices.GetService(typeof(seygreContext)) as seygreContext; string path = _env.ContentRootPath + Path.DirectorySeparatorChar + "ClientApp" + Path.DirectorySeparatorChar + "dist" /*se agrego para ver en AZURE su trabajo*/ /* + Path.DirectorySeparatorChar + "src" se omite para ver en AZURE su trabajo */ + Path.DirectorySeparatorChar + "assets" + Path.DirectorySeparatorChar + "profile"; if (!(Directory.Exists(path + Path.DirectorySeparatorChar + file.FileName))) { Directory.CreateDirectory(Path.Combine(path, id.ToString())); /* se crea carpeta por primera vez para ser guardada ahi la imagen */ } if (file.Length > 0) { using (var stream = new FileStream(path + Path.DirectorySeparatorChar + id.ToString() + Path.DirectorySeparatorChar + file.FileName, FileMode.Create)) { await file.CopyToAsync(stream); } } var found = context.Centrosacopio.Find(id); found.Imagen = file.FileName; context.Centrosacopio.Update(found); context.SaveChanges(); return Ok(); }