Skip to content

Commit

Permalink
Refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
davevans committed Jul 13, 2014
1 parent 95f68c5 commit 0c0a732
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 22 deletions.
1 change: 1 addition & 0 deletions src/Church/Church.Common/Church.Common.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
<Reference Include="System" />
<Reference Include="System.ComponentModel.DataAnnotations" />
<Reference Include="System.Core" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Web.Http, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
Expand Down
27 changes: 9 additions & 18 deletions src/Church/Church.Host.Core/Controllers/ChurchController.cs
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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<Model.Core.Church, ChurchViewModel>(church);
}

Expand All @@ -28,24 +32,11 @@ public ChurchViewModel ChurchById(int id)
public IEnumerable<LocationViewModel> ChurchLocationsByChurchId(int churchId)
{
var church = _churchService.GetById(churchId);
if (church == null)
{
throw new HttpResponseException(HttpStatusCode.NotFound);
}
return Mapper.MapList<Model.Core.Location, LocationViewModel>(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;
}
}
}
8 changes: 4 additions & 4 deletions src/Church/Church.Host.Core/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 0c0a732

Please sign in to comment.