// 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()); } TipoMaterial.EstaActivo = true; _tipoMaterialData.Update(TipoMaterial); try { await _tipoMaterialData.Commit(); } catch (DbUpdateConcurrencyException) { if (!TipoMaterialExists(TipoMaterial.ID)) { return(NotFound()); } else { throw; } } TempData["Edit"] = $"Se ha editado el tipo de material: {TipoMaterial.Nombre}"; return(RedirectToPage("./Index")); }
// 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()); } var result = _tipoMaterialData.Add(TipoMaterial); await _tipoMaterialData.Commit(); TempData["Message"] = "Se ha creado un nuevo tipo de material"; return(RedirectToPage("./Details", new { id = result.ID })); }
public async Task <IActionResult> OnPostAsync(int?id) { if (id == null) { return(NotFound()); } TipoMaterial = _tipoMaterialData.GetById(id); if (TipoMaterial == null) { return(NotFound()); } _tipoMaterialData.Delete(TipoMaterial.ID); await _tipoMaterialData.Commit(); TempData["Delete"] = $"Se ha eliminado el tipo de material: {TipoMaterial.Nombre}"; return(RedirectToPage("./Index")); }