// 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(Material).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!MaterialExists(Material.ID)) { return(NotFound()); } else { throw; } } return(RedirectToPage("./Index")); }
// 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(int?id, string[] selectedCategories) { if (id == null) { return(NotFound()); } var bijuterieToUpdate = await _context.Bijuterie .Include(i => i.BijuterieCategories) .ThenInclude(i => i.Category) .FirstOrDefaultAsync(s => s.ID == id); if (bijuterieToUpdate == null) { return(NotFound()); } if (await TryUpdateModelAsync <Bijuterie>( bijuterieToUpdate, "Bijuterie", i => i.Tip, i => i.Marca, i => i.Pret, i => i.Material)) { UpdateBijuterieCategories(_context, selectedCategories, bijuterieToUpdate); await _context.SaveChangesAsync(); return(RedirectToPage("./Index")); } UpdateBijuterieCategories(_context, selectedCategories, bijuterieToUpdate); PopulateAssignedCategoryData(_context, bijuterieToUpdate); return(Page()); }
// 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(string[] selectedCategories) { var newBijuterie = new Bijuterie(); if (selectedCategories != null) { newBijuterie.BijuterieCategories = new List <BijuterieCategory>(); foreach (var cat in selectedCategories) { var catToAdd = new BijuterieCategory { CategoryID = int.Parse(cat) }; newBijuterie.BijuterieCategories.Add(catToAdd); } } if (await TryUpdateModelAsync <Bijuterie>( newBijuterie, "Bijuterie", i => i.Tip, i => i.Marca, i => i.Pret, i => i.MaterialID)) { _context.Bijuterie.Add(newBijuterie); await _context.SaveChangesAsync(); return(RedirectToPage("./Index")); } PopulateAssignedCategoryData(_context, newBijuterie); return(Page()); }
// 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.Material.Add(Material); await _context.SaveChangesAsync(); return(RedirectToPage("./Index")); }
public async Task <IActionResult> OnPostAsync(int?id) { if (id == null) { return(NotFound()); } Category = await _context.Category.FindAsync(id); if (Category != null) { _context.Category.Remove(Category); await _context.SaveChangesAsync(); } return(RedirectToPage("./Index")); }
public async Task <IActionResult> OnPostAsync(int?id) { if (id == null) { return(NotFound()); } Bijuterie = await _context.Bijuterie.FindAsync(id); if (Bijuterie != null) { _context.Bijuterie.Remove(Bijuterie); await _context.SaveChangesAsync(); } return(RedirectToPage("./Index")); }
public async Task <IActionResult> OnPostAsync(int?id) { if (id == null) { return(NotFound()); } Material = await _context.Material.FindAsync(id); if (Material != null) { _context.Material.Remove(Material); await _context.SaveChangesAsync(); } return(RedirectToPage("./Index")); }