Skip to content

Commit

Permalink
Merge pull request #358 from adrianbanks/better-error-when-missing-co…
Browse files Browse the repository at this point in the history
…nference

Throw a better error when the conference can't be found
  • Loading branch information
adrianbanks authored Jun 6, 2019
2 parents 2a05943 + bdf92a9 commit 82d84e6
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
15 changes: 13 additions & 2 deletions DDDEastAnglia/DataAccess/ConferenceLoader.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using DDDEastAnglia.DataAccess.SimpleData.Builders;
using DDDEastAnglia.Domain;
using Conference = DDDEastAnglia.DataAccess.SimpleData.Models.Conference;

namespace DDDEastAnglia.DataAccess
{
Expand Down Expand Up @@ -36,13 +37,23 @@ public ConferenceLoader(IConferenceRepository conferenceRepository, ConferenceBu
public IConference LoadConference()
{
var dataConference = conferenceRepository.GetByEventShortName(DefaultEventName);
return conferenceBuilder.Build(dataConference);
return BuildConference(dataConference);
}

public IConference LoadConference(int sessionId)
{
var dataConference = conferenceRepository.ForSession(sessionId);
return conferenceBuilder.Build(dataConference);
return BuildConference(dataConference);
}

private IConference BuildConference(Conference conference)
{
if (conference == null)
{
throw new ArgumentNullException(nameof(conference), "Cannot find current conference");
}

return conferenceBuilder.Build(conference);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,6 @@ public ConferenceBuilder(ICalendarItemRepository calendarItemRepository, IBuild<

public Domain.Conference Build(Conference item)
{
if (item == null)
{
return null;
}

var conference = new Domain.Conference(item.ConferenceId, item.Name, item.ShortName, item.NumberOfTimeSlots, item.NumberOfTracks, item.AnonymousSessions);
var calendarItems = calendarItemRepository.GetAll();

Expand Down

0 comments on commit 82d84e6

Please sign in to comment.