Last active
March 18, 2016 09:38
-
-
Save rmaziarka/94eceba99473aa26ba33 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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