public IActionResult Create([Bind("Id,RoleName,RoleDescription,Category,StartDate,Permanent")] Role role)
 {
     if (ModelState.IsValid)
     {
         _roleRepository.AddNewRole(role);
         return(RedirectToAction(nameof(Index)));
     }
     return(View(role));
 }
        public IHttpActionResult SaveRole(RoleAc role)
        {
            try
            {
                //get Company Id by user id
                string        userId        = HttpContext.Current.User.Identity.GetUserId();
                CompanyDetail companyDetail = _companyRepository.GetCompanyDetailByUserId(userId);
                int           companyId     = 0;
                if (companyDetail != null)
                {
                    companyId = companyDetail.Id;
                }

                //check role name exist or not
                if (_roleContext.CheckRoleNameExistOrNot(role, companyId))
                {
                    return(Ok(new { isRoleNameExist = true }));
                }

                if (role.Id == 0)
                {
                    Role roleInfo = _roleContext.AddNewRole(role, companyId);
                    return(Ok(roleInfo));
                }
                else
                {
                    _roleContext.UpdateRole(role);
                    return(Ok(role));
                }
            }
            catch (Exception ex)
            {
                _errorLog.LogException(ex);
                throw;
            }
        }