public void Handle(EventCreated @event, TicketManagementDbContext db) { var eventsListModel = new EventsListReadModel() { Date = @event.Event.Date, IsSoldOut = false, Name = @event.Event.Name, VenueName = @event.Event.Venue.Name, EventId = @event.Event.Id }; db.Set <EventsListReadModel>().Add(eventsListModel); var eventDetailsModel = new EventDetailsReadModel() { Date = @event.Event.Date, Name = @event.Event.Name, VenueName = @event.Event.Venue.Name, EventId = @event.Event.Id, Latitude = @event.Event.Venue.Latitude, Longitude = @event.Event.Venue.Longitude, Poster = @event.Event.Poster, SeatCount = @event.Event.SeatCount, VideoUrl = @event.Event.VideoUrl, Description = @event.Event.Description }; db.Set <EventDetailsReadModel>().Add(eventDetailsModel); }
public async Task <T> AddAsync(T entity) { await _dbContext.Set <T>().AddAsync(entity); await _dbContext.SaveChangesAsync(); return(entity); }
public void Handle(OrderPlaced @event, TicketManagementDbContext db) { var orderReadModel = new OrderReadModel() { EventName = @event.Order.Event.Name, OrderId = @event.Order.Id, TicketCount = @event.Order.TicketCount }; db.Set <OrderReadModel>().Add(orderReadModel); }
public virtual async Task <T> GetByIdAsync(Guid id) { return(await _dbContext.Set <T>().FindAsync()); }