private async ValueTask <IActionResult> HandleAsync(FixtureEvent fixtureEvent) { string eventHandlerTypeName = $"{fixtureEvent.GetType().Name}Handler"; string eventHandlerTypeFullName = $"LabCMS.FixtureDomain.Server.EventHandles.{eventHandlerTypeName}"; Type eventHandlerType = _fixtureEventAssembly.GetType(eventHandlerTypeFullName) !; FixtureEventHandler eventHandler = _handlersFactory.Create(eventHandlerType, _repository); await eventHandler.HandleAsync(fixtureEvent); return(Ok()); }
private async ValueTask InterceptAsync(IInvocation invocation) { var proceed = invocation.CaptureProceedInfo(); FixtureEventHandler target = (invocation.InvocationTarget as FixtureEventHandler) !; FixtureEvent fixtureEvent = (invocation.Arguments[0] as FixtureEvent) !; await target.HandleAsync(fixtureEvent); await target.Repository.FixtureEventsInDatabase.AddAsync( FixtureEventInDatabase.GetEntity(fixtureEvent)); await target.Repository.SaveChangesAsync(); proceed.Invoke(); }