public int Add(string categoryName) { var category = new Category { Name = categoryName }; if (this.categoriesRepo.All().Any(c => c.Name == category.Name)) { return -1; } this.categoriesRepo.Add(category); this.categoriesRepo.SaveChanges(); return category.Id; }
public int Update(Category category) { this.categoriesRepo.Update(category); this.categoriesRepo.SaveChanges(); return category.Id; }