// GET: EarningSubCategories
        public ActionResult Index()
        {
            var earningSubCategoryVm = new EarningSubcategoryViewModel();

            earningSubCategoryVm.ListOfEarningSubCategories = _earningSubCategoriesRepository
                                                              .GetWhereWithIncludes(x => x.Id > 0, x => x.Category).ToList();
            return(View(earningSubCategoryVm));
        }
        private EarningSubcategoryViewModel CreateEarningSubcategoryWithSelectList()
        {
            var earningSubCategoryVm = new EarningSubcategoryViewModel();
            var earningCategories    = _earningCategoriesRepository.GetWhere(x => x.Id > 0).ToList();

            earningSubCategoryVm.SelectListOfEarningCategories = new SelectList(earningCategories, "Id", "CategoryName");
            return(earningSubCategoryVm);
        }
        public ActionResult DeleteConfirmed(int id)
        {
            var earningSubCategoryVm = new EarningSubcategoryViewModel();

            earningSubCategoryVm.SubCategory =
                _earningSubCategoriesRepository.GetWhereWithIncludes(earningSubCategory => earningSubCategory.Id == id, subc => subc.Category).FirstOrDefault();
            _earningSubCategoriesRepository.Delete(earningSubCategoryVm.SubCategory);
            return(RedirectToAction("Index"));
        }
 public ActionResult Edit(EarningSubcategoryViewModel earningSubCategoryVm)
 {
     if (ModelState.IsValid)
     {
         _earningSubCategoriesRepository.Update(earningSubCategoryVm.SubCategory);
         return(RedirectToAction("Index"));
     }
     earningSubCategoryVm = CreateEarningSubcategoryWithSelectList();
     return(View(earningSubCategoryVm));
 }
        // GET: EarningSubCategories/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            var earningSubCategoryVm = new EarningSubcategoryViewModel();

            earningSubCategoryVm.SubCategory =
                _earningSubCategoriesRepository.GetWhereWithIncludes(x => x.Id == id, subc => subc.Category).FirstOrDefault();
            if (earningSubCategoryVm.SubCategory == null)
            {
                return(HttpNotFound());
            }
            return(View(earningSubCategoryVm));
        }