Skip to content

Commit 2eaa64e

Browse files
committed
Refactor item service and inventory management: update namespace for IItemService, fix item amount update logic, and clean up DbService properties
1 parent 61026dd commit 2eaa64e

File tree

3 files changed

+4
-22
lines changed

3 files changed

+4
-22
lines changed
Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.Threading.Tasks;
41
using Hanekawa.Entities.Users;
52

6-
namespace Hanekawa.Application.Services;
3+
namespace Hanekawa.Application.Interfaces;
74

85
public interface IItemService
96
{
@@ -13,4 +10,4 @@ public interface IItemService
1310
ValueTask<IEnumerable<ItemType>> GetAllItemTypesAsync();
1411
ValueTask UseItemAsync(ulong guildId, ulong userId, Guid itemId);
1512
ValueTask<Item> CreateItemAsync(string name, string description, Guid typeId, int? price = null);
16-
}
13+
}

Hanekawa.Application/Services/InventoryService.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public async ValueTask UpdateInventoryAsync(GuildUser user, Inventory inventory)
6161
var item = existingUser.User.Inventory.FirstOrDefault(e => e.ItemId == inventory.ItemId);
6262
if (item is not null)
6363
{
64-
item.Amount =+ inventory.Amount;
64+
item.Amount += inventory.Amount;
6565
}
6666
else
6767
{

Hanekawa.Infrastructure/DbService.cs

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -14,29 +14,19 @@
1414

1515
namespace Hanekawa.Infrastructure;
1616

17-
/// <inheritdoc cref="Hanekawa.Application.Interfaces.IDbContext" />
1817
internal class DbService : DbContext, IDbContext
1918
{
2019
public DbService(DbContextOptions<DbService> options) : base(options) { }
21-
/// <inheritdoc />
20+
2221
public DbSet<Warning> Warnings { get; set; } = null!;
23-
/// <inheritdoc />
2422
public DbSet<Log> Logs { get; set; } = null!;
25-
/// <inheritdoc />
2623
public DbSet<GuildModerationLog> ModerationLogs { get; set; } = null!;
27-
/// <inheritdoc />
2824
public DbSet<GuildConfig> GuildConfigs { get; set; } = null!;
29-
/// <inheritdoc />
3025
public DbSet<GuildUser> Users { get; set; } = null!;
31-
/// <inheritdoc />
3226
public DbSet<LevelRequirement> LevelRequirements { get; set; } = null!;
33-
/// <inheritdoc />
3427
public DbSet<Club> Clubs { get; set; } = null!;
35-
/// <inheritdoc />
3628
public DbSet<ClubMember> ClubMembers { get; set; } = null!;
37-
/// <inheritdoc />
3829
public DbSet<Item> Items { get; set; } = null!;
39-
/// <inheritdoc />
4030
public DbSet<ItemType> ItemTypes { get; set; } = null!;
4131

4232
protected override void OnModelCreating(ModelBuilder modelBuilder)
@@ -157,20 +147,15 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)
157147
});
158148
}
159149

160-
/// <param name="cancellationToken"></param>
161-
/// <inheritdoc />
162150
public async Task<int> SaveChangesAsync(CancellationToken cancellationToken = default)
163151
=> await base.SaveChangesAsync(cancellationToken);
164152

165-
/// <inheritdoc />
166153
public async Task<bool> EnsureDatabaseCreated(CancellationToken cancellationToken = default)
167154
=> await base.Database.EnsureCreatedAsync(cancellationToken);
168155

169-
/// <inheritdoc />
170156
public async Task MigrateDatabaseAsync(CancellationToken cancellationToken = default)
171157
=> await base.Database.MigrateAsync(cancellationToken: cancellationToken);
172158

173-
/// <inheritdoc />
174159
public DbConnection GetConnection()
175160
{
176161
return this.Database.GetDbConnection();

0 commit comments

Comments
 (0)