feat: добавил каталог достижений и автоначисление
🚀 Create and publish a Docker image / Detect changes in backend and frontend (push) Successful in 10s
🚀 Create and publish a Docker image / Build & publish backend image (push) Successful in 2m53s
🚀 Create and publish a Docker image / Build & publish frontend image (push) Successful in 28s
🚀 Create and publish a Docker image / Update stack on Portainer (push) Successful in 7s

Реализовал автосоздание и обновление каталога достижений на бэке и синхронизацию на фронте.
This commit is contained in:
2026-05-12 23:21:39 +03:00
parent dbba2be277
commit feff77b232
12 changed files with 446 additions and 12 deletions
@@ -12,7 +12,13 @@ namespace UniVerse.Infrastructure.Services;
public class LectureService : ILectureService
{
private readonly AppDbContext _db;
public LectureService(AppDbContext db) => _db = db;
private readonly IGamificationService _gamification;
public LectureService(AppDbContext db, IGamificationService gamification)
{
_db = db;
_gamification = gamification;
}
private IQueryable<Lecture> BaseQuery() => _db.Lectures
.Include(l => l.Course).Include(l => l.Teacher)
@@ -96,6 +102,7 @@ public class LectureService : ILectureService
throw new ConflictException("Already enrolled.");
_db.LectureEnrollments.Add(new LectureEnrollment { LectureId = lectureId, UserId = userId });
await _db.SaveChangesAsync();
await _gamification.CheckAndAwardAchievementsAsync(userId);
}
public async Task UnenrollAsync(int lectureId, int userId)
@@ -114,6 +121,8 @@ public class LectureService : ILectureService
?? throw new NotFoundException("Enrollment not found.");
enrollment.Attended = attended;
await _db.SaveChangesAsync();
if (attended)
await _gamification.CheckAndAwardAchievementsAsync(userId);
}
public async Task<PagedResult<EnrollmentDto>> GetEnrollmentsAsync(int lectureId, PaginationRequest pagination)