Exemple #1
0
 private Ukol Modify(EventUkolUpdated evt, Ukol item)
 {
     item.EventGuid = evt.EventId;
     item.Value1    = evt.UkolValue1;
     item.Value2    = evt.UkolValue2;
     return(item);
 }
Exemple #2
0
        public async Task Update(CommandUkolUpdate cmd)
        {
            var item = db.Ukoly.FirstOrDefault(u => u.UkolId == cmd.UkolId);

            if (item != null)
            {
                var ev = new EventUkolUpdated()
                {
                    EventId    = Guid.NewGuid(),
                    UkolValue1 = cmd.UkolValue1,
                    UkolValue2 = cmd.UkolValue2,
                };
                ev.Generation = item.Generation + 1;
                item          = Modify(ev, item);
                await _handler.PublishEvent(ev, MessageType.UkolUpdated, ev.EventId, item.EventGuid, ev.Generation, cmd.UkolId);

                db.Ukoly.Update(item);
                await db.SaveChangesAsync();
            }
        }