diff --git a/src/Church/Church.Common/Church.Common.csproj b/src/Church/Church.Common/Church.Common.csproj index b789ae0..22312f6 100644 --- a/src/Church/Church.Common/Church.Common.csproj +++ b/src/Church/Church.Common/Church.Common.csproj @@ -45,6 +45,7 @@ + diff --git a/src/Church/Church.Host.Core/Controllers/ChurchController.cs b/src/Church/Church.Host.Core/Controllers/ChurchController.cs index 953d7c2..597c78a 100644 --- a/src/Church/Church.Host.Core/Controllers/ChurchController.cs +++ b/src/Church/Church.Host.Core/Controllers/ChurchController.cs @@ -1,5 +1,5 @@ using System.Collections.Generic; -using System.Linq; +using System.Net; using System.Web.Http; using Church.Common.Mapping; using Church.Components.Core; @@ -20,6 +20,10 @@ public ChurchController(IChurchService churchService) public ChurchViewModel ChurchById(int id) { var church = _churchService.GetById(id); + if (church == null) + { + throw new HttpResponseException(HttpStatusCode.NotFound); + } return Mapper.Map(church); } @@ -28,24 +32,11 @@ public ChurchViewModel ChurchById(int id) public IEnumerable ChurchLocationsByChurchId(int churchId) { var church = _churchService.GetById(churchId); + if (church == null) + { + throw new HttpResponseException(HttpStatusCode.NotFound); + } return Mapper.MapList(church.Locations); - - //var locationViewModels = church.Locations.Select(x => new LocationViewModel - //{ - // Id = x.Id, - // Name = x.Name, - // Address = new AddressViewModel - // { - // Street1 = x.Address.Street1, - // Street2 = x.Address.Street2, - // City = x.Address.City, - // PostCode = x.Address.PostCode, - // Country = x.Address.Country, - // State = x.Address.State, - // Id = x.Address.Id - // } - //}); - //return locationViewModels; } } } diff --git a/src/Church/Church.Host.Core/Startup.cs b/src/Church/Church.Host.Core/Startup.cs index ba4b7e6..c6e8930 100644 --- a/src/Church/Church.Host.Core/Startup.cs +++ b/src/Church/Church.Host.Core/Startup.cs @@ -11,17 +11,17 @@ public class Startup { public void Configuration(IAppBuilder appBuilder) { + var container = new TinyIoCContainer(); var httpConfig = new HttpConfiguration(); - httpConfig.MapHttpAttributeRoutes(); - httpConfig.SetDependencyResolver(container); + appBuilder.UseWebApi(httpConfig); RegisterComponents(container); RegisterMappings(); - - appBuilder.UseWebApi(httpConfig); + httpConfig.MapHttpAttributeRoutes(); + httpConfig.SetDependencyResolver(container); } void RegisterComponents(TinyIoCContainer container)