// To protect from overposting attacks, enable the specific properties you want to bind to. // For more details, see https://aka.ms/RazorPagesCRUD. public async Task <IActionResult> OnPostAsync() { if (!ModelState.IsValid) { return(Page()); } _context.Attach(InventarioModel).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!InventarioModelExists(InventarioModel.Id)) { return(NotFound()); } else { throw; } } return(RedirectToPage("./Index")); }
// To protect from overposting attacks, see https://aka.ms/RazorPagesCRUD public async Task <IActionResult> OnPostAsync() { if (!ModelState.IsValid) { return(Page()); } _context.AutorModel.Add(AutorModel); await _context.SaveChangesAsync(); return(RedirectToPage("./Index")); }
// To protect from overposting attacks, see https://aka.ms/RazorPagesCRUD public async Task <IActionResult> OnPostAsync() { if (!ModelState.IsValid) { return(Page()); } LibroModel.GenCodigo(); _context.Libros.Add(LibroModel); await _context.SaveChangesAsync(); return(RedirectToPage("./Index")); }
public async Task <IActionResult> OnPostAsync(int?id) { if (id == null) { return(NotFound()); } InventarioModel = await _context.Inventarios.FindAsync(id); if (InventarioModel != null) { _context.Inventarios.Remove(InventarioModel); await _context.SaveChangesAsync(); } return(RedirectToPage("./Index")); }
// To protect from overposting attacks, see https://aka.ms/RazorPagesCRUD public async Task <IActionResult> OnPostAsync() { if (!ModelState.IsValid) { return(Page()); } #region Subir archivo using (var memoryStream = new MemoryStream()) { await IfArchivo.CopyToAsync(memoryStream); // Upload the file if less than 2 MB if (memoryStream.Length < 2097152) { var file = new AppFile() { Content = memoryStream.ToArray() }; var UsuarioEnLinea = await UserManager.GetUserAsync(User); InventarioModel.Usuario = UsuarioEnLinea; InventarioModel.Archivo = IfArchivo.FileName; _context.Inventarios.Add(InventarioModel); await _context.SaveChangesAsync(); } else { ModelState.AddModelError("IfArchivo", "The file is too large."); } } #endregion return(RedirectToPage("./Index")); }