public IHttpActionResult GetCategoryProduct(int key)
 {
     CategoryProductRepository catProd = new CategoryProductRepository(new MyRoomDbContext());
     return Json(catProd.GetCategoryById(key));
 }
        public IHttpActionResult  PostCategoryAssignProducts(CategoryProductViewModel categoryAssignProductViewModel)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            try
            {
                //    catalogRepository.Insert(catalog);
                //    int catalogid = catalog.CatalogId;
                CategoryProductRepository categoryProdRepo = new CategoryProductRepository(new MyRoomDbContext());
                List<CategoryProduct> categoryProds = CategoryProductMapper.CreateModel(categoryAssignProductViewModel);
                if (categoryProds.Count>0)
                     categoryProdRepo.InsertCategoryProduct(categoryProds);
                else
                    categoryProdRepo.DeleteCategoryProduct(categoryAssignProductViewModel.CategoryId);
                 
                //    this.CreateStructureDirectories(catalogid);
                return Ok("The products has been assigned to category");

            }
            catch (Exception ex)
            {
                throw ex;
            }
        }