public static ResourcesDto FromController(ApiController controller) { var result = new ResourcesDto(); result.AddGetLink("ping", controller.Url <PingController>(x => nameof(x.GetPing))); if (controller.HasPermission(Permissions.AdminEventsRead)) { result.AddGetLink("admin/events", controller.Url <EventConsumersController>(x => nameof(x.GetEventConsumers))); } if (controller.HasPermission(Permissions.AdminRestore)) { result.AddGetLink("admin/restore", controller.Url <RestoreController>(x => nameof(x.GetJob))); } if (controller.HasPermission(Permissions.AdminUsersRead)) { result.AddGetLink("admin/users", controller.Url <UserManagementController>(x => nameof(x.GetUsers))); } result.AddGetLink("languages", controller.Url <LanguagesController>(x => nameof(x.GetLanguages))); return(result); }
public static ResourcesDto FromDomain(Resources resources) { var result = new ResourcesDto(); result.AddGetLink("ping", resources.Url <PingController>(x => nameof(x.GetPing))); if (resources.CanReadEvents) { result.AddGetLink("admin/events", resources.Url <EventConsumersController>(x => nameof(x.GetEventConsumers))); } if (resources.CanRestoreBackup) { result.AddGetLink("admin/restore", resources.Url <RestoreController>(x => nameof(x.GetRestoreJob))); } if (resources.CanReadUsers) { result.AddGetLink("admin/users", resources.Url <UserManagementController>(x => nameof(x.GetUsers))); } if (resources.CanReadOrleans) { result.AddGetLink("admin/orleans", "/orleans"); } result.AddGetLink("languages", resources.Url <LanguagesController>(x => nameof(x.GetLanguages))); return(result); }