public void CanBeSerialized()
        {
            //Arrange
            var fakeReport = new ReportRoot();
            var sut        = new UpdateReportCommand(fakeReport);

            //Act
            var json = JsonSerializer.Serialize(sut);

            //Assert
            Assert.False(string.IsNullOrEmpty(json));
        }
        public void CanBeConstructed()
        {
            //Arrange
            var fakeReport = new ReportRoot();
            var sut        = new UpdateReportCommand(fakeReport);

            //Act
            var hashCode = sut.GetHashCode();

            //Assert
            Assert.NotNull(sut);
            Assert.Equal(hashCode, sut.GetHashCode());
            Assert.Equal(fakeReport, sut.Report);
        }
        public Task Handle(IOrganizationUpdated message, IMessageHandlerContext context)
        {
            var tasks = new List <Task>();

            _session.Query <Report>()
            .Where(o => o.Organization.Id == message.Organization.Id).ToList()
            .ForEach(r =>
            {
                var cmd = new UpdateReportCommand(r.Id, r.Description, message.Organization, r.ReportingPeriod.Year,
                                                  r.ReportingPeriod.ReportingTerm);
                tasks.Add(context.Send(cmd));
            });
            return(Task.WhenAll(tasks));
        }
Пример #4
0
        public ICommand <IAggregateRoot> Convert(IAggregateRoot source, ICommand <IAggregateRoot> destination = default, ResolutionContext context = default)
        {
            switch (source)
            {
            case ReportRoot report:
                if (report.Id == Guid.Empty)
                {
                    destination = new CreateReportCommand(report.CostItems);
                }
                else
                {
                    destination = new UpdateReportCommand(report);
                }

                break;

            case null:
            default:
                break;
            }

            return(destination);
        }
        public void Set(ReportDto report)
        {
            var command = new UpdateReportCommand(report);

            _commandDispatcher.Handle(command);
        }
Пример #6
0
 public async Task <ReportRoot> Update(UpdateReportCommand command)
 {
     return(await _applicationFacade.Execute(command));
 }