public void InsertAlgorithm(Algorithm algorithm) { // indien geen categorie gekozen , deze opslaan in "Unsorted". if (algorithm.CategorieNaam == null || algorithm.CategorieNaam == "") { algorithm.CategorieNaam = "Unsorted"; try { //categorie 'unsorted' ophalen Categorie categorie = db.Query <Categorie>("GetCategorieUnsorted", new { Naam = algorithm.CategorieNaam }, commandType: CommandType.StoredProcedure).Single(); algorithm.CategorieId = categorie.Id; } catch (Exception) { //indien categorie 'unsorted' niet bestaat, deze categorie aanmaken int _id = db.Query <int>("InsertCategorieUnsorted", new { Naam = algorithm.CategorieNaam }, commandType: CommandType.StoredProcedure).Single(); algorithm.CategorieId = _id; } } db.Execute("InsertAlgorithm", new { CategorieId = algorithm.CategorieId, Nummer = algorithm.Nummer, Afbeelding = algorithm.Afbeelding, AlgorithmSolution = algorithm.AlgorithmSolution, Actief = algorithm.Actief }, commandType: CommandType.StoredProcedure); }
public void InsertCategorie(Categorie categorie) { db.Execute("InsertCategorie", new { Naam = categorie.Naam }, commandType: CommandType.StoredProcedure); }
public void UpdateCategorie(Categorie categorie) { db.Execute("UpdateCategorie", new { Naam = categorie.Naam, Id = categorie.Id }, commandType: CommandType.StoredProcedure); }