private void AddItem(DateTime from, DateTime to, CalendarItemState state, object settings) { CheckFromTo(from, to); var statePayload = JsonConvert.SerializeObject(settings); var item = new CalendarItem(from, to, state.Id, statePayload, DateTime.UtcNow); _items.Add(item); }
public void AddAvailability(DateTime from, DateTime to, Price price) { if (price == null) { throw new FantasticStayDomainException("Cannot add availability with no price."); } if (price.Amount < 0) { throw new FantasticStayDomainException("Cannot add availability with negative price."); } var a = CalendarItemState.Get(price.CurrencyId); if (Currency.Get(price.CurrencyId) == null) { throw new FantasticStayDomainException($"Currency with id '{price.CurrencyId}' is not supported."); } var settings = new AvailableStateSettings(price); AddItem(from, to, CalendarItemState.Available, settings); }