Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/CB.Accessors/Contracts/IAllowConfigurationAccessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ public interface IAllowConfigurationAccessor
{
Task<List<AllowConfigurationDto>> GetAllAsync();

Task<AllowConfigurationDto?> GetByIdAsync(string id);
Task<AllowConfigurationDto> GetByIdAsync(string id);

Task<AllowConfigurationDto> CreateAsync(AllowConfiguration entity);

Task<AllowConfigurationDto?> UpdateAsync(AllowConfigurationDto entity);
Task<AllowConfigurationDto> UpdateAsync(AllowConfigurationDto entity);

Task<bool> DeleteAsync(string id);
}
8 changes: 5 additions & 3 deletions src/CB.Accessors/Contracts/IChannelAccessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@ public interface IChannelAccessor
{
Task<List<ChannelDto>> GetAllAsync();

Task<ChannelDto?> GetByIdAsync(string id);
Task<ChannelDto> GetByIdAsync(string id);

Task<ChannelDto> CreateAsync(Channel entity);
Task<ChannelConfigurationSummaryDto> GetChannelConfigurationSummaryByIdAsync(string id);

Task<ChannelDto?> UpdateAsync(ChannelDto entity);
Task<ChannelConfigurationSummaryDto> CreateAsync(Channel entity);

Task<ChannelDto> UpdateAsync(ChannelDto entity);

Task<bool> DeleteAsync(string id);
}
4 changes: 2 additions & 2 deletions src/CB.Accessors/Contracts/IChannelConfigurationAccessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ public interface IChannelConfigurationAccessor
{
Task<List<ChannelConfigurationDto>> GetAllAsync();

Task<ChannelConfigurationDto?> GetByIdAsync(string id);
Task<ChannelConfigurationDto> GetByIdAsync(string id);

Task<ChannelConfigurationDto> CreateAsync(ChannelConfiguration entity);

Task<ChannelConfigurationDto?> UpdateAsync(string id,
Task<ChannelConfigurationDto> UpdateAsync(string id,
ChannelConfigurationDto dto);

Task<bool> DeleteAsync(string id);
Expand Down
6 changes: 3 additions & 3 deletions src/CB.Accessors/Contracts/ICreatorAccessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ public interface ICreatorAccessor
{
Task<List<CreatorDto>> GetAllAsync();

Task<CreatorDto?> GetByIdAsync(long id);
Task<CreatorDto> GetByIdAsync(long id);

Task<CreatorDto?> GetByChannelIdAndPlatformAsync(string channelId, Platform platform);
Task<CreatorDto> GetByChannelIdAndPlatformAsync(string channelId, Platform platform);

Task<CreatorDto> CreateAsync(Creator entity);

Task<CreatorDto?> UpdateAsync(string id,
Task<CreatorDto> UpdateAsync(string id,
Creator entity);

Task<bool> DeleteAsync(string id);
Expand Down
4 changes: 2 additions & 2 deletions src/CB.Accessors/Contracts/ICreatorChannelAccessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ public interface ICreatorChannelAccessor
{
Task<List<CreatorChannelDto>> GetAllAsync();

Task<CreatorChannelDto?> GetAsync(long creatorId,
Task<CreatorChannelDto> GetAsync(long creatorId,
string channelId,
int channelTypeId);

Task<CreatorChannelDto> CreateAsync(CreatorChannel entity);

Task<CreatorChannelDto?> UpdateAsync(string id,
Task<CreatorChannelDto> UpdateAsync(string id,
CreatorChannelDto entity);

Task<bool> DeleteAsync(long creatorId,
Expand Down
2 changes: 1 addition & 1 deletion src/CB.Accessors/Contracts/IDropdownPayloadAccessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ public interface IDropdownPayloadAccessor
{
Task<List<DropdownPayloadDto>> GetAllAsync();

Task<DropdownPayloadDto?> GetByIdAsync(int id);
Task<DropdownPayloadDto> GetByIdAsync(int id);

Task<DropdownPayloadDto> CreateAsync(DropdownPayload entity);

Expand Down
6 changes: 4 additions & 2 deletions src/CB.Accessors/Contracts/IGuildAccessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@ public interface IGuildAccessor
{
Task<List<GuildDto>> GetAllAsync();

Task<GuildDto?> GetByIdAsync(string id);
Task<GuildDto> GetByIdAsync(string id);

Task<GuildConfigurationSummaryDto> GetConfigurationSummaryByIdAsync(string id);

Task<GuildDto> CreateAsync(Guild entity);

Task<GuildDto?> UpdateAsync(string id,
Task<GuildDto> UpdateAsync(string id,
Guild entity);

Task<bool> DeleteAsync(string id);
Expand Down
4 changes: 2 additions & 2 deletions src/CB.Accessors/Contracts/IGuildConfigurationAccessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ public interface IGuildConfigurationAccessor
{
Task<List<GuildConfigurationDto>> GetAllAsync();

Task<GuildConfigurationDto?> GetByIdAsync(string id);
Task<GuildConfigurationDto> GetByIdAsync(string id);

Task<GuildConfigurationDto> CreateAsync(GuildConfiguration entity);

Task<GuildConfigurationDto?> UpdateAsync(string id,
Task<GuildConfigurationDto> UpdateAsync(string id,
GuildConfigurationDto entity);

Task<bool> DeleteAsync(string id);
Expand Down
4 changes: 2 additions & 2 deletions src/CB.Accessors/Contracts/IRoleConfigurationAccessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ public interface IRoleConfigurationAccessor
{
Task<List<RoleConfigurationDto>> GetAllAsync();

Task<RoleConfigurationDto?> GetByIdAsync(string id);
Task<RoleConfigurationDto> GetByIdAsync(string id);

Task<RoleConfigurationDto> CreateAsync(RoleConfiguration entity);

Task<RoleConfigurationDto?> UpdateAsync(RoleConfigurationDto entity);
Task<RoleConfigurationDto> UpdateAsync(RoleConfigurationDto entity);

Task<bool> DeleteAsync(string id);
}
4 changes: 2 additions & 2 deletions src/CB.Accessors/Contracts/IUserAccessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ public interface IUserAccessor
{
Task<List<UserDto>> GetAllAsync();

Task<UserDto?> GetByIdAsync(string id);
Task<UserDto> GetByIdAsync(string id);

Task<UserDto> CreateAsync(User entity);

Task<UserDto?> UpdateAsync(string id,
Task<UserDto> UpdateAsync(string id,
User entity);

Task<bool> DeleteAsync(string id);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public Task<List<AllowConfigurationDto>> GetAllAsync() => context
.ProjectTo<AllowConfigurationDto>(mapper.ConfigurationProvider)
.ToListAsync();

public Task<AllowConfigurationDto?> GetByIdAsync(string id) => context.AllowConfigurations
public Task<AllowConfigurationDto> GetByIdAsync(string id) => context.AllowConfigurations
.AsNoTracking()
.Where(g => g.GuildId == id)
.ProjectTo<AllowConfigurationDto>(mapper.ConfigurationProvider)
Expand All @@ -34,7 +34,7 @@ await context
return mapper.Map<AllowConfigurationDto>(entity);
}

public async Task<AllowConfigurationDto?> UpdateAsync(AllowConfigurationDto updated)
public async Task<AllowConfigurationDto> UpdateAsync(AllowConfigurationDto updated)
{
var allowConfiguration = await context
.AllowConfigurations
Expand Down
14 changes: 10 additions & 4 deletions src/CB.Accessors/Implementations/ChannelAccessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,19 @@ public Task<List<ChannelDto>> GetAllAsync() => context
.ProjectTo<ChannelDto>(mapper.ConfigurationProvider)
.ToListAsync();

public Task<ChannelDto?> GetByIdAsync(string id) => context.Channels
public Task<ChannelDto> GetByIdAsync(string id) => context.Channels
.AsNoTracking()
.Where(g => g.Id == id)
.ProjectTo<ChannelDto>(mapper.ConfigurationProvider)
.FirstOrDefaultAsync();

public async Task<ChannelDto> CreateAsync(Channel entity)
public Task<ChannelConfigurationSummaryDto> GetChannelConfigurationSummaryByIdAsync(string id) => context.Channels
.AsNoTracking()
.Where(g => g.Id == id)
.ProjectTo<ChannelConfigurationSummaryDto>(mapper.ConfigurationProvider)
.FirstOrDefaultAsync();

public async Task<ChannelConfigurationSummaryDto> CreateAsync(Channel entity)
{
entity.CreatedDate = DateTime.UtcNow;
entity.ModifiedDate = DateTime.UtcNow;
Expand All @@ -34,10 +40,10 @@ await context
.SaveChangesAsync()
.ConfigureAwait(false);

return mapper.Map<ChannelDto>(entity);
return mapper.Map<ChannelConfigurationSummaryDto>(entity);
}

public async Task<ChannelDto?> UpdateAsync(ChannelDto updated)
public async Task<ChannelDto> UpdateAsync(ChannelDto updated)
{
var channel = await context
.Channels
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public Task<List<ChannelConfigurationDto>> GetAllAsync() => context
.ProjectTo<ChannelConfigurationDto>(mapper.ConfigurationProvider)
.ToListAsync();

public Task<ChannelConfigurationDto?> GetByIdAsync(string id) => context.ChannelConfigurations
public Task<ChannelConfigurationDto> GetByIdAsync(string id) => context.ChannelConfigurations
.AsNoTracking()
.Where(g => g.GuildId == id)
.ProjectTo<ChannelConfigurationDto>(mapper.ConfigurationProvider)
Expand All @@ -34,7 +34,7 @@ await context
return mapper.Map<ChannelConfigurationDto>(entity);
}

public async Task<ChannelConfigurationDto?> UpdateAsync(string id,
public async Task<ChannelConfigurationDto> UpdateAsync(string id,
ChannelConfigurationDto dto)
{
var channelConfiguration = await context
Expand Down
6 changes: 3 additions & 3 deletions src/CB.Accessors/Implementations/CreatorAccessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ public Task<List<CreatorDto>> GetAllAsync() => context
.ProjectTo<CreatorDto>(mapper.ConfigurationProvider)
.ToListAsync();

public Task<CreatorDto?> GetByIdAsync(long id) => context.Creators
public Task<CreatorDto> GetByIdAsync(long id) => context.Creators
.AsNoTracking()
.Where(g => g.Id == id)
.ProjectTo<CreatorDto>(mapper.ConfigurationProvider)
.FirstOrDefaultAsync();

public Task<CreatorDto?> GetByChannelIdAndPlatformAsync(string channelId, Platform platform) => context.Creators
public Task<CreatorDto> GetByChannelIdAndPlatformAsync(string channelId, Platform platform) => context.Creators
.AsNoTracking()
.Where(g => g.ChannelId == channelId &&
g.PlatformId == (int)platform)
Expand All @@ -46,7 +46,7 @@ await context
return mapper.Map<CreatorDto>(entity);
}

public async Task<CreatorDto?> UpdateAsync(string id,
public async Task<CreatorDto> UpdateAsync(string id,
Creator updated)
{
var creator = await context
Expand Down
4 changes: 2 additions & 2 deletions src/CB.Accessors/Implementations/CreatorChannelAccessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public Task<List<CreatorChannelDto>> GetAllAsync() => context
.ProjectTo<CreatorChannelDto>(mapper.ConfigurationProvider)
.ToListAsync();

public Task<CreatorChannelDto?> GetAsync(long creatorId,
public Task<CreatorChannelDto> GetAsync(long creatorId,
string channelId,
int channelTypeId) => context.CreatorChannels
.AsNoTracking()
Expand All @@ -38,7 +38,7 @@ await context
return mapper.Map<CreatorChannelDto>(entity);
}

public async Task<CreatorChannelDto?> UpdateAsync(string id,
public async Task<CreatorChannelDto> UpdateAsync(string id,
CreatorChannelDto updated)
{
var creatorChannel = await context
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public Task<List<DropdownPayloadDto>> GetAllAsync() => context
.ProjectTo<DropdownPayloadDto>(mapper.ConfigurationProvider)
.ToListAsync();

public Task<DropdownPayloadDto?> GetByIdAsync(int id) => context.DropdownPayloads
public Task<DropdownPayloadDto> GetByIdAsync(int id) => context.DropdownPayloads
.AsNoTracking()
.Where(g => g.Id == id)
.ProjectTo<DropdownPayloadDto>(mapper.ConfigurationProvider)
Expand Down
10 changes: 8 additions & 2 deletions src/CB.Accessors/Implementations/GuildAccessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,18 @@ public Task<List<GuildDto>> GetAllAsync() => context
.ProjectTo<GuildDto>(mapper.ConfigurationProvider)
.ToListAsync();

public Task<GuildDto?> GetByIdAsync(string id) => context.Guilds
public Task<GuildDto> GetByIdAsync(string id) => context.Guilds
.AsNoTracking()
.Where(g => g.Id == id)
.ProjectTo<GuildDto>(mapper.ConfigurationProvider)
.FirstOrDefaultAsync();

public Task<GuildConfigurationSummaryDto> GetConfigurationSummaryByIdAsync(string id) => context.Guilds
.AsNoTracking()
.Where(g => g.Id == id)
.ProjectTo<GuildConfigurationSummaryDto>(mapper.ConfigurationProvider)
.FirstOrDefaultAsync();

public async Task<GuildDto> CreateAsync(Guild entity)
{
entity.CreatedDate = DateTime.UtcNow;
Expand All @@ -37,7 +43,7 @@ await context
return mapper.Map<GuildDto>(entity);
}

public async Task<GuildDto?> UpdateAsync(string id,
public async Task<GuildDto> UpdateAsync(string id,
Guild updated)
{
var guild = await context
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public Task<List<GuildConfigurationDto>> GetAllAsync() => context
.ProjectTo<GuildConfigurationDto>(mapper.ConfigurationProvider)
.ToListAsync();

public Task<GuildConfigurationDto?> GetByIdAsync(string id) => context.GuildConfigurations
public Task<GuildConfigurationDto> GetByIdAsync(string id) => context.GuildConfigurations
.AsNoTracking()
.Where(g => g.GuildId == id)
.ProjectTo<GuildConfigurationDto>(mapper.ConfigurationProvider)
Expand All @@ -34,7 +34,7 @@ await context
return mapper.Map<GuildConfigurationDto>(entity);
}

public async Task<GuildConfigurationDto?> UpdateAsync(string id,
public async Task<GuildConfigurationDto> UpdateAsync(string id,
GuildConfigurationDto updated)
{
var guildConfiguration = await context
Expand Down
4 changes: 2 additions & 2 deletions src/CB.Accessors/Implementations/RoleConfigurationAccessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public Task<List<RoleConfigurationDto>> GetAllAsync() => context
.ProjectTo<RoleConfigurationDto>(mapper.ConfigurationProvider)
.ToListAsync();

public Task<RoleConfigurationDto?> GetByIdAsync(string id) => context.RoleConfigurations
public Task<RoleConfigurationDto> GetByIdAsync(string id) => context.RoleConfigurations
.AsNoTracking()
.Where(g => g.GuildId == id)
.ProjectTo<RoleConfigurationDto>(mapper.ConfigurationProvider)
Expand All @@ -34,7 +34,7 @@ await context
return mapper.Map<RoleConfigurationDto>(entity);
}

public async Task<RoleConfigurationDto?> UpdateAsync(RoleConfigurationDto updated)
public async Task<RoleConfigurationDto> UpdateAsync(RoleConfigurationDto updated)
{
var roleConfiguration = await context
.RoleConfigurations
Expand Down
4 changes: 2 additions & 2 deletions src/CB.Accessors/Implementations/UserAccessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public Task<List<UserDto>> GetAllAsync() => context
.ProjectTo<UserDto>(mapper.ConfigurationProvider)
.ToListAsync();

public Task<UserDto?> GetByIdAsync(string id) => context.Users
public Task<UserDto> GetByIdAsync(string id) => context.Users
.AsNoTracking()
.Where(g => g.Id == id)
.ProjectTo<UserDto>(mapper.ConfigurationProvider)
Expand All @@ -37,7 +37,7 @@ await context
return mapper.Map<UserDto>(entity);
}

public async Task<UserDto?> UpdateAsync(string id,
public async Task<UserDto> UpdateAsync(string id,
User updated)
{
var user = await context
Expand Down
4 changes: 2 additions & 2 deletions src/CB.Bot/Commands/Application/ChannelSlashCommands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ await SocketInteraction
}

var guild = await guildAccessor
.GetByIdAsync(Context.Guild.Id.ToString())
.GetConfigurationSummaryByIdAsync(Context.Guild.Id.ToString())
.ConfigureAwait(false);

if (guild == null)
Expand All @@ -79,7 +79,7 @@ await FollowupAsync("There was an issue retrieving your guild. Contact support."
return;
}

var existingChannel = await channelAccessor.GetByIdAsync(discordChannel.Id.ToString()).ConfigureAwait(false)
var existingChannel = await channelAccessor.GetChannelConfigurationSummaryByIdAsync(discordChannel.Id.ToString()).ConfigureAwait(false)
?? await channelAccessor.CreateAsync(new()
{
CreatedDate = DateTime.UtcNow,
Expand Down
Loading
Loading