Skip to content
This repository has been archived by the owner on Aug 23, 2024. It is now read-only.

Commit

Permalink
AutoMapper fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
camjm committed Sep 21, 2015
1 parent 11fc47c commit e0246ac
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 4 deletions.
23 changes: 21 additions & 2 deletions src/BeyondEarthApp.Web.Api.Models/Faction.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
namespace BeyondEarthApp.Web.Api.Models
using System.Collections.Generic;

namespace BeyondEarthApp.Web.Api.Models
{
public class Faction
public class Faction : ILinkContaining
{
public long FactionId { get; set; }

Expand All @@ -11,5 +13,22 @@ public class Faction
public string Capital { get; set; }

public string Ability { get; set; }

#region Links

private List<Link> _links;

public List<Link> Links
{
get { return _links ?? (_links = new List<Link>()); }
set { _links = value; }
}

public void AddLink(Link link)
{
Links.Add(link);
}

#endregion
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ public class FactionConfigurator : IAutoMapperTypeConfigurator
{
public void Configure(IAutoMapper mapper)
{
mapper.CreateMap<Faction, Models.Faction>();
mapper.CreateMap<Faction, Models.Faction>()
.ForMember(opt => opt.Links, x => x.Ignore());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ public void Configure(IAutoMapper mapper)
.ForMember(opt => opt.GameId, x => x.Ignore())
.ForMember(opt => opt.Technologies, x => x.Ignore())
.ForMember(opt => opt.User, x => x.Ignore())
.ForMember(opt => opt.CreatedDate, x => x.Ignore());
.ForMember(opt => opt.Status, x => x.Ignore())
.ForMember(opt => opt.CreatedDate, x => x.Ignore())
.ForMember(opt => opt.StartDate, x => x.Ignore());
}
}
}

0 comments on commit e0246ac

Please sign in to comment.