public async Task <ActionResult <IQueryable <Venue> > > Get([FromODataUri] int key) //Nem lehet GetAsync a neve, létrehozáskor 500 lenne { //Lekérjük az elemet, és a DAL elemből DTO-t csinálunk, amiből pedig Queryable-t csinálunk az OData-hoz var result = _mapper.Map <Venue>(await _venueService.GetVenueAsync(key)).ToQueryable(); return(Ok(SingleResult.Create(result))); }
public Task <VenueVm> GetVenue(string venueId) => _venueService.GetVenueAsync(venueId);
public async Task <CompositeModel> GetMeetup([FromRoute] string meetupId, [FromBody] RandomConcatModel descriptor = null) { var meetup = await _meetupService.GetMeetupAsync(meetupId).ConfigureAwait(true); descriptor = descriptor ?? new RandomConcatModel(); descriptor.VenueId = descriptor.VenueId; descriptor.Sessions = descriptor.Sessions ?? new List <SessionVm>(); descriptor.TalkIds = descriptor.TalkIds ?? new List <string>(); descriptor.SpeakerIds = descriptor.SpeakerIds ?? new List <string>(); descriptor.FriendIds = descriptor.FriendIds ?? new List <string>(); if (meetup != null && descriptor.Sessions.Count == 0) { descriptor.Sessions = meetup.Sessions; } descriptor.TalkIds.AddRange(descriptor.Sessions.Select(x => x.TalkId).Where(x => !string.IsNullOrWhiteSpace(x))); // talks var talks = new Dictionary <string, TalkVm>(); foreach (var talkId in descriptor.TalkIds.Distinct()) { var talk = await _talkService.GetTalkAsync(talkId).ConfigureAwait(true); talks.Add(talkId, talk); } // speakers descriptor.SpeakerIds.AddRange( talks.Select(x => x.Value).SelectMany(x => x.SpeakerIds.Select(s => s.SpeakerId)) ); var speakers = new Dictionary <string, SpeakerVm>(); foreach (var speakerId in descriptor.SpeakerIds.Distinct()) { var speaker = await _speakerService.GetSpeakerAsync(speakerId).ConfigureAwait(true); speakers.Add(speakerId, speaker); } // friends if (meetup != null && descriptor.FriendIds.Count == 0) { descriptor.FriendIds.AddRange(meetup.FriendIds.Select(x => x.FriendId)); } var friends = new List <Friend>(); foreach (var friendId in descriptor.FriendIds.Distinct()) { var friend = await _friendService.GetFriendAsync(friendId).ConfigureAwait(true); friends.Add(friend); } // name if (string.IsNullOrWhiteSpace(descriptor.Name)) { descriptor.Name = meetup?.Name; } // venue descriptor.VenueId = descriptor.VenueId ?? meetup?.VenueId; VenueVm venue = null; if (!string.IsNullOrWhiteSpace(descriptor.VenueId)) { venue = await _venueService.GetVenueAsync(descriptor.VenueId).ConfigureAwait(true); } // community if (string.IsNullOrWhiteSpace(descriptor.CommunityId)) { descriptor.CommunityId = meetup?.CommunityId.ToString(); } return(new CompositeModel { Id = meetup?.Id, Name = descriptor.Name, CommunityId = string.IsNullOrWhiteSpace(descriptor.CommunityId) ? (Community?)null : descriptor.CommunityId.GetCommunity(), Venue = venue, Sessions = descriptor.Sessions, Talks = talks, Speakers = speakers, Friends = friends }); }