public IActionResult Save(ReasonSubCategoryMaster_VM reasonSubCategoryMaster_VM)
 {
     if (reasonSubCategoryMaster_VM != null)
     {
         reasonSubCategoryMaster_VM.ClientId = clientId;
         if (reasonSubCategoryMaster_VM.Id > 0)
         {
             if (_voucherReasonSubCategoryMasterRepository.Update(reasonSubCategoryMaster_VM, this.loginUserId) > 0)
             {
                 TempData["Status"]  = Helper.success_code;
                 TempData["Message"] = Message.voucherSubCategoryUpdated;
             }
             else
             {
                 TempData["Message"] = Message.voucherSubCategoryUpdatedError;
             }
         }
         else
         {
             if (_voucherReasonSubCategoryMasterRepository.Add(reasonSubCategoryMaster_VM, this.loginUserId) > 0)
             {
                 TempData["Status"]  = Helper.success_code;
                 TempData["Message"] = Message.voucherSubCategoryAdded;
             }
             else
             {
                 TempData["Message"] = Message.voucherSubCategoryAddedError;
             }
         }
     }
     return(RedirectToAction("List", "VoucherReasonSubCategory"));
 }
        /// <summary>
        /// Function add sub-category
        /// </summary>
        /// <param name="country_VM"></param>
        /// <param name="loginUserId"></param>
        /// <returns></returns>
        public int Add(ReasonSubCategoryMaster_VM subCategoryMaster_VM, int loginUserId)
        {
            var obj = new VoucherReasonSubCategoryMaster();

            obj.Name             = subCategoryMaster_VM.Name;
            obj.Status           = subCategoryMaster_VM.Status;
            obj.ClientId         = subCategoryMaster_VM.ClientId;
            obj.ReasonCategoryId = subCategoryMaster_VM.ReasonCategoryId;
            obj.CreatedBy        = loginUserId;
            obj.CreatedOn        = DateTime.Now;
            _context.VoucherReasonSubCategoryMaster.Add(obj);
            return(_context.SaveChanges());
        }
        /// <summary>
        /// Function for update sub category
        /// </summary>
        /// <param name="country_VM"></param>
        /// <param name="loginUserId"></param>
        /// <returns></returns>
        public int Update(ReasonSubCategoryMaster_VM subCategoryMaster_VM, int loginUserId)
        {
            var obj = _context.VoucherReasonSubCategoryMaster.Where(x => x.Id == subCategoryMaster_VM.Id && x.IsDeleted == false).FirstOrDefault();

            if (obj != null)
            {
                obj.Name             = subCategoryMaster_VM.Name;
                obj.Status           = subCategoryMaster_VM.Status;
                obj.ReasonCategoryId = subCategoryMaster_VM.ReasonCategoryId;
                obj.ClientId         = subCategoryMaster_VM.ClientId;
                obj.ModifiedBy       = loginUserId;
                obj.ModifiedOn       = DateTime.Now;
                return(_context.SaveChanges());
            }
            return(0);
        }
        public IActionResult Index(int Id = 0)
        {
            ViewBag.ReasonCategories = new SelectList(_voucherReasonCategoryMasterRepository.GetList().Where(x => x.ClientId == clientId && x.Status), "Id", "Name");
            var subcategory = new ReasonSubCategoryMaster_VM();

            if (Id > 0)
            {
                subcategory = _voucherReasonSubCategoryMasterRepository.Get(Id);
                if (subcategory == null)
                {
                    return(RedirectToAction("List", " VoucherReasonSubCategory"));
                }
                else
                {
                    ViewData["Title"] = "Edit";
                    return(View(subcategory));
                }
            }
            else
            {
                ViewData["Title"] = "Add";
                return(View(subcategory));
            }
        }