public async Task <IActionResult> EditarGaleriaEventos(EventoGal even) { if (even.Id == 0) { return(NotFound()); } if (ModelState.IsValid) { try{ _contexto.Update(even); await _contexto.SaveChangesAsync(); }catch (Exception ex) { return(RedirectToAction("Index")); } } return(View(even)); }
public async Task <IActionResult> CrearGaleriaEventos(EventoGal e, ICollection <IFormFile> files) { var upload = Path.Combine(_environment.WebRootPath, "images"); foreach (var file in files) { if (file.Length > 0) { using (var fileStream = new FileStream(Path.Combine(upload, file.FileName), FileMode.Create)) { e.RutaFotoF = "/images/" + file.FileName; await file.CopyToAsync(fileStream); } } } if (ModelState.IsValid) { _contexto.eventosgal.Add(e); await _contexto.SaveChangesAsync(); //return RedirectToAction("Index"); } return(View(e)); }