mirror of https://github.com/ErsatzTV/ErsatzTV.git
Browse Source
* Used a UUID in HDHomeRun config to allow multiple instances on a same network * tweak some async calls * try to fix line endings --------- Co-authored-by: Jason Dove <1695733+jasongdove@users.noreply.github.com>pull/1820/head
9 changed files with 104 additions and 54 deletions
@ -0,0 +1,8 @@
@@ -0,0 +1,8 @@
|
||||
# Auto detect text files and perform LF normalization |
||||
* text=auto |
||||
|
||||
*.cs text diff=csharp |
||||
*.cshtml text diff=html |
||||
*.csx text diff=csharp |
||||
*.sln text eol=crlf |
||||
*.csproj text eol=crlf |
@ -0,0 +1,3 @@
@@ -0,0 +1,3 @@
|
||||
namespace ErsatzTV.Application.HDHR; |
||||
|
||||
public record GetHDHRUUID : IRequest<Guid>; |
@ -0,0 +1,24 @@
@@ -0,0 +1,24 @@
|
||||
using ErsatzTV.Core.Domain; |
||||
using ErsatzTV.Core.Interfaces.Repositories; |
||||
|
||||
namespace ErsatzTV.Application.HDHR; |
||||
|
||||
public class GetHDHRUUIDHandler : IRequestHandler<GetHDHRUUID, Guid> |
||||
{ |
||||
private readonly IConfigElementRepository _configElementRepository; |
||||
|
||||
public GetHDHRUUIDHandler(IConfigElementRepository configElementRepository) => |
||||
_configElementRepository = configElementRepository; |
||||
|
||||
public async Task<Guid> Handle(GetHDHRUUID request, CancellationToken cancellationToken) |
||||
{ |
||||
Option<Guid> maybeGuid = await _configElementRepository.GetValue<Guid>(ConfigElementKey.HDHRUUID); |
||||
return await maybeGuid.IfNoneAsync( |
||||
async () => |
||||
{ |
||||
Guid guid = Guid.NewGuid(); |
||||
await _configElementRepository.Upsert(ConfigElementKey.HDHRUUID, guid); |
||||
return guid; |
||||
}); |
||||
} |
||||
} |
Loading…
Reference in new issue