Пример #1
0
 /// <inheritdoc />
 public void RefreshContext(IMvcForumContext context)
 {
     _context = context;
     _roleService.RefreshContext(context);
     _notificationService.RefreshContext(context);
     _groupPermissionForRoleService.RefreshContext(context);
 }
Пример #2
0
 /// <inheritdoc />
 public void RefreshContext(IMvcForumContext context)
 {
     _context = context;
     _groupPermissionForRoleService.RefreshContext(context);
     _permissionService.RefreshContext(context);
     _globalPermissionForRoleService.RefreshContext(context);
 }
Пример #3
0
        /// <inheritdoc />
        public async Task <IPipelineProcess <Group> > Process(IPipelineProcess <Group> input,
                                                              IMvcForumContext context)
        {
            _groupPermissionForRoleService.RefreshContext(context);
            _notificationService.RefreshContext(context);

            try
            {
                // Check if anyone else if using this role
                var okToDelete = !input.EntityToProcess.Topics.Any();

                if (okToDelete)
                {
                    // Get any Grouppermissionforoles and delete these first
                    var rolesToDelete = _groupPermissionForRoleService.GetByGroup(input.EntityToProcess.Id);

                    foreach (var GroupPermissionForRole in rolesToDelete)
                    {
                        _groupPermissionForRoleService.Delete(GroupPermissionForRole);
                    }

                    var GroupNotificationsToDelete = new List <GroupNotification>();
                    GroupNotificationsToDelete.AddRange(input.EntityToProcess.GroupNotifications);
                    foreach (var GroupNotification in GroupNotificationsToDelete)
                    {
                        _notificationService.Delete(GroupNotification);
                    }

                    context.Group.Remove(input.EntityToProcess);

                    await context.SaveChangesAsync();

                    _cacheService.ClearStartsWith("GroupList");
                }
                else
                {
                    input.AddError($"In use by {input.EntityToProcess.Topics} entities");
                    return(input);
                }
            }
            catch (Exception ex)
            {
                input.AddError(ex.Message);
                _loggingService.Error(ex);
            }

            return(input);
        }