public static Result <Order> Create(ContactData seller, ContactData buyer, IReadOnlyCollection <OrderItem> items,
                                            ISystemTimeProvider systemTimeProvider, ISingleCurrencyPolicy singleCurrencyPolicy, ISingleItemsCurrencyPolicy singleItemsCurrencyPolicy)
        {
            var creationDateResult = UtcDateTime.Create(systemTimeProvider.UtcNow);
            var summaryResult      = CreateSummary(items, singleItemsCurrencyPolicy, singleCurrencyPolicy);

            return(Result.Combine(creationDateResult, summaryResult)
                   .OnSuccess(() => new Order(creationDateResult.Value, seller, buyer, items, summaryResult.Value,
                                              systemTimeProvider)));
        }
Example #2
0
        public async Task ShouldNotCreateExamWithRegistrationEndDateAfterExamDate()
        {
            var examDateTime          = UtcDateTime.Create(new DateTime(2020, 03, 10, 12, 00, 00, DateTimeKind.Utc)).Value;
            var registrationStartDate = UtcDate.Create(new DateTime(2020, 02, 08, 00, 00, 00, DateTimeKind.Utc)).Value;
            var registrationEndDate   = UtcDate.Create(new DateTime(2020, 03, 12, 00, 00, 00, DateTimeKind.Utc)).Value;

            var examResult = await Exam.CreateAsync(_subjectId, _locationId, examDateTime, _capacity,
                                                    registrationStartDate, registrationEndDate, _systemTimeProvider.Object, _examRepository.Object);

            examResult.IsSuccess.Should().BeFalse();
        }
        public static Result <CreateExamCommand> Create(CreateExamRequest request,
                                                        ISubjectExistenceValidator subjectExistenceValidator,
                                                        ILocationExistenceValidator locationExistenceValidator)
        {
            var subjectId = SubjectId.Create(request.SubjectId, subjectExistenceValidator)
                            .BindErrorsTo(nameof(request.SubjectId));
            var locationId = LocationId.Create(request.LocationId, locationExistenceValidator)
                             .BindErrorsTo(nameof(request.LocationId));
            var examDateTime = UtcDateTime.Create(request.ExamDateTime)
                               .BindErrorsTo(nameof(request.ExamDateTime));
            var capacity = Capacity.Create(request.Capacity)
                           .BindErrorsTo(nameof(request.Capacity));
            var registrationStartDate = UtcDate.Create(request.RegistrationStartDate)
                                        .BindErrorsTo(nameof(request.RegistrationStartDate));
            var registrationEndDate = UtcDate.Create(request.RegistrationEndDate)
                                      .BindErrorsTo(nameof(request.RegistrationEndDate));

            return(Result.Combine(subjectId, locationId, examDateTime, capacity, registrationStartDate,
                                  registrationEndDate)
                   .OnSuccess(() => new CreateExamCommand(subjectId.Value, locationId.Value, examDateTime.Value,
                                                          capacity.Value, registrationStartDate.Value, registrationEndDate.Value)));
        }
        public void ShouldReturnExpectedResult(DateTime dateTime, bool isSuccess)
        {
            var utcDateTimeResult = UtcDateTime.Create(dateTime);

            utcDateTimeResult.IsSuccess.Should().Be(isSuccess);
        }