Пример #1
0
        // partially apply the domain model to updateDomainForExchangeData.
        private Func <Either <StateChangeError, ExchangeData>, Either <StateChangeError, StateChangeEvent> > getUpdateDomainFunc
            (DomainModel domainModel)
        {
            if (domainModel == null)
            {
                throw new ArgumentNullException(nameof(domainModel));
            }


            return(either => either.IfRight(data => updateDomainForExchangeData(domainModel, data)));
        }
Пример #2
0
        /// Update the exchange if the exchange already exists or create a
        /// new exchange if it does not.
        private Either <StateChangeError, StateChangeEvent> updateDomainForExchangeData
            (DomainModel domainModel
            , ExchangeData data)
        {
            if (domainModel == null)
            {
                throw new ArgumentNullException(nameof(domainModel));
            }
            if (data == null)
            {
                throw new ArgumentNullException(nameof(data));
            }


            return
                (domainModel
                 .GetCommandForNewExchangeData(data)
                 .Execute());
        }
Пример #3
0
        public ServiceResponse Handle
            (ServiceRequest request)
        {
            if (request == null)
            {
                throw new ArgumentNullException(nameof(request));
            }


            var domainModel  = new DomainModel(request.DataModel);
            var updateDomain = getUpdateDomainFunc(domainModel);

            return
                (this
                 .deserialise(request.Message)
                 .Select(updateDomain)
                 .Aggregate(
                     new ResponseAccumulator()
                     , collateUpdateResponses
                     , (acc) => new ServiceResponse(acc.Events, acc.Errors)
                     ));
        }