Skip to content

Commit

Permalink
#108 Accessibility - bookings not realized
Browse files Browse the repository at this point in the history
  • Loading branch information
kgniazdowski committed Aug 10, 2021
1 parent 5c8a9d4 commit 0a9e798
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ public async Task<Unit> Handle(AddCompletedBookingsCommand request, Cancellation
case BookingStatus.CanceledByFacility:
member.AddCanceledByFacilityBooking(offer, null, employee, booking.Date, booking.Duration, booking.BookedRecordId, booking.Caution);
break;
case BookingStatus.NotRealized:
member.AddNotRealizedBooking(offer, null, employee, booking.Date, booking.Duration, booking.BookedRecordId, booking.Caution);
break;
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
using System;
using Community.Domain.Members.ValueObjects;
using Core.Domain;

namespace Community.Domain.Members.Events
{
public class BookingNotRealized : IEvent
{
public BookingNotRealized(Guid memberId, BookingOffer offer, BookingFacility facility, BookingEmployee employee, DateTime date, short duration, Guid bookedRecordId, string caution)
{
MemberId = memberId;
Offer = offer;
Facility = facility;
Employee = employee;
Date = date;
Duration = duration;
BookedRecordId = bookedRecordId;
Caution = caution;
}

public Guid MemberId { get; }
public BookingOffer Offer { get; }
public BookingFacility Facility { get; }
public BookingEmployee Employee { get; }
public DateTime Date { get; }
public short Duration { get; }
public Guid BookedRecordId { get; }
public string Caution { get; }
}
}
22 changes: 22 additions & 0 deletions community-service/src/Community.Domain/Members/Member.cs
Original file line number Diff line number Diff line change
Expand Up @@ -110,5 +110,27 @@ public void Apply(BookingCanceledByFacility @event)
@event.BookedRecordId
));
}

public void AddNotRealizedBooking(BookingOffer offer, BookingFacility facility, BookingEmployee employee, DateTime date, short duration, Guid bookedRecordId, string caution)
{
var @event = new BookingNotRealized(Id, offer, facility, employee, date, duration, bookedRecordId, caution);

Enqueue(@event);
Apply(@event);
}

public void Apply(BookingNotRealized @event)
{
ArchivalBookings.Add(new ArchivalBooking(
@event.Offer,
@event.Facility,
@event.Employee,
@event.Date,
@event.Duration,
BookingStatus.CanceledByFacility,
@event.Caution,
@event.BookedRecordId
));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -61,5 +61,19 @@ public void Apply(BookingCanceledByFacility @event, MemberArchivalBookings view)
@event.BookedRecordId
));
}

public void Apply(BookingNotRealized @event, MemberArchivalBookings view)
{
view.ArchivalBookings.Add(new ArchivalBooking(
@event.Offer,
@event.Facility,
@event.Employee,
@event.Date,
@event.Duration,
BookingStatus.NotRealized,
@event.Caution,
@event.BookedRecordId
));
}
}
}

0 comments on commit 0a9e798

Please sign in to comment.