|
| 1 | +import Foundation |
| 2 | +import Storage |
| 3 | + |
| 4 | + |
| 5 | +// MARK: - Storage.Booking: ReadOnlyConvertible |
| 6 | +// |
| 7 | +extension Storage.Booking: ReadOnlyConvertible { |
| 8 | + |
| 9 | + /// Updates the Storage.Booking with the a ReadOnly. |
| 10 | + /// |
| 11 | + public func update(with booking: Yosemite.Booking) { |
| 12 | + siteID = booking.siteID |
| 13 | + bookingID = booking.bookingID |
| 14 | + allDay = booking.allDay |
| 15 | + cost = booking.cost |
| 16 | + customerID = booking.customerID |
| 17 | + dateCreated = booking.dateCreated |
| 18 | + dateModified = booking.dateModified |
| 19 | + endDate = booking.endDate |
| 20 | + googleCalendarEventID = booking.googleCalendarEventID |
| 21 | + orderID = booking.orderID |
| 22 | + orderItemID = booking.orderItemID |
| 23 | + parentID = booking.parentID |
| 24 | + productID = booking.productID |
| 25 | + resourceID = booking.resourceID |
| 26 | + startDate = booking.startDate |
| 27 | + statusKey = booking.statusKey |
| 28 | + localTimezone = booking.localTimezone |
| 29 | + } |
| 30 | + |
| 31 | + /// Returns a ReadOnly version of the receiver. |
| 32 | + /// |
| 33 | + public func toReadOnly() -> Yosemite.Booking { |
| 34 | + Booking(siteID: siteID, |
| 35 | + bookingID: bookingID, |
| 36 | + allDay: allDay, |
| 37 | + cost: cost ?? "", |
| 38 | + customerID: customerID, |
| 39 | + dateCreated: dateCreated ?? Date(), |
| 40 | + dateModified: dateModified ?? Date(), |
| 41 | + endDate: endDate ?? Date(), |
| 42 | + googleCalendarEventID: googleCalendarEventID, |
| 43 | + orderID: orderID, |
| 44 | + orderItemID: orderItemID, |
| 45 | + parentID: parentID, |
| 46 | + productID: productID, |
| 47 | + resourceID: resourceID, |
| 48 | + startDate: startDate ?? Date(), |
| 49 | + statusKey: statusKey ?? "", |
| 50 | + localTimezone: localTimezone ?? "") |
| 51 | + } |
| 52 | +} |
0 commit comments