mirror of https://github.com/abpframework/eventhub
committed by
GitHub
13 changed files with 2747 additions and 96 deletions
@ -1,48 +1,30 @@ |
|||||
using System; |
using System; |
||||
using System.Linq; |
|
||||
using System.Threading.Tasks; |
using System.Threading.Tasks; |
||||
using EventHub.Events.Registrations; |
|
||||
using IdentityServer4.Validation; |
|
||||
using Volo.Abp.DependencyInjection; |
using Volo.Abp.DependencyInjection; |
||||
using Volo.Abp.Domain.Repositories; |
using Volo.Abp.Domain.Repositories; |
||||
using Volo.Abp.EventBus; |
using Volo.Abp.EventBus; |
||||
using Volo.Abp.Linq; |
|
||||
|
|
||||
namespace EventHub.Events |
namespace EventHub.Events |
||||
{ |
{ |
||||
public class EventTimeChangeLocalEventHandler : ILocalEventHandler<EventTimeChangingEventData>, ITransientDependency |
public class EventTimeChangeLocalEventHandler : ILocalEventHandler<EventTimeChangingEventData>, ITransientDependency |
||||
{ |
{ |
||||
private readonly IRepository<EventRegistration, Guid> _eventRegistrationRepository; |
private readonly IRepository<Event, Guid> _eventRepository; |
||||
private readonly IAsyncQueryableExecuter _asyncExecuter; |
|
||||
|
|
||||
public EventTimeChangeLocalEventHandler( |
public EventTimeChangeLocalEventHandler(IRepository<Event, Guid> eventRepository) |
||||
IRepository<EventRegistration, Guid> eventRegistrationRepository, |
|
||||
IAsyncQueryableExecuter asyncExecuter) |
|
||||
{ |
{ |
||||
_eventRegistrationRepository = eventRegistrationRepository; |
_eventRepository = eventRepository; |
||||
_asyncExecuter = asyncExecuter; |
|
||||
} |
} |
||||
|
|
||||
public async Task HandleEventAsync(EventTimeChangingEventData eventData) |
public async Task HandleEventAsync(EventTimeChangingEventData eventData) |
||||
{ |
{ |
||||
await UpdateEventRegistrationForTimingChangeAsync(@eventData.Event); |
await UpdateEventForTimingChangeAsync(eventData.Event); |
||||
} |
} |
||||
|
|
||||
private async Task UpdateEventRegistrationForTimingChangeAsync(Event @event) |
private async Task UpdateEventForTimingChangeAsync(Event @event) |
||||
{ |
{ |
||||
var eventRegistrationQueryable = await _eventRegistrationRepository.GetQueryableAsync(); |
@event.IsTimingChangeEmailSent = false; |
||||
var query = eventRegistrationQueryable.Where(x => x.EventId == @event.Id); |
|
||||
var eventRegistrations = await _asyncExecuter.ToListAsync(query); |
|
||||
|
|
||||
foreach (var eventRegistration in eventRegistrations) |
await _eventRepository.UpdateAsync(@event, true); |
||||
{ |
|
||||
if (eventRegistration.IsTimingChangeEmailSent) |
|
||||
{ |
|
||||
eventRegistration.IsTimingChangeEmailSent = false; |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
await _eventRegistrationRepository.UpdateManyAsync(eventRegistrations, true); |
|
||||
} |
} |
||||
} |
} |
||||
} |
} |
||||
File diff suppressed because it is too large
@ -0,0 +1,35 @@ |
|||||
|
using Microsoft.EntityFrameworkCore.Migrations; |
||||
|
|
||||
|
namespace EventHub.Migrations |
||||
|
{ |
||||
|
public partial class Moved_IsTimingChangeEmailSent_To_Event : Migration |
||||
|
{ |
||||
|
protected override void Up(MigrationBuilder migrationBuilder) |
||||
|
{ |
||||
|
migrationBuilder.DropColumn( |
||||
|
name: "IsTimingChangeEmailSent", |
||||
|
table: "EhEventRegistrations"); |
||||
|
|
||||
|
migrationBuilder.AddColumn<bool>( |
||||
|
name: "IsTimingChangeEmailSent", |
||||
|
table: "EhEvents", |
||||
|
type: "boolean", |
||||
|
nullable: false, |
||||
|
defaultValue: true); |
||||
|
} |
||||
|
|
||||
|
protected override void Down(MigrationBuilder migrationBuilder) |
||||
|
{ |
||||
|
migrationBuilder.DropColumn( |
||||
|
name: "IsTimingChangeEmailSent", |
||||
|
table: "EhEvents"); |
||||
|
|
||||
|
migrationBuilder.AddColumn<bool>( |
||||
|
name: "IsTimingChangeEmailSent", |
||||
|
table: "EhEventRegistrations", |
||||
|
type: "boolean", |
||||
|
nullable: false, |
||||
|
defaultValue: true); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
Loading…
Reference in new issue