public ActionResult Details(string id)
        {
            try
            {
                if (id == null)
                {
                    return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
                }

                PartsProductsSubCategory  partsProductsSubCategory  = new PartsProductsSubCategory();
                PartsSubCategoryViewModel partsSubCategoryViewModel = new PartsSubCategoryViewModel();
                partsProductsSubCategory = _unitOfWork.PartsSubCategory.GetByID(Convert.ToInt32(id));
                partsSubCategoryViewModel.PartsProductsSubCategoryName = partsProductsSubCategory.PartsProductsSubCategoryName;
                partsSubCategoryViewModel.PartsProductsCategoryName    = partsProductsSubCategory.PartsProductsCategory.PartsProductsCategoryName;



                if (partsSubCategoryViewModel != null)
                {
                    return(PartialView("_DetailsPartsSubCategory", partsSubCategoryViewModel));
                }
                else
                {
                    return(HttpNotFound());
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
 public ActionResult AddNew(PartsSubCategoryViewModel partsSubCategoryViewModel)
 {
     try
     {
         if (ModelState.IsValid)
         {
             string str = partsSubCategoryViewModel.PartsProductsSubCategoryName;
             PartsSubCategoryRepository partsSubCategoryRepository = new PartsSubCategoryRepository(new AutoSolutionContext());
             bool IsExist = partsSubCategoryRepository.isExist(partsSubCategoryViewModel.PartsProductsSubCategoryName);
             if (!IsExist)
             {
                 PartsProductsSubCategory partsProductsSubCategory = new PartsProductsSubCategory();
                 partsProductsSubCategory.PartsProductsSubCategoryName = partsSubCategoryViewModel.PartsProductsSubCategoryName;
                 partsProductsSubCategory.PartsProductsCategoryId      = Convert.ToInt32(partsSubCategoryViewModel.SelectedPartsProductsCategory);
                 _unitOfWork.PartsSubCategory.Add(partsProductsSubCategory);
                 _unitOfWork.Complete();
                 _unitOfWork.Dispose();
                 return(RedirectToAction("GetPartsProductSubCategory"));
             }
             else
             {
                 return(RedirectToAction("GetPartsProductSubCategory"));
             }
         }
     }
     catch (Exception)
     {
         throw;
     }
     return(View());
 }
 public ActionResult Edit(PartsSubCategoryViewModel partsSubCategoryViewModel)
 {
     try
     {
         if (partsSubCategoryViewModel == null)
         {
             return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
         }
         PartsProductsSubCategory partsProductsSubCategory = new PartsProductsSubCategory();
         partsProductsSubCategory.PartsProductsSubCategoryId   = partsSubCategoryViewModel.PartsProductsSubCategoryId;
         partsProductsSubCategory.PartsProductsSubCategoryName = partsSubCategoryViewModel.PartsProductsSubCategoryName;
         partsProductsSubCategory.PartsProductsCategoryId      = Convert.ToInt32(partsSubCategoryViewModel.SelectedPartsProductsCategory);
         _unitOfWork.PartsSubCategory.Update(partsProductsSubCategory);
         _unitOfWork.Complete();
         _unitOfWork.Dispose();
     }
     catch (Exception)
     {
         throw;
     }
     return(RedirectToAction("GetPartsProductSubCategory"));
 }