// 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()); } Color.EstaActivo = true; Color.MaterialId = MaterialId; _colorData.Update(Color); try { await _colorData.Commit(); } catch (DbUpdateConcurrencyException) { if (!ColorExists(Color.ID)) { return(NotFound()); } else { throw; } } TempData["Edit"] = $"Se ha editado el color: {Color.Nombre}"; return(RedirectToPage("/Materiales/Colores/Index", new { materialId = MaterialId })); }
public async Task <IActionResult> OnPost() { if (!ModelState.IsValid) { CargarMaterial(MaterialId); return(Page()); } Color.MaterialId = MaterialId; var result = _colorData.Add(Color); await _colorData.Commit(); TempData["Message"] = $"Se ha creado el color: {result.Nombre}"; return(RedirectToPage("/Materiales/Colores/Index", new { materialId = MaterialId })); }
public async Task <IActionResult> OnPost(int?id) { if (id == null) { return(NotFound()); } Color = _colorData.GetById(id); if (Color == null) { return(NotFound()); } _colorData.Delete(Color.ID); await _colorData.Commit(); TempData["Delete"] = $"Se ha eliminado el color: {Color.Nombre}"; return(RedirectToPage("/Materiales/Colores/Index", new { materialId = Color.Material.ID })); }