public override EventStream LoadEventStream(Type eventType, IEventStoreAggregateId eventStoreAggregateId, long version) { Type supportedEventType = typeof(RolePermissionStateEventBase); if (!eventType.IsAssignableFrom(supportedEventType)) { throw new NotSupportedException(); } RolePermissionId idObj = (RolePermissionId)(eventStoreAggregateId as EventStoreAggregateId).Id; var criteria = CurrentSession.CreateCriteria <RolePermissionStateEventBase>(); criteria.Add(Restrictions.Eq("StateEventId.IdRoleId", idObj.RoleId)); criteria.Add(Restrictions.Eq("StateEventId.IdPermissionId", idObj.PermissionId)); criteria.Add(Restrictions.Le("StateEventId.Version", version)); criteria.AddOrder(Order.Asc("StateEventId.Version")); var es = criteria.List <IEvent>(); foreach (RolePermissionStateEventBase e in es) { e.StateEventReadOnly = true; } return(new EventStream() { SteamVersion = es.Count > 0 ? ((RolePermissionStateEventBase)es.Last()).StateEventId.Version : default(long), Events = es }); }
public static string ToIdString(RolePermissionId id) { var formatter = new RolePermissionIdFlattenedDtoFormatter(); var idDto = new RolePermissionIdFlattenedDto(id); var idStr = formatter.ToString(idDto); return(idStr); }
public IRolePermissionState Get(RolePermissionId id) { IRolePermissionState state = CurrentSession.Get <RolePermissionState>(id); if (ReadOnlyProxyGenerator != null && state != null) { return(ReadOnlyProxyGenerator.CreateProxy <IRolePermissionState>(state, new Type[] { }, _readOnlyPropertyNames)); } return(state); }
public IRolePermissionState Get(RolePermissionId id) { IRolePermissionState state = CurrentSession.Get <RolePermissionState> (id); if (state == null) { state = new RolePermissionState(); (state as RolePermissionState).Id = id; } return(state); }
public async Task <IRolePermissionStateEvent> GetStateEventAsync(RolePermissionId id, long version) { var idObj = RolePermissionProxyUtils.ToIdString(id); var uriParameters = new RolePermissionStateEventUriParameters(); uriParameters.Id = idObj; uriParameters.Version = version.ToString(); var req = new RolePermissionStateEventGetRequest(uriParameters); var resp = await _ramlClient.RolePermissionStateEvent.Get(req); RolePermissionProxyUtils.ThrowOnHttpResponseError(resp); return(resp.Content); }
public virtual IRolePermissionEvent GetEvent(RolePermissionId id, long version) { var e = (IRolePermissionEvent)EventStore.GetEvent(ToEventStoreAggregateId(id), version); if (e != null) { e.ReadOnly = true; } else if (version == -1) { return(GetEvent(id, 0)); } return(e); }
public IRolePermissionState Get(RolePermissionId id, bool nullAllowed) { IRolePermissionState state = CurrentSession.Get <RolePermissionState> (id); if (!nullAllowed && state == null) { state = new RolePermissionState(); (state as RolePermissionState).Id = id; } if (ReadOnlyProxyGenerator != null && state != null) { return(ReadOnlyProxyGenerator.CreateProxy <IRolePermissionState>(state, new Type[] { }, _readOnlyPropertyNames)); } return(state); }
public async Task <IRolePermissionState> GetAsync(RolePermissionId id) { IRolePermissionState state = null; var idObj = RolePermissionProxyUtils.ToIdString(id); var uriParameters = new RolePermissionUriParameters(); uriParameters.Id = idObj; var req = new RolePermissionGetRequest(uriParameters); var resp = await _ramlClient.RolePermission.Get(req); RolePermissionProxyUtils.ThrowOnHttpResponseError(resp); state = resp.Content; return(state); }
public IRolePermissionStateEvent GetStateEvent(RolePermissionId id, long version) { return(GetStateEventAsync(id, version).GetAwaiter().GetResult()); }
public IRolePermissionState Get(RolePermissionId id) { return(GetAsync(id).GetAwaiter().GetResult()); }
public RolePermissionEventId(RolePermissionId id, long version) { this._id = id; this._version = version; }
public abstract IEventStoreAggregateId ToEventStoreAggregateId(RolePermissionId aggregateId);
public virtual IRolePermissionState GetHistoryState(RolePermissionId id, long version) { var eventStream = EventStore.LoadEventStream(typeof(IRolePermissionEvent), ToEventStoreAggregateId(id), version - 1); return(new RolePermissionState(eventStream.Events)); }
public virtual IRolePermissionState Get(RolePermissionId id) { var state = StateRepository.Get(id, true); return(state); }
public override IEventStoreAggregateId ToEventStoreAggregateId(RolePermissionId aggregateId) { return(new EventStoreAggregateId(aggregateId)); }