Created
May 24, 2014 16:29
-
-
Save wayne-o/24db432bf9de1b5c2d24 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 EventProfileTransformer : AbstractTransformerCreationTask<EventInstance> | |
{ | |
public EventProfileTransformer() | |
{ | |
TransformResults = eventInstances => from ei in eventInstances | |
let images = LoadDocument<FullImage>(ei.Images.Select(x=>x.Id)) | |
let campsites = LoadDocument<Campsite>(ei.Campsites.Select(x=>x.Id)) | |
select new EventProfileDto | |
{ | |
Images = (from i in images | |
select new ImageDto | |
{ | |
Name = i.Value | |
}).ToList(), | |
Campsites =(from c in campsites | |
let members = LoadDocument<UserAccount>(c.Members.Select(x=>x.Id)) | |
select new CampsiteDto | |
{ | |
Name = c.Name, | |
Id = c.Id, | |
Slug = c.Slug, | |
Members = members.Select(x=> new UserAccountDto | |
{ | |
Id = x.Id, | |
Username = x.Username, | |
Slug = x.Slug, | |
Image = new ImageDto | |
{ | |
Name = x.Image != null ? x.Image.Name : string.Empty | |
} | |
}).ToList() | |
}).ToList(), | |
Image = new ImageDto | |
{ | |
Name = ei.Image.Name | |
}, | |
Tags = (from ln in ei.Locations | |
let locaiton = LoadDocument<Location>(ln.Id) | |
from levent in locaiton.ListingEvents | |
let locationevent = LoadDocument<ListingEvent>(levent.Id) | |
let ac = LoadDocument<ArtistDto>(locationevent.Artists.Select(x => x.Id)) | |
from a in ac | |
from tag in a.Tags | |
group tag by tag.Name into g | |
where g.Count() > 4 | |
select new TagDto | |
{ | |
Name = g.Key, | |
Count = g.Count() | |
}).OrderByDescending(tags => tags.Count).ToList(), | |
PromotionCompany = LoadDocument<PromotionCompanyDTO>(ei.EventPromoterId), | |
Slug = ei.Slug, | |
EventInstance = new EventInstanceDto | |
{ | |
Name = ei.Name, | |
BioText = ei.BioText, | |
Id = ei.Id, | |
Slug = ei.Slug, | |
FromDate = ei.FromDate, | |
ToDate = ei.ToDate, | |
Image = new ImageDto | |
{ | |
Name = ei.Image.Name | |
}, | |
EventSeriesId = ei.EventSeriesId, | |
UsersAttending = (from attending in ei.UsersAttending | |
let usr = LoadDocument<UserAccountDto>(attending.UserAccount.Id) | |
select new UserAttendanceDto | |
{ | |
Status = attending.Status, | |
Email = usr.Email, | |
Slug = usr.Slug, | |
Id = usr.Id, | |
Name = usr.Username, | |
ThirdPartyUsername = usr.ThirdPartyUsername, | |
Image = usr.Image | |
}).ToList(), | |
Images = (from i in images | |
select new ImageDto | |
{ | |
Name = i.Value | |
}).ToList(), | |
} | |
}; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment