diff --git a/src/Bonsai/Areas/Admin/Controllers/ChangesetsController.cs b/src/Bonsai/Areas/Admin/Controllers/ChangesetsController.cs index 59cb4c5..12b6054 100644 --- a/src/Bonsai/Areas/Admin/Controllers/ChangesetsController.cs +++ b/src/Bonsai/Areas/Admin/Controllers/ChangesetsController.cs @@ -13,7 +13,7 @@ namespace Bonsai.Areas.Admin.Controllers; /// Controller for managing changesets. /// [Route("admin/changes")] -public class ChangesetsController(ChangesetsManagerService changes, AppDbContext db) : AdminControllerBase +public class ChangesetsController(ChangesetsManagerService changesSvc, AppDbContext db) : AdminControllerBase { protected override Type ListStateType => typeof(ChangesetsListRequestVM); @@ -26,7 +26,7 @@ public class ChangesetsController(ChangesetsManagerService changes, AppDbContext public async Task Index(ChangesetsListRequestVM request) { PersistListState(request); - var vm = await changes.GetChangesetsAsync(request); + var vm = await changesSvc.GetChangesetsAsync(request); return View(vm); } @@ -37,7 +37,7 @@ public async Task Index(ChangesetsListRequestVM request) [Route("details")] public async Task Details(Guid id) { - var vm = await changes.GetChangesetDetailsAsync(id); + var vm = await changesSvc.GetChangesetDetailsAsync(id); return View(vm); } @@ -48,7 +48,7 @@ public async Task Details(Guid id) [Route("revert")] public async Task Revert(Guid id) { - var vm = await changes.GetChangesetDetailsAsync(id); + var vm = await changesSvc.GetChangesetDetailsAsync(id); if (!vm.CanRevert) throw new OperationException(Texts.Admin_Changesets_CannotRevertMessage); @@ -62,11 +62,11 @@ public async Task Revert(Guid id) [Route("revert")] public async Task Revert(Guid id, bool confirm) { - var editVm = await changes.GetChangesetDetailsAsync(id); + var editVm = await changesSvc.GetChangesetDetailsAsync(id); if (!editVm.CanRevert) throw new OperationException(Texts.Admin_Changesets_CannotRevertMessage); - await changes.RevertChangeAsync(id, User); + await changesSvc.RevertChangeAsync(id, User); await db.SaveChangesAsync(); return RedirectToSuccess(Texts.Admin_Changesets_RevertedMessage); diff --git a/src/Bonsai/Areas/Admin/Controllers/PagesController.cs b/src/Bonsai/Areas/Admin/Controllers/PagesController.cs index 78d8dec..97c359d 100644 --- a/src/Bonsai/Areas/Admin/Controllers/PagesController.cs +++ b/src/Bonsai/Areas/Admin/Controllers/PagesController.cs @@ -29,7 +29,7 @@ namespace Bonsai.Areas.Admin.Controllers; /// Controller for handling pages. /// [Route("admin/pages")] -public class PagesController(PagesManagerService pages, ISearchEngine search, AppDbContext db, IBackgroundJobService jobs) +public class PagesController(PagesManagerService pagesSvc, ISearchEngine search, AppDbContext db, IBackgroundJobService jobs) : AdminControllerBase { protected override Type ListStateType => typeof(PagesListRequestVM); @@ -53,7 +53,7 @@ public class PagesController(PagesManagerService pages, ISearchEngine search, Ap public async Task Index(PagesListRequestVM request) { PersistListState(request); - var vm = await pages.GetPagesAsync(request); + var vm = await pagesSvc.GetPagesAsync(request); return View(vm); } @@ -64,7 +64,7 @@ public async Task Index(PagesListRequestVM request) [Route("create")] public async Task Create([FromQuery]PageType type = PageType.Person) { - var vm = await pages.RequestCreateAsync(type, User); + var vm = await pagesSvc.RequestCreateAsync(type, User); if (vm.Type != type) { TempData[NotificationsService.NOTE_PAGETYPE_RESET_FROM_DRAFT] = type; @@ -86,7 +86,7 @@ public async Task Create(PageEditorVM vm) try { - var page = await pages.CreateAsync(vm, User); + var page = await pagesSvc.CreateAsync(vm, User); await db.SaveChangesAsync(); await search.AddPageAsync(page); await jobs.RunAsync(JobBuilder.For().SupersedeAll()); @@ -107,7 +107,7 @@ public async Task Create(PageEditorVM vm) [Route("update")] public async Task Update(Guid id) { - var vm = await pages.RequestUpdateAsync(id, User); + var vm = await pagesSvc.RequestUpdateAsync(id, User); return await ViewEditorFormAsync(vm, displayDraft: true); } @@ -123,7 +123,7 @@ public async Task Update(PageEditorVM vm, string tab) try { - var page = await pages.UpdateAsync(vm, User); + var page = await pagesSvc.UpdateAsync(vm, User); await db.SaveChangesAsync(); await search.AddPageAsync(page); await jobs.RunAsync(JobBuilder.For().SupersedeAll()); @@ -145,7 +145,7 @@ public async Task Update(PageEditorVM vm, string tab) [Route("remove")] public async Task Remove(Guid id) { - ViewBag.Info = await pages.RequestRemoveAsync(id, User); + ViewBag.Info = await pagesSvc.RequestRemoveAsync(id, User); return View(new RemoveEntryRequestVM { Id = id }); } @@ -157,9 +157,9 @@ public async Task Remove(Guid id) public async Task Remove(RemoveEntryRequestVM vm) { if (vm.RemoveCompletely) - await pages.RemoveCompletelyAsync(vm.Id, User); + await pagesSvc.RemoveCompletelyAsync(vm.Id, User); else - await pages.RemoveAsync(vm.Id, User); + await pagesSvc.RemoveAsync(vm.Id, User); await db.SaveChangesAsync(); await search.RemovePageAsync(vm.Id); @@ -187,7 +187,7 @@ private async Task ViewEditorFormAsync(PageEditorVM vm, string tab .JoinString(", "); var photoThumbUrl = await GetMainPhotoThumbnailUrlAsync(vm.MainPhotoKey); - var draft = await pages.GetPageDraftAsync(vm.Id, User); + var draft = await pagesSvc.GetPageDraftAsync(vm.Id, User); ViewBag.Data = new PageEditorDataVM { diff --git a/src/Bonsai/Areas/Admin/Controllers/UsersController.cs b/src/Bonsai/Areas/Admin/Controllers/UsersController.cs index 90bd239..c428255 100644 --- a/src/Bonsai/Areas/Admin/Controllers/UsersController.cs +++ b/src/Bonsai/Areas/Admin/Controllers/UsersController.cs @@ -22,7 +22,7 @@ namespace Bonsai.Areas.Admin.Controllers; /// Controller for managing users. /// [Route("admin/users")] -public class UsersController(UsersManagerService users, PagesManagerService pages, BonsaiConfigService config, ISearchEngine search, AppDbContext db) +public class UsersController(UsersManagerService usersSvc, PagesManagerService pagesSvc, BonsaiConfigService configSvc, ISearchEngine search, AppDbContext db) : AdminControllerBase { protected override Type ListStateType => typeof(UsersListRequestVM); @@ -35,9 +35,9 @@ public class UsersController(UsersManagerService users, PagesManagerService page public async Task Index([FromQuery] UsersListRequestVM request) { PersistListState(request); - var users1 = await users.GetUsersAsync(request); - ViewBag.AllowPasswordAuth = config.GetStaticConfig().Auth.AllowPasswordAuth; - return View(users1); + var users = await usersSvc.GetUsersAsync(request); + ViewBag.AllowPasswordAuth = configSvc.GetStaticConfig().Auth.AllowPasswordAuth; + return View(users); } /// @@ -47,7 +47,7 @@ public async Task Index([FromQuery] UsersListRequestVM request) [Route("remove")] public async Task Remove(string id) { - var vm = await users.RequestRemoveAsync(id, User); + var vm = await usersSvc.RequestRemoveAsync(id, User); return View(vm); } @@ -58,7 +58,7 @@ public async Task Remove(string id) [Route("remove")] public async Task Remove(string id, bool confirm) { - await users.RemoveAsync(id, User); + await usersSvc.RemoveAsync(id, User); return RedirectToSuccess(Texts.Admin_Users_RemovedMessage); } @@ -69,7 +69,7 @@ public async Task Remove(string id, bool confirm) [Route("update")] public async Task Update(string id) { - var vm = await users.RequestUpdateAsync(id); + var vm = await usersSvc.RequestUpdateAsync(id); return await ViewUpdateFormAsync(vm); } @@ -85,16 +85,16 @@ public async Task Update(UserEditorVM vm) try { - if (vm.CreatePersonalPage && await users.CanCreatePersonalPageAsync(vm)) + if (vm.CreatePersonalPage && await usersSvc.CanCreatePersonalPageAsync(vm)) { - var page = await pages.CreateDefaultUserPageAsync(vm, User); + var page = await pagesSvc.CreateDefaultUserPageAsync(vm, User); vm.PersonalPageId = page.Id; vm.CreatePersonalPage = false; await search.AddPageAsync(page); } - await users.UpdateAsync(vm, User); + await usersSvc.UpdateAsync(vm, User); await db.SaveChangesAsync(); @@ -135,14 +135,14 @@ public async Task Create(UserCreatorVM vm) { if (vm.CreatePersonalPage) { - var page = await pages.CreateDefaultUserPageAsync(vm, User); + var page = await pagesSvc.CreateDefaultUserPageAsync(vm, User); vm.PersonalPageId = page.Id; vm.CreatePersonalPage = false; await search.AddPageAsync(page); } - await users.CreateAsync(vm); + await usersSvc.CreateAsync(vm); await db.SaveChangesAsync(); return RedirectToSuccess(Texts.Admin_Users_CreatedMessage); @@ -177,7 +177,7 @@ public async Task ResetPassword(UserPasswordEditorVM vm) try { - await users.ResetPasswordAsync(vm); + await usersSvc.ResetPasswordAsync(vm); return RedirectToSuccess(Texts.Admin_Users_PasswordResetMessage); } catch (ValidationException ex) @@ -211,7 +211,7 @@ private async Task ViewCreateFormAsync(UserCreatorVM vm) /// private async Task ViewResetPasswordFormAsync(string id) { - ViewBag.Data = await users.GetAsync(id); + ViewBag.Data = await usersSvc.GetAsync(id); return View("ResetPassword", new UserPasswordEditorVM { Id = id }); } @@ -220,12 +220,12 @@ private async Task ViewResetPasswordFormAsync(string id) /// private async Task ViewUpdateFormAsync(UserEditorVM vm) { - var canCreate = await users.CanCreatePersonalPageAsync(vm); + var canCreate = await usersSvc.CanCreatePersonalPageAsync(vm); var pageItems = await GetPageItemsAsync(vm.PersonalPageId); ViewBag.Data = new UserEditorDataVM { - IsSelf = users.IsSelf(vm.Id, User), + IsSelf = usersSvc.IsSelf(vm.Id, User), UserRoleItems = ViewHelper.GetEnumSelectList(vm.Role), CanCreatePersonalPage = canCreate, PageItems = pageItems @@ -258,7 +258,7 @@ private async Task> GetPageItemsAsync(Guid? pageId /// private void CheckPasswordAuth() { - if (!config.GetStaticConfig().Auth.AllowPasswordAuth) + if (!configSvc.GetStaticConfig().Auth.AllowPasswordAuth) throw new OperationException(Texts.Admin_Users_PasswordAuthRestrictedMessage); }