Skip to content

Instantly share code, notes, and snippets.

@rmaziarka
Last active March 18, 2016 09:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rmaziarka/94eceba99473aa26ba33 to your computer and use it in GitHub Desktop.
Save rmaziarka/94eceba99473aa26ba33 to your computer and use it in GitHub Desktop.
public class Requirement : BaseEntity
{
public DateTime CreateDate { get; set; }
public decimal? MinPrice { get; set; }
public decimal? MaxPrice { get; set; }
public ICollection<Contact> Contacts { get; set; }
public Country Country { get; set; }
}
public class Contact : BaseEntity
{
public string FirstName { get; set; }
public string Surname { get; set; }
public ICollection<Requirement> Requirements { get; set; }
}
public class Country : BaseEntity{
public string Name { get; set; }
}
public RequirementResult {
public Guid Id { get; set; }
public DateTime CreateDate { get; set; }
public decimal? MinPrice { get; set; }
public decimal? MaxPrice { get; set; }
public string CountryName { get; set; }
public IEnumerable<ContactResult> Contacts { get; set; }
}
public ContactResult {
public string FirstName { get; set; }
public string Surname { get; set; }
}
public RequirementResultProfile : Profile {
public RequirementResultProfile() {
Mapper.CreateMap<Requirement, RequirementResult>()
.ForMember(el => el.CountryName, m => m.MapFrom(el => el.Country.Name));
}
}
public ContactResultProfile : Profile {
public ContactResultProfile() {
Mapper.CreateMap<Contact, ContactResult>();
}
}
public GetRequirementQueryHandler : IRequestHandler<int, RequirementResult> {
public RequirementResult Handle(int id){
RequirementResult requirement =
this.requirementRepository
.Get()
.ProjectTo<RequirementResult>()
.FirstAsync(el => el.Id == id);
return requirement;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment