// 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(Gen).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!GenExists(Gen.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[] selectedArome) { if (id == null) { return(NotFound()); } var parfumToUpdate = await _context.Parfum .Include(i => i.Brand) .Include(i => i.Gen) .Include(i => i.AromeParfum) .ThenInclude(i => i.Aroma) .FirstOrDefaultAsync(s => s.ID == id); if (parfumToUpdate == null) { return(NotFound()); } if (await TryUpdateModelAsync <Parfum>( parfumToUpdate, "Parfum", i => i.Denumire, i => i.Descriere, i => i.Pret, i => i.DataAparitie, i => i.Brand, i => i.GenID)) { UpdateAromeParfum(_context, selectedArome, parfumToUpdate); await _context.SaveChangesAsync(); return(RedirectToPage("./Index")); } //Apelam UpdateBookCategories pentru a aplica informatiile din checkboxuri la entitatea Books care //este editata UpdateAromeParfum(_context, selectedArome, parfumToUpdate); PopulateAtributAromaData(_context, parfumToUpdate); 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[] selectedArome) { var newParfum = new Parfum(); if (selectedArome != null) { newParfum.AromeParfum = new List <AromaParfum>(); foreach (var cat in selectedArome) { var catToAdd = new AromaParfum { AromaID = int.Parse(cat) }; newParfum.AromeParfum.Add(catToAdd); } } if (await TryUpdateModelAsync <Parfum>( newParfum, "Parfum", i => i.Denumire, i => i.Descriere, i => i.Pret, i => i.DataAparitie, i => i.BrandID, i => i.GenID)) { _context.Parfum.Add(newParfum); await _context.SaveChangesAsync(); return(RedirectToPage("./Index")); } PopulateAtributAromaData(_context, newParfum); 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.Gen.Add(Gen); await _context.SaveChangesAsync(); return(RedirectToPage("./Index")); }
public async Task <IActionResult> OnPostAsync(int?id) { if (id == null) { return(NotFound()); } Brand = await _context.Brand.FindAsync(id); if (Brand != null) { _context.Brand.Remove(Brand); await _context.SaveChangesAsync(); } return(RedirectToPage("./Index")); }