diff --git a/MBS_COMMAND.Application/UserCases/Commands/Configs/GeneratePointsCommandHandler.cs b/MBS_COMMAND.Application/UserCases/Commands/Configs/GeneratePointsCommandHandler.cs index 6be905a..1ad9511 100644 --- a/MBS_COMMAND.Application/UserCases/Commands/Configs/GeneratePointsCommandHandler.cs +++ b/MBS_COMMAND.Application/UserCases/Commands/Configs/GeneratePointsCommandHandler.cs @@ -26,8 +26,9 @@ public async Task Handle(Command.GeneratePoints request, CancellationTok { var users = await _userRepository.FindAll(x => x.Role == 0 && x.Status == 1).AsTracking() .ToListAsync(cancellationToken); - var point = await _context.Configs.Where(x => x.Key.Equals("PointPerStudent")).Select(x => x.Value) + var pointString = await _context.Configs.Where(x => x.Key.Equals("PointPerStudent")).Select(x => x.Value) .FirstOrDefaultAsync(cancellationToken); + var point = double.Parse(pointString!); foreach (var x in users) { x.Points = point; diff --git a/MBS_COMMAND.Application/UserCases/Commands/Schedules/CreateScheduleCommandHandler.cs b/MBS_COMMAND.Application/UserCases/Commands/Schedules/CreateScheduleCommandHandler.cs index 423ffd6..d25cbec 100644 --- a/MBS_COMMAND.Application/UserCases/Commands/Schedules/CreateScheduleCommandHandler.cs +++ b/MBS_COMMAND.Application/UserCases/Commands/Schedules/CreateScheduleCommandHandler.cs @@ -95,7 +95,7 @@ public async Task Handle(Command.CreateScheduleCommand request, Cancella return Result.Failure(new Error("500", "Booking points is not exist !")); } - if (group.BookingPoints < point!.Value) + if (group.BookingPoints < double.Parse(point!.Value)) { return Result.Failure(new Error("500", "Not enough points to book")); } @@ -118,7 +118,7 @@ public async Task Handle(Command.CreateScheduleCommand request, Cancella scheduleRepository.Add(schedule); if (isAccepted == 1) { - group.BookingPoints -= point.Value; + group.BookingPoints -= double.Parse(point!.Value); } @@ -127,7 +127,7 @@ public async Task Handle(Command.CreateScheduleCommand request, Cancella UserId = x.StudentId, ScheduleId = schedule.Id, Date = schedule.Date, - Point = point.Value / group.Members.Count, + Point = double.Parse(point!.Value) / group.Members.Count, Status = 0 }).ToList(); diff --git a/MBS_COMMAND.Domain/Entities/Config.cs b/MBS_COMMAND.Domain/Entities/Config.cs index e19d98b..fad5223 100644 --- a/MBS_COMMAND.Domain/Entities/Config.cs +++ b/MBS_COMMAND.Domain/Entities/Config.cs @@ -6,5 +6,5 @@ public class Config { [Key] public string Key { get; set; } - public int Value { get; set; } + public string Value { get; set; } } diff --git a/MBS_COMMAND.Persistence/Migrations/ApplicationDbContextModelSnapshot.cs b/MBS_COMMAND.Persistence/Migrations/ApplicationDbContextModelSnapshot.cs index 804681a..c40bc79 100644 --- a/MBS_COMMAND.Persistence/Migrations/ApplicationDbContextModelSnapshot.cs +++ b/MBS_COMMAND.Persistence/Migrations/ApplicationDbContextModelSnapshot.cs @@ -91,8 +91,9 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("Key") .HasColumnType("nvarchar(450)"); - b.Property("Value") - .HasColumnType("int"); + b.Property("Value") + .IsRequired() + .HasColumnType("nvarchar(max)"); b.HasKey("Key");