public async Task Increment(CourseId id) { var counter = await _repository.Search() ?? InitializeCounter(); if (!counter.HasIncremented(id)) { counter.Increment(id); await _repository.Save(counter); } }
public async Task <CoursesCounterResponse> Find() { var coursesCounter = await _repository.Search() ?? throw new CoursesCounterNotInitialized(); return(new CoursesCounterResponse(coursesCounter.Total.Value)); }