Exemple #1
0
        public static void AddEvent(CqrsEvent <M> newCqrsEvent)
        {
            EventQueue.Enqueue(newCqrsEvent);

            // Triggering the subscriber actions
            SubscriberActions.ForEach(x => x.Invoke(newCqrsEvent));
        }
        public void Update <M>(List <M> modelsWithNewValues) where M : class, IModel, new()
        {
            api.Update(modelsWithNewValues, this.crudModels.UpdateModel);

            foreach (var model in modelsWithNewValues)
            {
                var eventForUpdatedModel = new CqrsEvent <M>(ECqrsEventType.UpdateEvent, model);
                CqrsEventHandler <M> .AddEvent(eventForUpdatedModel);
            }
        }
        public void Delete(List <M> modelsToDelete)
        {
            api.Delete(modelsToDelete, crudModels.DeleteModel);

            foreach (var deletedModel in modelsToDelete)
            {
                var eventForDeletedModel = new CqrsEvent <M>(ECqrsEventType.DeleteEvent, deletedModel);
                CqrsEventHandler <M> .AddEvent(eventForDeletedModel);
            }
        }
        public void Create(List <M> newModels)
        {
            api.Create(newModels, crudModels.CreateModel);

            foreach (var newModel in newModels)
            {
                var eventForNewModel = new CqrsEvent <M>(ECqrsEventType.CreateEvent, newModel);
                CqrsEventHandler <M> .AddEvent(eventForNewModel);
            }
        }