Пример #1
0
 public Relationship(MarketParticipantMrid marketParticipantMrid, RelationshipType type, Instant effectuationDate)
 {
     MarketParticipantMrid = marketParticipantMrid ?? throw new ArgumentNullException(nameof(marketParticipantMrid));
     Type             = type ?? throw new ArgumentNullException(nameof(type));
     EffectuationDate = effectuationDate;
     State            = RelationshipState.Pending;
 }
Пример #2
0
        public BusinessRulesValidationResult CanChangeSupplier(MarketParticipantMrid energySupplierMrid, Instant effectuationDate, ISystemDateTimeProvider systemDateTimeProvider)
        {
            if (energySupplierMrid is null)
            {
                throw new ArgumentNullException(nameof(energySupplierMrid));
            }

            if (systemDateTimeProvider == null)
            {
                throw new ArgumentNullException(nameof(systemDateTimeProvider));
            }

            var rules = new List <IBusinessRule>()
            {
                new MeteringPointMustBeEnergySuppliableRule(_meteringPointType),
                new ProductionMeteringPointMustBeObligatedRule(_meteringPointType, _isProductionObligated),
                new CannotBeInStateOfClosedDownRule(_physicalState),
                new MustHaveEnergySupplierAssociatedRule(_relationships.AsReadOnly()),
                new ChangeOfSupplierRegisteredOnSameDateIsNotAllowedRule(_relationships.AsReadOnly(), effectuationDate),
                new MoveInRegisteredOnSameDateIsNotAllowedRule(_relationships.AsReadOnly(), effectuationDate),
                new MoveOutRegisteredOnSameDateIsNotAllowedRule(_relationships.AsReadOnly(), effectuationDate),
                new EffectuationDateCannotBeInThePastRule(effectuationDate, systemDateTimeProvider.Now()),
            };

            return(new BusinessRulesValidationResult(rules));
        }
Пример #3
0
 private Relationship(int id, MarketParticipantMrid marketParticipantMrid, RelationshipType type, RelationshipState state, Instant effectuationDate)
 {
     Id = id;
     MarketParticipantMrid = marketParticipantMrid ?? throw new ArgumentNullException(nameof(marketParticipantMrid));
     Type             = type ?? throw new ArgumentNullException(nameof(type));
     EffectuationDate = effectuationDate;
     State            = state;
 }
Пример #4
0
        public void RegisterMoveOut(MarketParticipantMrid customerMrid, Instant effectuationDate)
        {
            if (customerMrid is null)
            {
                throw new ArgumentNullException(nameof(customerMrid));
            }

            _relationships.Add(new Relationship(customerMrid, RelationshipType.MoveOut, effectuationDate));
        }
Пример #5
0
        public void RegisterChangeOfEnergySupplier(MarketParticipantMrid energySupplierMrid, Instant effectuationDate, ISystemDateTimeProvider systemDateTimeProvider)
        {
            if (!CanChangeSupplier(energySupplierMrid, effectuationDate, systemDateTimeProvider).Success)
            {
                throw new InvalidOperationException();
            }

            _relationships.Add(new Relationship(energySupplierMrid, RelationshipType.EnergySupplier, effectuationDate));
            //TODO: Refactor along with new Comsumer/Supplier concepts
            AddDomainEvent(new EnergySupplierChangeRegistered(GsrnNumber, new ProcessId("TODO"), effectuationDate));
        }
Пример #6
0
        public void RegisterMoveIn(MarketParticipantMrid customerMrid, MarketParticipantMrid energySupplierMrid, Instant effectuationDate)
        {
            if (customerMrid is null)
            {
                throw new ArgumentNullException(nameof(customerMrid));
            }

            if (energySupplierMrid is null)
            {
                throw new ArgumentNullException(nameof(energySupplierMrid));
            }

            _relationships.Add(new Relationship(customerMrid, RelationshipType.Customer1, effectuationDate));
            _relationships.Add(new Relationship(energySupplierMrid, RelationshipType.EnergySupplier, effectuationDate));
        }
Пример #7
0
        public void ActivateMoveIn(MarketParticipantMrid customerMrid, MarketParticipantMrid energySupplierMrid)
        {
            if (customerMrid is null)
            {
                throw new ArgumentNullException(nameof(customerMrid));
            }

            if (energySupplierMrid is null)
            {
                throw new ArgumentNullException(nameof(energySupplierMrid));
            }

            var customerRelation = _relationships.First(r =>
                                                        r.MarketParticipantMrid.Equals(customerMrid) && r.Type == RelationshipType.Customer1);

            customerRelation.Activate();

            var energySupplierRelation = _relationships.First(r =>
                                                              r.MarketParticipantMrid.Equals(energySupplierMrid) && r.Type == RelationshipType.EnergySupplier);

            energySupplierRelation.Activate();
        }