Bulk-Commit: Darft: Anmeldetool.

Interface Definition: done
Server-Side-Implementation: partly done (CR missing, potential Refactor, ...)
Client-Side-Implementation: started: (UI: done, Service: started, but works with SSR)
Missing: Permissions / Roles to restrict access to an event.
Missing: Fields on Event.
Missing: Good Styling
Time-Took: about 12 Hours.
Learning: Commit in smaller packets, rest will be discussed at CR
This commit is contained in:
Konstantin Hintermayer
2025-05-14 20:40:10 +02:00
parent e45fce2e65
commit 38c5bef225
17 changed files with 508 additions and 92 deletions

View File

@ -34,7 +34,7 @@ namespace SZUAbsolventenverein.Module.EventRegistration.Repository
}
else
{
return db.Event.AsNoTracking().FirstOrDefault(item => item.EventRegistrationId == EventRegistrationId);
return db.Event.AsNoTracking().FirstOrDefault(item => item.EventId == EventRegistrationId);
}
}

View File

@ -1,15 +1,19 @@
using System.Collections.Generic;
using System.Threading.Tasks;
using SZUAbsolventenverein.Module.EventRegistration.Models;
namespace SZUAbsolventenverein.Module.EventRegistration.Repository
{
public interface IResponseRepository
{
IEnumerable<Models.Response> GetResponses(int ModuleId);
Models.Response GetResponse(int EventRegistrationId);
Models.Response GetResponse(int EventRegistrationId, bool tracking);
Models.Response AddResponse(Models.Event EventRegistration);
Models.Response UpdateResponse(Models.Event EventRegistration);
void DeleteResponse(int EventRegistrationId);
IEnumerable<Response> GetResponses(int ModuleId);
IEnumerable<Response> GetResponses(int EventId, int ModuleId);
Response GetResponse(int EventRegistrationId);
Response GetResponse(int EventRegistrationId, bool tracking);
Response GetResponse(int EventId, int OwnerId);
Response GetResponse(int EventId, int OwnerId, bool tracking);
Response AddResponse(Response EventResponse);
Response UpdateResponse(Response EventResponse);
void DeleteResponse(int EventResponseId);
}
}

View File

@ -0,0 +1,89 @@
using Microsoft.EntityFrameworkCore;
using System.Linq;
using System.Collections.Generic;
using Oqtane.Modules;
using SZUAbsolventenverein.Module.EventRegistration.Models;
namespace SZUAbsolventenverein.Module.EventRegistration.Repository
{
public class ResponseRepository : IResponseRepository, ITransientService
{
private readonly IDbContextFactory<EventRegistrationContext> _factory;
public ResponseRepository(IDbContextFactory<EventRegistrationContext> factory)
{
_factory = factory;
}
public IEnumerable<Response> GetResponses(int ModuleId)
{
using var db = _factory.CreateDbContext();
return db.Response.Where(item => item.ModuleId == ModuleId).ToList();
}
public IEnumerable<Response> GetResponses(int EventId, int ModuleId)
{
using var db = _factory.CreateDbContext();
return db.Response.Where(item => item.ModuleId == ModuleId && item.EventRegistrationId == EventId).ToList();
}
public Response GetResponse(int EventRegistrationId)
{
return GetResponse(EventRegistrationId, true);
}
public Response GetResponse(int EventRegistrationId, bool tracking)
{
using var db = _factory.CreateDbContext();
if (tracking)
{
return db.Response.Find(EventRegistrationId);
}
else
{
return db.Response.AsNoTracking().FirstOrDefault(item => item.EventRegistrationId == EventRegistrationId);
}
}
public Response GetResponse(int EventId, int OwnerId)
{
return GetResponse(EventId, OwnerId, true);
}
public Response GetResponse(int EventId, int OwnerId, bool tracking)
{
using var db = _factory.CreateDbContext();
if (tracking)
{
return db.Response.FirstOrDefault(item => item.EventRegistrationId == EventId && item.OwnerId == OwnerId);
}
else
{
return db.Response.AsNoTracking().FirstOrDefault(item => item.EventRegistrationId == EventId && item.OwnerId == OwnerId);
}
}
public Response AddResponse(Response EventResponse)
{
using var db = _factory.CreateDbContext();
db.Response.Add(EventResponse);
db.SaveChanges();
return EventResponse;
}
public Response UpdateResponse(Response EventResponse)
{
using var db = _factory.CreateDbContext();
db.Entry(EventResponse).State = EntityState.Modified;
db.SaveChanges();
return EventResponse;
}
public void DeleteResponse(int EventRegistrationId)
{
using var db = _factory.CreateDbContext();
Response EventResponse = db.Response.Find(EventRegistrationId);
db.Response.Remove(EventResponse);
db.SaveChanges();
}
}
}