Exemplo n.º 1
0
 public async Task <Result <Exam> > GetAsync(ExamId identifier)
 {
     return(Maybe <Exam> .From(await _examsDbContext.Exams.SingleOrDefaultAsync(exam => exam.Id == identifier))
            .ToResult(DomainErrors.BuildAggregateNotFound(nameof(Exam), identifier.Value)));
 }
Exemplo n.º 2
0
 public static Result <ExamId> Create(long examId, IExamExistenceValidator examExistenceValidator)
 {
     return(Result.Create(() => examId > 0, DomainErrors.BuildInvalidIdentifier(examId))
            .AndEnsure(() => examExistenceValidator.Exist(examId), DomainErrors.BuildAggregateNotFound("Exam", examId))
            .OnSuccess(() => new ExamId(examId)));
 }