public async Task <IActionResult> Edit(int id, [Bind("Id,Subcategorie,CategorieId,Verantwoordelijke,Verantwoordelijke2")] SubCategorie subCat) { if (id != subCat.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(subCat); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!SubCategorieExists(subCat.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["CategorieId"] = new SelectList(_context.Categorie, "Id", "Naam", subCat.CategorieId); return(View(subCat)); }
public async Task <ActionResult <SubCategorie> > PostSubCategorie(SubCategorie subCategorie) { _context.SubCategories.Add(subCategorie); await _context.SaveChangesAsync(); return(CreatedAtAction("GetSubCategorie", new { id = subCategorie.Id }, subCategorie)); }
public async Task <IActionResult> PutSubCategorie(int id, SubCategorie subCategorie) { if (id != subCategorie.Id) { return(BadRequest()); } _context.Entry(subCategorie).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!SubCategorieExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public void UpdateSubCategorie(SubCategorie subCategorie) { if (subCategorie == null) { throw new ArgumentNullException(nameof(subCategorie)); } _context.Entry(subCategorie).State = EntityState.Modified; }
public void DeleteSubCategorie(SubCategorie subCategorie) { if (subCategorie == null) { throw new ArgumentNullException(nameof(subCategorie)); } _context.Remove(subCategorie); }
public void CreateSubCategorie(SubCategorie subCategorie) { if (subCategorie == null) { throw new ArgumentNullException(nameof(subCategorie)); } _context.Add(subCategorie); }
public ActionResult <SubCategorie> AddSubCategorie([FromBody] SubCategorie subCategorie) { try { _repository.CreateSubCategorie(subCategorie); _repository.SaveChanges(); return(CreatedAtAction(nameof(GetSubCategorieById), new SubCategorie { Id = subCategorie.Id }, subCategorie)); } catch (Exception) { return(BadRequest()); } }
public ActionResult PutSubCategorie(int id, [FromBody] SubCategorie subCategorie) { try { if (subCategorie.Id != id) { return(NotFound()); } _repository.UpdateSubCategorie(subCategorie); _repository.SaveChanges(); return(Ok()); } catch (Exception) { return(BadRequest()); } }