// To protect from overposting attacks, please 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()); } Material.EstaActivo = true; _materialData.Update(Material); try { await _materialData.Commit(); } catch (DbUpdateConcurrencyException) { if (!MaterialExists(Material.ID)) { return(NotFound()); } else { throw; } } TempData["Edit"] = $"Se ha editado el material: {Material.Nombre}"; return(RedirectToPage("./Index")); }
public async Task <IActionResult> OnPostAsync() { if (!ModelState.IsValid) { return(Page()); } var result = _materialData.Add(Material); await _materialData.Commit(); TempData["Message"] = "Se ha creado un nuevo material"; return(RedirectToPage("./Details", new { id = result.ID })); }