// 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(Client).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ClientExists(Client.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[] selectedCategorii) { if (id == null) { return(NotFound()); } var bijuterieToUpdate = await _context.Bijuterie .Include(i => i.Client) .Include(i => i.BijuterieCategorii) .ThenInclude(i => i.Categorie) .FirstOrDefaultAsync(s => s.ID == id); if (bijuterieToUpdate == null) { return(NotFound()); } if (await TryUpdateModelAsync <Bijuterie>( bijuterieToUpdate, "Bijuterie", i => i.Denumire, i => i.Bijutier, i => i.Pret, i => i.DataVanzarii, i => i.Client)) { UpdateBijuterieCategorii(_context, selectedCategorii, bijuterieToUpdate); await _context.SaveChangesAsync(); return(RedirectToPage("./Index")); } //Apelam UpdateBookCategories pentru a aplica informatiile din checkboxuri la entitatea Books care //este editata UpdateBijuterieCategorii(_context, selectedCategorii, 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() { if (!ModelState.IsValid) { return(Page()); } _context.Categorie.Add(Categorie); await _context.SaveChangesAsync(); return(RedirectToPage("./Index")); }
public async Task <IActionResult> OnPostAsync(int?id) { if (id == null) { return(NotFound()); } Categorie = await _context.Categorie.FindAsync(id); if (Categorie != null) { _context.Categorie.Remove(Categorie); await _context.SaveChangesAsync(); } 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(string[] selectedCategorii) { var newBijuterie = new Bijuterie(); if (selectedCategorii != null) { newBijuterie.BijuterieCategorii = new List <BijuterieCategorie>(); foreach (var cat in selectedCategorii) { var catToAdd = new BijuterieCategorie { CategorieID = int.Parse(cat) }; newBijuterie.BijuterieCategorii.Add(catToAdd); } } if (await TryUpdateModelAsync <Bijuterie>(newBijuterie, "Bijuterie", i => i.Denumire, i => i.Bijutier, i => i.Pret, i => i.DataVanzarii, i => i.ClientID)) { _context.Bijuterie.Add(newBijuterie); await _context.SaveChangesAsync(); return(RedirectToPage("./Index")); } PopulateAssignedCategoryData(_context, newBijuterie); return(Page()); }