public void AddCategoryWithTitle(string title)
 {
     _categories.Add(_categoryToSave  = new Category(Domain.Entities.Comments.Comments.Init(Program.AuthUser, "Category")) { Title = title });
     Categories = new BindingList<Category>(_categories);
     if (Categories.Count < 2)
         _selectedCategory = _categoryToSave;
     SaveCategory();
 }
        /// <summary>
        /// The fuction to get all products that match all not-empty specified datas
        /// </summary>
        /// <param name="sku"></param>
        /// <param name="title"></param>
        /// <param name="category"></param>
        /// <returns></returns>
        public ICollection<Product> GetBy(string sku, string title, Category category)
        {
            var result = dbContext.Products.AsQueryable();

            if (!string.IsNullOrWhiteSpace(sku))
                result = result.Where(product => product.SKU == sku);

            if (!string.IsNullOrWhiteSpace(title))
                result = result.Where(product => product.Title == title);

            if (!Category.IsNullOrEmpty(category))
                result = result.Where(product => product.Category == category);

            return result.ToList();
        }
 public void UseCategoryWithID(int id)
 {
     if(id != 0)
     {
         _categoryInUse = _categoryRepository.Read(id);
         _category = _categoryInUse;
         NotifyPropertyChanged();
     }
     _categoryComments = new BindingList<Comment>(_categoryInUse.Comments.ToList());
 }
 public static bool IsNullOrEmpty(Category category)
 {
     return category == null || category.Title == "";
 }
 public ICollection<Product> GetBy(string sku, string title, Category category)
 {
     return ProductRepository.GetBy(sku, title, category);
 }
 public void Save(Category category)
 {
     CategoryRepository.Update(category);
 }
 public void Create(Category category)
 {
     CategoryRepository.Create(category);
 }
 public void Update(Category entity)
 {
     dbContext.Entry(entity).State = System.Data.Entity.EntityState.Modified;
     dbContext.SaveChanges();
 }
 public void Delete(Category entity)
 {
     dbContext.Categories.Remove(entity);
     dbContext.SaveChanges();
 }
 public void Create(Category entity)
 {
     dbContext.Categories.Add(entity);
     dbContext.SaveChanges();
 }
        public void SaveCategoryInUse()
        {
            Category categoryToSave = _selectedCategory;

            if (_selectedCategory.Id == 0)
            {
                categoryToSave = new Category(_categoryComments)
                {
                    Date = _selectedCategory.Date,
                    Id = _selectedCategory.Id,
                    IsActive = _selectedCategory.IsActive,
                    Title = _selectedCategory.Title
                };
            }
            else
            {
                categoryToSave.Comments = _categoryComments;

            }
            _categories[_categories.IndexOf(_categories.First(x => x.Title == categoryToSave.Title))] = categoryToSave;
        }
 public void UseCategoryWithID(int id)
 {
     if(id != 0)
         _selectedCategory = Categories.FirstOrDefault(categ=> categ.Id == id);
     if(_selectedCategory!= null)
         _categoryComments = new BindingList<Comment>(_selectedCategory.Comments.ToList());
 }
 public void Clear()
 {
     SKU = null;
     Title = null;
     Category = null;
     Products.Clear();
     NotifyPropertyChanged();
 }