Esempio n. 1
0
        public async Task <GroupViewModel> GetGroupViewModel(Guid memoryBookUniverseId, Guid groupId)
        {
            IList <GroupReadModel> groups = await this.groupProvider.GetGroupsAsync(memoryBookUniverseId, groupId).ConfigureAwait(false);

            if (groups == null || groups.Count == 0)
            {
                return(null);
            }

            GroupReadModel groupReadModel = groups.First();
            GroupViewModel viewModel      = groupReadModel.ToViewModel();

            IList <DetailTypeReadModel> detailTypes = await this.detailTypeQueryManager.GetAllDetailTypes().ConfigureAwait(false);

            Dictionary <Guid, DetailTypeReadModel> detailTypesDictionary = detailTypes.ToDictionary(x => x.Id);

            Task <IList <DetailsByEntityModel> > groupDetails         = this.detailProvider.GetDetailsForGroups(memoryBookUniverseId, groupId);
            Task <IList <MemberViewModel> >      memberViewModelsTask = this.GetMemberViewModels(memoryBookUniverseId, groupReadModel.MemberIds, detailTypesDictionary);

            await Task.WhenAll(groupDetails, memberViewModelsTask).ConfigureAwait(false);

            viewModel.Details = groupDetails.Result?.FirstOrDefault()?.Details
                                .Select(x => x.ToViewModel(detailTypesDictionary)).ToList();

            viewModel.Members = memberViewModelsTask.Result;

            return(viewModel);
        }
        public static GroupViewModel ToViewModel(this GroupReadModel readModel)
        {
            Contract.RequiresNotNull(readModel, nameof(readModel));

            return(new GroupViewModel
            {
                GroupDescription = readModel.Description,
                GroupName = readModel.Name
            });
        }
Esempio n. 3
0
        protected override async Task Handle(GroupCreated notification)
        {
            var view = new GroupReadModel
            {
                Id       = notification.Id,
                RegionId = notification.RegionId,
                GenreIds = notification.GenreIds,
                BuddyIds = new List <string>()
            };

            await Writer.Add(view);
        }