public IHttpActionResult SaveRoleAndPermissionDetails(List <RolePermissionAc> permission)
 {
     try
     {
         if (HttpContext.Current.User.Identity.IsAuthenticated)
         {
             var userID         = HttpContext.Current.User.Identity.GetUserId();
             var companyDetails = _companyRepository.GetCompanyDetailByUserId(userID);
             foreach (var permissionDetails in permission)
             {
                 foreach (var permissions in permissionDetails.Permission)
                 {
                     foreach (var childPermission in permissions.Children)
                     {
                         if (childPermission.IsChecked)
                         {
                             var rolePermission = new RolePermission();
                             rolePermission.CreatedDateTime   = DateTime.UtcNow;
                             rolePermission.ChildPermissionId = childPermission.PermissionId;
                             rolePermission.CompanyId         = companyDetails.Id;
                             rolePermission.RoleId            = permissionDetails.RoleId;
                             rolePermission.IsChecked         = true;
                             _workFlowRepository.AddRoleAndPermission(rolePermission);
                         }
                         else
                         {
                             var rolePermission = new RolePermission();
                             rolePermission.CreatedDateTime   = DateTime.UtcNow;
                             rolePermission.ChildPermissionId = childPermission.PermissionId;
                             rolePermission.CompanyId         = companyDetails.Id;
                             rolePermission.RoleId            = permissionDetails.RoleId;
                             _workFlowRepository.DeleteRolePermission(rolePermission);
                         }
                     }
                 }
             }
             return(Ok(new { IsResult = true }));
         }
         else
         {
             return(BadRequest());
         }
     }
     catch (Exception ex)
     {
         _errorLog.LogException(ex);
         throw;
     }
 }