mirror of https://github.com/abpframework/eventhub
11 changed files with 233 additions and 24 deletions
@ -0,0 +1,24 @@ |
|||||
|
using System; |
||||
|
using Volo.Abp.Application.Dtos; |
||||
|
|
||||
|
namespace EventHub.Events |
||||
|
{ |
||||
|
public class EventInListDto : EntityDto<Guid> |
||||
|
{ |
||||
|
public string OrganizationName { get; set; } |
||||
|
|
||||
|
public string OrganizationDisplayName { get; set; } |
||||
|
|
||||
|
public string Title { get; set; } |
||||
|
|
||||
|
public string Description { get; set; } |
||||
|
|
||||
|
public DateTime StartTime { get; set; } |
||||
|
|
||||
|
public DateTime EndTime { get; set; } |
||||
|
|
||||
|
public bool IsOnline { get; set; } |
||||
|
|
||||
|
public bool IsLive { get; set; } |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,17 @@ |
|||||
|
using System; |
||||
|
using Volo.Abp.Application.Dtos; |
||||
|
|
||||
|
namespace EventHub.Events |
||||
|
{ |
||||
|
public class EventListFilterDto : PagedResultRequestDto |
||||
|
{ |
||||
|
public DateTime? MinDate { get; set; } |
||||
|
|
||||
|
public DateTime? MaxDate { get; set; } |
||||
|
|
||||
|
public EventListFilterDto() |
||||
|
{ |
||||
|
MaxResultCount = 20; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -1,58 +1,89 @@ |
|||||
using System; |
using System; |
||||
using System.Threading.Tasks; |
using System.Threading.Tasks; |
||||
|
using EventHub.Events; |
||||
using EventHub.Organizations; |
using EventHub.Organizations; |
||||
using Volo.Abp.Data; |
using Volo.Abp.Data; |
||||
using Volo.Abp.DependencyInjection; |
using Volo.Abp.DependencyInjection; |
||||
using Volo.Abp.Domain.Repositories; |
using Volo.Abp.Domain.Repositories; |
||||
|
using Volo.Abp.Timing; |
||||
using Volo.Abp.Users; |
using Volo.Abp.Users; |
||||
|
|
||||
namespace EventHub |
namespace EventHub |
||||
{ |
{ |
||||
public class EventHubTestDataSeedContributor : IDataSeedContributor, ITransientDependency |
public class EventHubTestDataSeedContributor : IDataSeedContributor, ITransientDependency |
||||
{ |
{ |
||||
private readonly OrganizationManager _organizationManager; |
|
||||
private readonly IRepository<Organization, Guid> _organizationRepository; |
private readonly IRepository<Organization, Guid> _organizationRepository; |
||||
|
private readonly IRepository<Event, Guid> _eventRepository; |
||||
private readonly ICurrentUser _currentUser; |
private readonly ICurrentUser _currentUser; |
||||
private readonly EventHubTestData _eventHubTestData; |
private readonly EventHubTestData _eventHubTestData; |
||||
|
private readonly IClock _clock; |
||||
|
|
||||
public EventHubTestDataSeedContributor( |
public EventHubTestDataSeedContributor( |
||||
EventHubTestData eventHubTestData, |
EventHubTestData eventHubTestData, |
||||
OrganizationManager organizationManager, |
|
||||
ICurrentUser currentUser, |
ICurrentUser currentUser, |
||||
IRepository<Organization, Guid> organizationRepository) |
IRepository<Organization, Guid> organizationRepository, |
||||
|
IRepository<Event, Guid> eventRepository, |
||||
|
IClock clock) |
||||
{ |
{ |
||||
_eventHubTestData = eventHubTestData; |
_eventHubTestData = eventHubTestData; |
||||
_organizationManager = organizationManager; |
|
||||
_currentUser = currentUser; |
_currentUser = currentUser; |
||||
_organizationRepository = organizationRepository; |
_organizationRepository = organizationRepository; |
||||
|
_eventRepository = eventRepository; |
||||
|
_clock = clock; |
||||
} |
} |
||||
|
|
||||
public async Task SeedAsync(DataSeedContext context) |
public async Task SeedAsync(DataSeedContext context) |
||||
{ |
{ |
||||
await CreateOrganizationsAsync(); |
await CreateOrganizationsAsync(); |
||||
|
await CreateEvents(); |
||||
} |
} |
||||
|
|
||||
private async Task CreateOrganizationsAsync() |
private async Task CreateOrganizationsAsync() |
||||
{ |
{ |
||||
var volosoft = await _organizationRepository.InsertAsync( |
await _organizationRepository.InsertAsync( |
||||
await _organizationManager.CreateAsync( |
new Organization( |
||||
|
_eventHubTestData.OrganizationVolosoftId, |
||||
_currentUser.GetId(), |
_currentUser.GetId(), |
||||
_eventHubTestData.OrganizationVolosoftName, |
_eventHubTestData.OrganizationVolosoftName, |
||||
"Volosoft", |
"Volosoft", |
||||
"Volosoft is producing software development tools for developers. We are organizing events related to the ABP.IO platform and general software development topic." |
"Volosoft is producing software development tools for developers. We are organizing events related to the ABP.IO platform and general software development topic." |
||||
) |
) |
||||
); |
); |
||||
_eventHubTestData.OrganizationVolosoftId = volosoft.Id; |
|
||||
|
|
||||
var dotnetEurope = await _organizationRepository.InsertAsync( |
await _organizationRepository.InsertAsync( |
||||
await _organizationManager.CreateAsync( |
new Organization( |
||||
Guid.NewGuid(), //TODO: create a second user and set its id!
|
_eventHubTestData.OrganizationDotnetEuropeId, |
||||
|
Guid.NewGuid(), |
||||
_eventHubTestData.OrganizationDotnetEuropeName, |
_eventHubTestData.OrganizationDotnetEuropeName, |
||||
"Dotnet Europe", |
"Dotnet Europe", |
||||
"Organizing events on Microsoft's .NET Platform in European Countries." |
"Organizing events on Microsoft's .NET Platform in European Countries." |
||||
) |
) |
||||
); |
); |
||||
_eventHubTestData.OrganizationDotnetEuropeId = dotnetEurope.Id; |
} |
||||
|
|
||||
|
private async Task CreateEvents() |
||||
|
{ |
||||
|
await _eventRepository.InsertAsync( |
||||
|
new Event( |
||||
|
_eventHubTestData.AbpBlazorPastEventId, |
||||
|
_eventHubTestData.OrganizationVolosoftId, |
||||
|
_eventHubTestData.AbpBlazorPastEventTitle, |
||||
|
_clock.Now.ClearTime().AddDays(-2).AddHours(15), |
||||
|
_clock.Now.ClearTime().AddDays(-2).AddHours(17), |
||||
|
"This is a past event about Blazor and the ABP Framework." |
||||
|
) |
||||
|
); |
||||
|
|
||||
|
await _eventRepository.InsertAsync( |
||||
|
new Event( |
||||
|
_eventHubTestData.AbpMicroservicesFutureEventId, |
||||
|
_eventHubTestData.OrganizationVolosoftId, |
||||
|
_eventHubTestData.AbpMicroservicesFutureEventTitle, |
||||
|
_clock.Now.ClearTime().AddDays(1).AddHours(15), |
||||
|
_clock.Now.ClearTime().AddDays(1).AddHours(17), |
||||
|
"This is a future event about the ABP Framework and Microservices that is set for tomorrow." |
||||
|
) |
||||
|
); |
||||
} |
} |
||||
} |
} |
||||
} |
} |
||||
|
|||||
Loading…
Reference in new issue