public async Task <IEnumerable <FacilityRepresentation> > ListAsync() { var facilities = await(from item in context.Facilities.AsNoTracking() where item.Owner == securityContext.GetCurrentTenant() select new { item.Id, item.Name, item.Description, item.StreetAddress, item.Latitude, item.Longitude, item.Images, AccommodationCount = item.Accommodations.Count() }).ToListAsync(); return((from facility in facilities select new FacilityRepresentation { Id = facility.Id, Name = facility.Name, Description = facility.Description, StreetAddress = facility.StreetAddress, Latitude = facility.Latitude, Longitude = facility.Longitude, Images = facility.Images.ToStringArray(), AccommodationCount = facility.AccommodationCount }).ToList()); }
private static IEnumerable <ReliableEvent> AsReliableEvents(this IEnumerable <IntegrationEvent> events, ISecurityContext securityContext) { return(from @event in events select new ReliableEvent { Id = @event.EventId.ToString(), EventName = @event.GetType().Name, OccurredAt = @event.OccurredAt, User = securityContext.GetCurrentUser(), Tenant = securityContext.GetCurrentTenant(), Payload = JsonConvert.SerializeObject(@event) }); }
public async Task <int> Handle(CreateFacilityCommand request, CancellationToken cancellationToken) { var facility = Domain.Models.Facility.NewFacility( securityContext.GetCurrentTenant(), request.Name, request.Description, request.StreetAddress, request.Latitude, request.Longitude, request.Images); facility.Id = await repository.AddAsync(facility); await repository.SaveChangesAsync(facility, context); return(facility.Id); }
public static async Task PersistEventsAsync(this FacilityContext context, Entity <int> entity, ISecurityContext securityContext) { var events = entity.CollectEvents(); if (events != null && events.Any()) { foreach (var @event in events) { await context.Events.AddAsync(new Models.Event { EventName = @event.GetType().Name, OccurredAt = @event.OccurredAt, User = securityContext.GetCurrentUser(), Tenant = securityContext.GetCurrentTenant(), Payload = JsonConvert.SerializeObject(@event) }); } } }
public Task <List <Contracts.Models.Facility> > ListAsync() { return(dataSource.ListByOwnerAsync(securityContext.GetCurrentTenant())); }
private void AddSecurityContext(Message message) { message.UserProperties.Add(Constants.TenantId, securityContext.GetCurrentTenant()); message.UserProperties.Add(Constants.ObjectId, securityContext.GetCurrentUser()); }