public async Task <bool> Create(CategorieServiceModel categorieServiceModel) { Categorie categorie = new Categorie { Name = categorieServiceModel.Name }; this.dbContext.Categories.Add(categorie); int result = await this.dbContext.SaveChangesAsync(); return(result > 0); }
public async Task <bool> Edit(string id, CategorieServiceModel categorieServiceModel) { var categorieFromDb = await this.dbContext.Categories.SingleOrDefaultAsync(x => x.Id == id); if (categorieFromDb == null) { throw new ArgumentNullException(nameof(categorieFromDb)); } categorieFromDb.Name = categorieServiceModel.Name; this.dbContext.Update(categorieFromDb); int result = await this.dbContext.SaveChangesAsync(); return(result > 0); }