public async Task <CommandResponse <Event> > Handle(EventSaveCommand request, CancellationToken cancellationToken) { var result = new CommandResponse <Event>() { Errors = GetRequestErrors(request) }; if (result.Errors.Count == 0) { try { var aggregate = new EventAggregate(_dbContext); await aggregate.EventSaveAsync(request.Item); result.Result = (Event)request.Item; } catch (Exception e) { Console.WriteLine(e); result.ErrorInfo = new ErrorInfo() { UserErrorMessage = "An internal error has occured", HasException = true }; } } return(result); }
public async Task <bool> Add(EventAggregate evtAggregate) { try { var record = evtAggregate.ToModel(); _context.Events.Add(record); await _context.SaveChangesAsync().ConfigureAwait(false); return(true); } catch { return(false); } }
public static JObject ToDto(this EventAggregate evt) { if (evt == null) { throw new ArgumentNullException(nameof(evt)); } var result = new JObject(); result.Add(new JProperty(Core.Common.EventResponseNames.Id, evt.Id)); result.Add(new JProperty(Core.Common.EventResponseNames.AggregateId, evt.AggregateId)); result.Add(new JProperty(Core.Common.EventResponseNames.Description, evt.Description)); result.Add(new JProperty(Core.Common.EventResponseNames.CreatedOn, evt.CreatedOn)); result.Add(new JProperty(Core.Common.EventResponseNames.Payload, evt.Payload)); return(result); }
public static Domain.EventAggregate ToDomain(this EventAggregate evtAggregate) { if (evtAggregate == null) { throw new ArgumentNullException(nameof(evtAggregate)); } return(new Domain.EventAggregate { Id = evtAggregate.Id, AggregateId = evtAggregate.AggregateId, Order = evtAggregate.Order, CreatedOn = evtAggregate.CreatedOn, Description = evtAggregate.Description, Payload = evtAggregate.Payload }); }
public static Domain.EventAggregate ToDomain(this EventAggregate evtAggregate) { if (evtAggregate == null) { throw new ArgumentNullException(nameof(evtAggregate)); } return(new Domain.EventAggregate { Id = evtAggregate.Id, AggregateId = evtAggregate.AggregateId, Order = evtAggregate.Order, CreatedOn = evtAggregate.CreatedOn, Description = evtAggregate.Description, Payload = evtAggregate.Payload, Type = evtAggregate.Type, Key = evtAggregate.Key, Verbosity = (Domain.EventVerbosities)evtAggregate.Verbosity }); }