mirror of https://github.com/abpframework/eventhub
13 changed files with 2746 additions and 95 deletions
@ -1,48 +1,30 @@ |
|||
using System; |
|||
using System.Linq; |
|||
using System.Threading.Tasks; |
|||
using EventHub.Events.Registrations; |
|||
using IdentityServer4.Validation; |
|||
using Volo.Abp.DependencyInjection; |
|||
using Volo.Abp.Domain.Repositories; |
|||
using Volo.Abp.EventBus; |
|||
using Volo.Abp.Linq; |
|||
|
|||
namespace EventHub.Events |
|||
{ |
|||
public class EventTimeChangeLocalEventHandler : ILocalEventHandler<EventTimeChangingEventData>, ITransientDependency |
|||
{ |
|||
private readonly IRepository<EventRegistration, Guid> _eventRegistrationRepository; |
|||
private readonly IAsyncQueryableExecuter _asyncExecuter; |
|||
private readonly IRepository<Event, Guid> _eventRepository; |
|||
|
|||
public EventTimeChangeLocalEventHandler( |
|||
IRepository<EventRegistration, Guid> eventRegistrationRepository, |
|||
IAsyncQueryableExecuter asyncExecuter) |
|||
public EventTimeChangeLocalEventHandler(IRepository<Event, Guid> eventRepository) |
|||
{ |
|||
_eventRegistrationRepository = eventRegistrationRepository; |
|||
_asyncExecuter = asyncExecuter; |
|||
_eventRepository = eventRepository; |
|||
} |
|||
|
|||
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(); |
|||
var query = eventRegistrationQueryable.Where(x => x.EventId == @event.Id); |
|||
var eventRegistrations = await _asyncExecuter.ToListAsync(query); |
|||
@event.IsTimingChangeEmailSent = false; |
|||
|
|||
foreach (var eventRegistration in eventRegistrations) |
|||
{ |
|||
if (eventRegistration.IsTimingChangeEmailSent) |
|||
{ |
|||
eventRegistration.IsTimingChangeEmailSent = false; |
|||
} |
|||
} |
|||
|
|||
await _eventRegistrationRepository.UpdateManyAsync(eventRegistrations, true); |
|||
await _eventRepository.UpdateAsync(@event, 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