Exemple #1
0
        public static TCreateParty ToCreateParty <TCreateParty>(this IPartyState state)
            where TCreateParty : ICreateParty, new()
        {
            var cmd = new TCreateParty();

            cmd.Version = ((IPartyStateProperties)state).Version;

            cmd.PartyId                = state.PartyId;
            cmd.PartyTypeId            = state.PartyTypeId;
            cmd.PrimaryRoleTypeId      = state.PrimaryRoleTypeId;
            cmd.ExternalId             = state.ExternalId;
            cmd.PreferredCurrencyUomId = state.PreferredCurrencyUomId;
            cmd.Description            = state.Description;
            cmd.OrganizationName       = state.OrganizationName;
            cmd.IsSummary              = state.IsSummary;
            cmd.Salutation             = state.Salutation;
            cmd.FirstName              = state.FirstName;
            cmd.MiddleName             = state.MiddleName;
            cmd.LastName               = state.LastName;
            cmd.PersonalTitle          = state.PersonalTitle;
            cmd.Nickname               = state.Nickname;
            cmd.CardId = state.CardId;
            cmd.Active = ((IPartyStateProperties)state).Active;
            return(cmd);
        }
        public IPartyState Get(string id)
        {
            IPartyState state = CurrentSession.Get <PartyState>(id);

            if (ReadOnlyProxyGenerator != null && state != null)
            {
                return(ReadOnlyProxyGenerator.CreateProxy <IPartyState>(state, new Type[] {  }, _readOnlyPropertyNames));
            }
            return(state);
        }
Exemple #3
0
        public static TDeleteParty ToDeleteParty <TDeleteParty>(this IPartyState state)
            where TDeleteParty : IDeleteParty, new()
        {
            var cmd = new TDeleteParty();

            cmd.PartyId = state.PartyId;
            cmd.Version = ((IPartyStateProperties)state).Version;

            return(cmd);
        }
        public IPartyState Get(Type type, string id, bool nullAllowed)
        {
            IPartyState state = CurrentSession.Get <PartyState> (id);

            if (state != null && !type.IsAssignableFrom(state.GetType()))
            {
                throw new InvalidCastException(String.Format("state is NOT instance of {0}", type.Name));
            }
            if (!nullAllowed && state == null)
            {
                state = NewEmptyState(type);
                (state as PartyState).PartyId = id;
            }
            return(state);
        }
Exemple #5
0
        public async Task <IPartyState> GetAsync(string partyId)
        {
            IPartyState state         = null;
            var         idObj         = partyId;
            var         uriParameters = new PartyUriParameters();

            uriParameters.Id = idObj;

            var req = new PartyGetRequest(uriParameters);

            var resp = await _ramlClient.Party.Get(req);

            PartyProxyUtils.ThrowOnHttpResponseError(resp);
            state = (resp.Content == null) ? null : resp.Content.ToPartyState();
            return(state);
        }
Exemple #6
0
        public static TCreateParty ToCreateParty <TCreateParty>(this IPartyState state)
            where TCreateParty : ICreateParty, new()
        {
            var cmd = new TCreateParty();

            cmd.Version = ((IPartyStateProperties)state).Version;

            cmd.PartyId           = state.PartyId;
            cmd.PartyTypeId       = state.PartyTypeId;
            cmd.PrimaryRoleTypeId = state.PrimaryRoleTypeId;
            cmd.OrganizationName  = state.OrganizationName;
            cmd.Description       = state.Description;
            cmd.Type      = state.Type;
            cmd.IsSummary = state.IsSummary;
            cmd.Active    = ((IPartyStateProperties)state).Active;
            return(cmd);
        }
        public void Save(IPartyState state)
        {
            IPartyState s = state;

            if (ReadOnlyProxyGenerator != null)
            {
                s = ReadOnlyProxyGenerator.GetTarget <IPartyState>(state);
            }
            CurrentSession.SaveOrUpdate(s);

            var saveable = s as ISaveable;

            if (saveable != null)
            {
                saveable.Save();
            }
            CurrentSession.Flush();
        }
Exemple #8
0
        public static TMergePatchParty ToMergePatchParty <TMergePatchParty>(this IPartyState state)
            where TMergePatchParty : IMergePatchParty, new()
        {
            var cmd = new TMergePatchParty();

            cmd.Version = ((IPartyStateProperties)state).Version;

            cmd.PartyId           = state.PartyId;
            cmd.PartyTypeId       = state.PartyTypeId;
            cmd.PrimaryRoleTypeId = state.PrimaryRoleTypeId;
            cmd.OrganizationName  = state.OrganizationName;
            cmd.Description       = state.Description;
            cmd.Type      = state.Type;
            cmd.IsSummary = state.IsSummary;
            cmd.Active    = ((IPartyStateProperties)state).Active;

            if (state.PartyTypeId == null)
            {
                cmd.IsPropertyPartyTypeIdRemoved = true;
            }
            if (state.PrimaryRoleTypeId == null)
            {
                cmd.IsPropertyPrimaryRoleTypeIdRemoved = true;
            }
            if (state.OrganizationName == null)
            {
                cmd.IsPropertyOrganizationNameRemoved = true;
            }
            if (state.Description == null)
            {
                cmd.IsPropertyDescriptionRemoved = true;
            }
            if (state.Type == null)
            {
                cmd.IsPropertyTypeRemoved = true;
            }
            return(cmd);
        }
Exemple #9
0
 public PartyStateDtoWrapper()
 {
     this._state = new PartyState();
 }
Exemple #10
0
 private void Persist(IEventStoreAggregateId eventStoreAggregateId, IPartyAggregate aggregate, IPartyState state)
 {
     EventStore.AppendEvents(eventStoreAggregateId, ((IPartyStateProperties)state).Version, aggregate.Changes, () => { StateRepository.Save(state); });
     if (AggregateEventListener != null)
     {
         AggregateEventListener.EventAppended(new AggregateEvent <IPartyAggregate, IPartyState>(aggregate, state, aggregate.Changes));
     }
 }
Exemple #11
0
 public abstract IPartyAggregate GetPartyAggregate(IPartyState state);
Exemple #12
0
        protected bool IsRepeatedCommand(IPartyCommand command, IEventStoreAggregateId eventStoreAggregateId, IPartyState state)
        {
            bool repeated = false;

            if (((IPartyStateProperties)state).Version > command.AggregateVersion)
            {
                var lastEvent = EventStore.GetEvent(typeof(IPartyEvent), eventStoreAggregateId, command.AggregateVersion);
                if (lastEvent != null && lastEvent.CommandId == command.CommandId)
                {
                    repeated = true;
                }
            }
            return(repeated);
        }
 public override IPartyAggregate GetPartyAggregate(IPartyState state)
 {
     return(new PartyAggregate(state));
 }
Exemple #14
0
 public PartyAggregate(IPartyState state)
 {
     _state = state;
 }
Exemple #15
0
 public PartyStateDtoWrapper(IPartyState state)
 {
     this._state = state;
 }
Exemple #16
0
        public static TMergePatchParty ToMergePatchParty <TMergePatchParty>(this IPartyState state)
            where TMergePatchParty : IMergePatchParty, new()
        {
            var cmd = new TMergePatchParty();

            cmd.Version = ((IPartyStateProperties)state).Version;

            cmd.PartyId                = state.PartyId;
            cmd.PartyTypeId            = state.PartyTypeId;
            cmd.PrimaryRoleTypeId      = state.PrimaryRoleTypeId;
            cmd.ExternalId             = state.ExternalId;
            cmd.PreferredCurrencyUomId = state.PreferredCurrencyUomId;
            cmd.Description            = state.Description;
            cmd.OrganizationName       = state.OrganizationName;
            cmd.IsSummary              = state.IsSummary;
            cmd.Salutation             = state.Salutation;
            cmd.FirstName              = state.FirstName;
            cmd.MiddleName             = state.MiddleName;
            cmd.LastName               = state.LastName;
            cmd.PersonalTitle          = state.PersonalTitle;
            cmd.Nickname               = state.Nickname;
            cmd.CardId = state.CardId;
            cmd.Active = ((IPartyStateProperties)state).Active;

            if (state.PartyTypeId == null)
            {
                cmd.IsPropertyPartyTypeIdRemoved = true;
            }
            if (state.PrimaryRoleTypeId == null)
            {
                cmd.IsPropertyPrimaryRoleTypeIdRemoved = true;
            }
            if (state.ExternalId == null)
            {
                cmd.IsPropertyExternalIdRemoved = true;
            }
            if (state.PreferredCurrencyUomId == null)
            {
                cmd.IsPropertyPreferredCurrencyUomIdRemoved = true;
            }
            if (state.Description == null)
            {
                cmd.IsPropertyDescriptionRemoved = true;
            }
            if (state.OrganizationName == null)
            {
                cmd.IsPropertyOrganizationNameRemoved = true;
            }
            if (state.Salutation == null)
            {
                cmd.IsPropertySalutationRemoved = true;
            }
            if (state.FirstName == null)
            {
                cmd.IsPropertyFirstNameRemoved = true;
            }
            if (state.MiddleName == null)
            {
                cmd.IsPropertyMiddleNameRemoved = true;
            }
            if (state.LastName == null)
            {
                cmd.IsPropertyLastNameRemoved = true;
            }
            if (state.PersonalTitle == null)
            {
                cmd.IsPropertyPersonalTitleRemoved = true;
            }
            if (state.Nickname == null)
            {
                cmd.IsPropertyNicknameRemoved = true;
            }
            if (state.CardId == null)
            {
                cmd.IsPropertyCardIdRemoved = true;
            }
            return(cmd);
        }
Exemple #17
0
        public static IPartyCommand ToCreateOrMergePatchParty <TCreateParty, TMergePatchParty>(this IPartyState state)
            where TCreateParty : ICreateParty, new()
            where TMergePatchParty : IMergePatchParty, new()
        {
            bool bUnsaved = ((IPartyState)state).IsUnsaved;

            if (bUnsaved)
            {
                return(state.ToCreateParty <TCreateParty>());
            }
            else
            {
                return(state.ToMergePatchParty <TMergePatchParty>());
            }
        }