Commit före flytt avStatusparameter från point till round

This commit is contained in:
2025-09-13 08:43:17 +02:00
parent a2d47debfe
commit b4898660f2
13 changed files with 226 additions and 34 deletions

View File

@ -0,0 +1,36 @@
using GreadyPoang.DataLayer.Database;
using GreadyPoang.EntityLayer;
namespace GreadyPoang.DataLayer;
public class CombinedRepository : ICombinedRepository
{
private readonly DataContext _context;
public CombinedRepository(DataContext context)
{
_context = context;
}
IEnumerable<RoundBuilderElement> ICombinedRepository.roundBuilderElements()
{
var result = (from gameRound in _context.GameRounds
join gamePoint in _context.GamePoints on gameRound.GameRoundId equals gamePoint.GameRoundId
join participant in _context.Participants on gamePoint.ParticipantId equals participant.ParticipantId
orderby gameRound.GameRoundStartDate descending, participant.LastName, participant.FirstName, gamePoint.GameRoundRegNr
select new RoundBuilderElement
{
ParticipantId = participant.ParticipantId,
ParticipantName = participant.LastNameFirstName,
GamePointId = gamePoint.GamePointId,
GameRoundRegNr = gameRound.GameRoundId,
GameRegPoints = gamePoint.GameRegPoints,
GameRoundId = gameRound.GameRoundId,
GameRoundStartDate = gameRound.GameRoundStartDate,
Status = gamePoint.PointStatus
}).ToList();
return result;
}
}

View File

@ -25,7 +25,7 @@ public class GamePointRepository : IRepository<GamePoint>
{
var res = -1;
if ((entity.GameRoundRegNr == 0)
|| (entity.GameRegPoints == 0))
&& (entity.GameRegPoints == 0))
{
return res; // Validation failed
}
@ -51,7 +51,7 @@ public class GamePointRepository : IRepository<GamePoint>
try
{
_dataContext.GamePoints.Remove(entity);
_dataContext.SaveChanges();
_dataContext.SaveChangesAsync();
res = true;
}
catch (Exception ex)
@ -62,6 +62,22 @@ public class GamePointRepository : IRepository<GamePoint>
return res;
}
public async Task<bool> DeleteById(int Id)
{
var ok = false;
var delObject = await this.Get(Id);
if (delObject != null)
{
try
{
ok = this.Delete(delObject);
}
catch (Exception ex)
{
throw new Exception("Unsuccessful remove of GamePoint: " + ex.Message);
}
}
return ok;
}
}

View File

@ -58,4 +58,24 @@ public class GameRoundRepository : IRepository<GameRound>
}
return res;
}
public async Task<bool> DeleteById(int Id)
{
var ok = false;
var delObject = await this.Get(Id);
if (delObject != null)
{
try
{
ok = this.Delete(delObject);
}
catch (Exception ex)
{
throw new Exception("Unsuccessful remove of GameRound: " + ex.Message);
}
}
return ok;
}
}

View File

@ -62,4 +62,23 @@ public class ParticipantRepository : IRepository<Participant>
}
return res;
}
public async Task<bool> DeleteById(int Id)
{
var ok = false;
var delObject = await this.Get(Id);
if (delObject != null)
{
try
{
ok = this.Delete(delObject);
}
catch (Exception ex)
{
throw new Exception("Unsuccessful remove of Participant: " + ex.Message);
}
}
return ok;
}
}

View File

@ -0,0 +1,9 @@

using GreadyPoang.EntityLayer;
namespace GreadyPoang.DataLayer;
public interface ICombinedRepository
{
IEnumerable<RoundBuilderElement> roundBuilderElements();
}