private void InsertUpdateProductCategory(ProductCateroryModal model)
        {
            try
            {
                ProductCategory product = new ProductCategory();
                product.CategoryName = model.CategoryName;

                product.ProdCatId = model.ProdCatId;
                var result = productCategoriesRepository.AddUpdateProductCategory(product);
            }
            catch (Exception ex)
            { throw ex; }
        }
        public ActionResult SaveProductCaterory(ProductCateroryModal model)
        {
            List <string> messages       = new List <string>();
            bool          responseStatus = true;

            if (!ModelState.IsValid)
            {
                responseStatus = false;
                messages       = ModelState.Values
                                 .SelectMany(x => x.Errors)
                                 .Select(x => x.ErrorMessage)
                                 .ToList();
            }
            try
            {
                if (responseStatus && model.ProdCatId > 0 && productCategoriesRepository.getProductCategoryDetilsById(model.ProdCatId) != null)
                {
                    InsertUpdateProductCategory(model);
                    responseStatus = true;
                    messages.Add("Product Category data inserted successfully.");
                }
                else if (responseStatus)
                {
                    InsertUpdateProductCategory(model);

                    responseStatus = true;
                    messages.Add("Product Category data updated successfully.");
                }
            }
            catch (Exception ex)
            {
                responseStatus = false;
                messages.Add("something went wrong, please contact your administrator." + ex.Message);
            }


            return(Json(new { messages, responseStatus }, JsonRequestBehavior.AllowGet));
        }
        public ActionResult ProductCategoryFormPartialView(int?id)
        {
            if (id == null)
            {
                id = 0;
            }
            var modeldata = productCategoriesRepository.getProductCategoryDetilsById(id.Value);

            if (modeldata == null)
            {
                ProductCateroryModal objresult = new ProductCateroryModal();

                return(View(objresult));
            }
            var result = new ProductCateroryModal()
            {
                ProdCatId    = modeldata.ProdCatId,
                CategoryName = modeldata.CategoryName
            };

            result = result == null ? new ProductCateroryModal() : result;

            return(View(result));
        }