public void UpdatePermission(AjaxEditPermissionViewModel ajaxEditPermissionViewModel) { using (var unitOfWork = UnitOfWorkManager.NewUnitOfWork()) { try { if (Request.IsAjaxRequest()) { if (ajaxEditPermissionViewModel.Category == Guid.Empty) { // If category is empty guid then this is a global permission var gpr = new GlobalPermissionForRole { MembershipRole = _roleService.GetRole(ajaxEditPermissionViewModel.MembershipRole), Permission = _permissionService.Get(ajaxEditPermissionViewModel.Permission), IsTicked = ajaxEditPermissionViewModel.HasPermission }; _globalPermissionForRoleService.UpdateOrCreateNew(gpr); } else { // We have a category so it's a category permission var mappedItem = new CategoryPermissionForRole { Category = _categoryService.Get(ajaxEditPermissionViewModel.Category), MembershipRole = _roleService.GetRole(ajaxEditPermissionViewModel.MembershipRole), Permission = _permissionService.Get(ajaxEditPermissionViewModel.Permission), IsTicked = ajaxEditPermissionViewModel.HasPermission }; _categoryPermissionForRoleService.UpdateOrCreateNew(mappedItem); } } unitOfWork.Commit(); } catch (Exception ex) { unitOfWork.Rollback(); LoggingService.Error(ex); throw; } } }
public void UpdatePermission(AjaxEditPermissionViewModel ajaxEditPermissionViewModel) { using (var unitOfWork = UnitOfWorkManager.NewUnitOfWork()) { try { if (Request.IsAjaxRequest()) { var mappedItem = new CategoryPermissionForRole { Category = _categoryService.Get(ajaxEditPermissionViewModel.Category), MembershipRole = _roleService.GetRole(ajaxEditPermissionViewModel.MembershipRole), Permission = _permissionService.Get(ajaxEditPermissionViewModel.Permission), IsTicked = ajaxEditPermissionViewModel.HasPermission }; _categoryPermissionForRoleService.UpdateOrCreateNew(mappedItem); } unitOfWork.Commit(); } catch (Exception ex) { unitOfWork.Rollback(); LoggingService.Error(ex); throw; } } }