Skip to content

Commit

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,6 @@ public class BookingData
public short Duration { get; private set; }
public Guid BookedRecordId { get; private set; }
public BookingStatus Status { get; private set; }
public string Caution { get; set; }
}
}

This file was deleted.

This file was deleted.

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 BookingCanceledByFacility : IEvent
{
public BookingCanceledByFacility(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 @@ -88,5 +88,27 @@ public void Apply(BookingCanceled @event)
@event.BookedRecordId
));
}

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

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

public void Apply(BookingCanceledByFacility @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 @@ -37,6 +37,7 @@ public enum BookingStatus
{
Fulfilled,
Canceled,
CanceledByFacility,
NotRealized
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,19 @@ public void Apply(BookingCanceled @event, MemberArchivalBookings view)
@event.BookedRecordId
));
}

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

0 comments on commit 5c8a9d4

Please sign in to comment.