Exemplo n.º 1
0
        public int Add(string name, string userId)
        {
            try
            {
                var category = new Category
                {
                    Name = name,
                    UserId = userId
                };

                categories.Add(category);
                categories.SaveChanges();

                return category.Id;
            }
            catch (Exception ex)
            {
                throw;
            }
        }
Exemplo n.º 2
0
        private void GenerateCategories()
        {
            for (int i = 0; i < 10; i++)
            {
                var randomName = random.GenerateRandomString(5, 15);
                var category = new Category()
                {
                    Name = randomName,
                    LanguageId = random.GenerateRandomNumber(1, 2)
                };

                context.Categories.Add(category);
            }

            context.SaveChanges();
        }