public int CreateNewCategory(Category category)
        {
            using (DobbermanEntities context = new DobbermanEntities())
            {
                // find out if category already exists by its name
                CategoryEntity validateCategory = (from p
                                             in context.Categories
                                                     where p.Name == category.Name
                                                     select p).FirstOrDefault();
                if (!(validateCategory == null)) return validateCategory.CategoryId;

                CategoryEntity categoryEntity = new CategoryEntity()
                {
                    Name = category.Name,
                    Description = category.Description,
                    Picture = category.Picture,

                };
                context.AddToCategories(categoryEntity);
                context.SaveChanges();
                return categoryEntity.CategoryId;
            }
        }
 private Category TranslateCategoryEntityToCategory(CategoryEntity categoryEntity)
 {
     Category category = new Category()
     {
         CategoryId = categoryEntity.CategoryId,
         Name = categoryEntity.Name,
         Description = categoryEntity.Description,
         Picture = categoryEntity.Picture,
     };
     return category;
 }