public static TCreateContactMech ToCreateContactMech <TCreateContactMech>(this IContactMechState state) where TCreateContactMech : ICreateContactMech, new() { var cmd = new TCreateContactMech(); cmd.Version = ((IContactMechStateProperties)state).Version; cmd.ContactMechId = state.ContactMechId; cmd.ContactMechTypeId = state.ContactMechTypeId; cmd.InfoString = state.InfoString; cmd.ToName = state.ToName; cmd.AttnName = state.AttnName; cmd.Address1 = state.Address1; cmd.Address2 = state.Address2; cmd.Directions = state.Directions; cmd.City = state.City; cmd.PostalCode = state.PostalCode; cmd.PostalCodeExt = state.PostalCodeExt; cmd.CountryGeoId = state.CountryGeoId; cmd.StateProvinceGeoId = state.StateProvinceGeoId; cmd.CountyGeoId = state.CountyGeoId; cmd.PostalCodeGeoId = state.PostalCodeGeoId; cmd.GeoPointId = state.GeoPointId; cmd.CountryCode = state.CountryCode; cmd.AreaCode = state.AreaCode; cmd.ContactNumber = state.ContactNumber; cmd.AskForName = state.AskForName; cmd.Active = ((IContactMechStateProperties)state).Active; return(cmd); }
public IContactMechState Get(string id) { IContactMechState state = CurrentSession.Get <ContactMechState>(id); if (ReadOnlyProxyGenerator != null && state != null) { return(ReadOnlyProxyGenerator.CreateProxy <IContactMechState>(state, new Type[] { }, _readOnlyPropertyNames)); } return(state); }
public static TDeleteContactMech ToDeleteContactMech <TDeleteContactMech>(this IContactMechState state) where TDeleteContactMech : IDeleteContactMech, new() { var cmd = new TDeleteContactMech(); cmd.ContactMechId = state.ContactMechId; cmd.Version = ((IContactMechStateProperties)state).Version; return(cmd); }
public IContactMechState Get(string id, bool nullAllowed) { IContactMechState state = CurrentSession.Get <ContactMechState> (id); if (!nullAllowed && state == null) { state = new ContactMechState(); (state as ContactMechState).ContactMechId = id; } if (ReadOnlyProxyGenerator != null && state != null) { return(ReadOnlyProxyGenerator.CreateProxy <IContactMechState>(state, new Type[] { }, _readOnlyPropertyNames)); } return(state); }
public async Task <IContactMechState> GetAsync(string contactMechId) { IContactMechState state = null; var idObj = contactMechId; var uriParameters = new ContactMechUriParameters(); uriParameters.Id = idObj; var req = new ContactMechGetRequest(uriParameters); var resp = await _ramlClient.ContactMech.Get(req); ContactMechProxyUtils.ThrowOnHttpResponseError(resp); state = (resp.Content == null) ? null : resp.Content.ToContactMechState(); return(state); }
public void Save(IContactMechState state) { IContactMechState s = state; if (ReadOnlyProxyGenerator != null) { s = ReadOnlyProxyGenerator.GetTarget <IContactMechState>(state); } CurrentSession.SaveOrUpdate(s); var saveable = s as ISaveable; if (saveable != null) { saveable.Save(); } CurrentSession.Flush(); }
public override IContactMechAggregate GetContactMechAggregate(IContactMechState state) { return(new ContactMechAggregate(state)); }
public ContactMechAggregate(IContactMechState state) { _state = state; }
protected bool IsRepeatedCommand(IContactMechCommand command, IEventStoreAggregateId eventStoreAggregateId, IContactMechState state) { bool repeated = false; if (((IContactMechStateProperties)state).Version > command.AggregateVersion) { var lastEvent = EventStore.GetEvent(typeof(IContactMechEvent), eventStoreAggregateId, command.AggregateVersion); if (lastEvent != null && lastEvent.CommandId == command.CommandId) { repeated = true; } } return(repeated); }
private void Persist(IEventStoreAggregateId eventStoreAggregateId, IContactMechAggregate aggregate, IContactMechState state) { EventStore.AppendEvents(eventStoreAggregateId, ((IContactMechStateProperties)state).Version, aggregate.Changes, () => { StateRepository.Save(state); }); if (AggregateEventListener != null) { AggregateEventListener.EventAppended(new AggregateEvent <IContactMechAggregate, IContactMechState>(aggregate, state, aggregate.Changes)); } }
public abstract IContactMechAggregate GetContactMechAggregate(IContactMechState state);
public ContactMechStateDtoWrapper(IContactMechState state) { this._state = state; }
public ContactMechStateDtoWrapper() { this._state = new ContactMechState(); }
public static TMergePatchContactMech ToMergePatchContactMech <TMergePatchContactMech>(this IContactMechState state) where TMergePatchContactMech : IMergePatchContactMech, new() { var cmd = new TMergePatchContactMech(); cmd.Version = ((IContactMechStateProperties)state).Version; cmd.ContactMechId = state.ContactMechId; cmd.ContactMechTypeId = state.ContactMechTypeId; cmd.InfoString = state.InfoString; cmd.ToName = state.ToName; cmd.AttnName = state.AttnName; cmd.Address1 = state.Address1; cmd.Address2 = state.Address2; cmd.Directions = state.Directions; cmd.City = state.City; cmd.PostalCode = state.PostalCode; cmd.PostalCodeExt = state.PostalCodeExt; cmd.CountryGeoId = state.CountryGeoId; cmd.StateProvinceGeoId = state.StateProvinceGeoId; cmd.CountyGeoId = state.CountyGeoId; cmd.PostalCodeGeoId = state.PostalCodeGeoId; cmd.GeoPointId = state.GeoPointId; cmd.CountryCode = state.CountryCode; cmd.AreaCode = state.AreaCode; cmd.ContactNumber = state.ContactNumber; cmd.AskForName = state.AskForName; cmd.Active = ((IContactMechStateProperties)state).Active; if (state.ContactMechTypeId == null) { cmd.IsPropertyContactMechTypeIdRemoved = true; } if (state.InfoString == null) { cmd.IsPropertyInfoStringRemoved = true; } if (state.ToName == null) { cmd.IsPropertyToNameRemoved = true; } if (state.AttnName == null) { cmd.IsPropertyAttnNameRemoved = true; } if (state.Address1 == null) { cmd.IsPropertyAddress1Removed = true; } if (state.Address2 == null) { cmd.IsPropertyAddress2Removed = true; } if (state.Directions == null) { cmd.IsPropertyDirectionsRemoved = true; } if (state.City == null) { cmd.IsPropertyCityRemoved = true; } if (state.PostalCode == null) { cmd.IsPropertyPostalCodeRemoved = true; } if (state.PostalCodeExt == null) { cmd.IsPropertyPostalCodeExtRemoved = true; } if (state.CountryGeoId == null) { cmd.IsPropertyCountryGeoIdRemoved = true; } if (state.StateProvinceGeoId == null) { cmd.IsPropertyStateProvinceGeoIdRemoved = true; } if (state.CountyGeoId == null) { cmd.IsPropertyCountyGeoIdRemoved = true; } if (state.PostalCodeGeoId == null) { cmd.IsPropertyPostalCodeGeoIdRemoved = true; } if (state.GeoPointId == null) { cmd.IsPropertyGeoPointIdRemoved = true; } if (state.CountryCode == null) { cmd.IsPropertyCountryCodeRemoved = true; } if (state.AreaCode == null) { cmd.IsPropertyAreaCodeRemoved = true; } if (state.ContactNumber == null) { cmd.IsPropertyContactNumberRemoved = true; } if (state.AskForName == null) { cmd.IsPropertyAskForNameRemoved = true; } return(cmd); }
public static IContactMechCommand ToCreateOrMergePatchContactMech <TCreateContactMech, TMergePatchContactMech>(this IContactMechState state) where TCreateContactMech : ICreateContactMech, new() where TMergePatchContactMech : IMergePatchContactMech, new() { bool bUnsaved = ((IContactMechState)state).IsUnsaved; if (bUnsaved) { return(state.ToCreateContactMech <TCreateContactMech>()); } else { return(state.ToMergePatchContactMech <TMergePatchContactMech>()); } }