Example #1
0
 public static Community Extend(this Community original, CommunityVm vm)
 => new Community
 {
     Id       = original.Id,
     Name     = vm.Name,
     City     = vm.City,
     TimeZone = vm.TimeZone,
 };
Example #2
0
 public Task <CommunityVm> UpdateCommunityAsync(CommunityVm community)
 {
     throw new System.NotImplementedException();
 }
Example #3
0
        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)
                );
            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);
            }

            var friends = new List <FriendVm>();

            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
            CommunityVm community = null;

            if (string.IsNullOrWhiteSpace(descriptor.CommunityId))
            {
                community = await _communityService.GetCommunityAsync(descriptor.CommunityId);
            }

            return(new CompositeModel
            {
                Id = meetup?.Id,
                Name = descriptor.Name,
                Community = community,
                Venue = venue,
                Sessions = descriptor.Sessions,
                Talks = talks,
                Speakers = speakers,
                Friends = friends
            });
        }
 public async Task <IActionResult> Put([FromBody] CommunityVm community)
 {
     _dbContext.Communities.Update(_mapper.Map <Community>(community));
     return(Ok(await _dbContext.SaveChangesAsync()));
 }
Example #5
0
 public Task <CommunityVm> AddCommunityAsync(CommunityVm community)
 {
     throw new NotImplementedException();
 }