Exemple #1
0
        private string FormatName(MemberReadModel member)
        {
            var name  = member.SortName ?? member.DisplayName;
            var email = member.Email;

            return($"{name} <{email}>");
        }
Exemple #2
0
        public async Task <DetailReadModel> CreateWedding(
            MemberReadModel creator,
            Guid relationshipId,
            DateTime weddingDate,
            string weddingLocation = null)
        {
            Contract.RequiresNotNull(creator, nameof(creator));

            string weddingLocationText = string.Empty;

            if (!string.IsNullOrWhiteSpace(weddingLocation))
            {
                weddingLocationText = $" at {weddingLocation}";
            }

            string customDetailText = $"Married {weddingDate.ToShortDateString()}{weddingLocationText}";

            var detail = await this.detailProvider.CreateDetail(
                creator.MemoryBookUniverseId,
                creator, customDetailText,
                DetailTypeEnum.Wedding,
                weddingDate)
                         .ConfigureAwait(false);

            await this.detailAssociationProvider.CreateRelationshipDetailAssociation(detail, relationshipId)
            .ConfigureAwait(false);

            return(detail);
        }
        private async Task LoadUser(string username)
        {
            var command = new MemberUserNameQuery(User, username);
            var result  = await Mediator.Send(command);

            Member = result;
        }
Exemple #4
0
        public async Task <DetailReadModel> CreateEvent(MemberReadModel creator, IList <Guid> memberAttendees, DateTime?startDate, DateTime?endDate, string description)
        {
            Contract.RequiresNotNull(creator, nameof(creator));
            Contract.RequiresNotNullOrEmpty(memberAttendees, nameof(memberAttendees));

            var detail = await this.detailProvider.CreateDetail(creator.MemoryBookUniverseId, creator, description, DetailTypeEnum.Event, startDate, endDate)
                         .ConfigureAwait(false);

            await this.detailAssociationProvider.CreateMemberDetailAssociation(detail, memberAttendees)
            .ConfigureAwait(false);

            return(detail);
        }
Exemple #5
0
        public static MemberViewModel ToViewModel(this MemberReadModel memberReadModel, IDictionary <Guid, List <DetailViewModel> > memberDetailsDictionary, IList <CombinedRelationshipReadModel> relationships)
        {
            Contract.RequiresNotNull(memberReadModel, nameof(memberReadModel));

            string middleName = string.IsNullOrWhiteSpace(memberReadModel.MiddleName) ? " " : " " + memberReadModel.MiddleName;

            return(new MemberViewModel
            {
                CommonName = memberReadModel.CommonName,
                FullName = $"{memberReadModel.FirstName}{middleName} {memberReadModel.LastName}",
                Id = memberReadModel.Id,
                Details = memberDetailsDictionary.ContainsKey(memberReadModel.Id) ? memberDetailsDictionary[memberReadModel.Id] : new List <DetailViewModel>(),
                Relationships = relationships?.Where(x => x.RelationshipMembers.Any(n => n.MemberId == memberReadModel.Id)).ToList()
            });
        }
        public async Task <DetailReadModel> CreateDetail(Guid memoryBookUniverseId, MemberReadModel creator, string customDetailText, DetailTypeEnum detailType, DateTime?startDate, DateTime?endDate = null)
        {
            Contract.RequiresNotNull(creator, nameof(creator));

            var detailTypeReadModel = await this.GetDetailType(detailType).ConfigureAwait(false);

            DetailCreateModel detailCreateModel = new DetailCreateModel
            {
                StartTime        = startDate,
                EndTime          = endDate,
                CreatorId        = creator.Id,
                CustomDetailText = customDetailText,
                DetailTypeId     = detailTypeReadModel.Id
            };

            return(await this.CreateDetail(memoryBookUniverseId, detailCreateModel)
                   .ConfigureAwait(false));
        }
        public async Task <Guid> CreateTwoPersonRelationship(
            MemberReadModel firstMember,
            MemberReadModel secondMember,
            RelationshipTypeEnum firstMemberRelationshipType,
            RelationshipTypeEnum secondMemberRelationshipType,
            DateTime?startDate,
            DateTime?endDate)
        {
            Contract.RequiresNotNull(firstMember, nameof(firstMember));
            Contract.RequiresNotNull(secondMember, nameof(secondMember));

            RelationshipTypeReadModel firstMemberRelationshipTypeModel = await this.relationshipTypeProvider
                                                                         .GetRelationshipType(firstMemberRelationshipType).ConfigureAwait(false);

            RelationshipTypeReadModel secondMemberRelationshipTypeModel = await this.relationshipTypeProvider
                                                                          .GetRelationshipType(secondMemberRelationshipType).ConfigureAwait(false);

            var createModel = new CombinedRelationshipCreateModel
            {
                RelationshipMembers = new List <CombinedRelationshipMemberCreateModel>
                {
                    new CombinedRelationshipMemberCreateModel
                    {
                        MemberId = firstMember.Id,
                        MemberRelationshipTypeId = firstMemberRelationshipTypeModel.Id,
                    },
                    new CombinedRelationshipMemberCreateModel
                    {
                        MemberId = secondMember.Id,
                        MemberRelationshipTypeId = secondMemberRelationshipTypeModel.Id
                    }
                },
                StartDate = startDate,
                EndDate   = endDate
            };

            return((await this.CreateRelationships(firstMember.MemoryBookUniverseId, new List <CombinedRelationshipCreateModel> {
                createModel
            }).ConfigureAwait(false))?.FirstOrDefault() ?? Guid.Empty);
        }
        private async Task <Guid> LoadData(Guid universeId)
        {
            Guid groupId = await this.groupManager.CreateGroup(universeId, "TheMikeEicks", "The Mike Eicks", "The family of Diane and Michael Eick");

            MemberReadModel mike = await this.memberManager.CreateMember(universeId, "Michael", "David", "Eick", "Mike");

            MemberReadModel diane = await this.memberManager.CreateMember(universeId, "Diane", "Gail", "Eick", "Diane");

            MemberReadModel lisa = await this.memberManager.CreateMember(universeId, "Lisa", "Jean", "Eick", "Lisa");

            MemberReadModel sara = await this.memberManager.CreateMember(universeId, "Sara", "Ann", "Eick", "Sara");

            MemberReadModel ian = await this.memberManager.CreateMember(universeId, "Ian", "Gilmore", "Mitchel", "Ian");

            MemberReadModel david = await this.memberManager.CreateMember(universeId, "David", "Randolph", "Ulmer", "David");

            List <MemberReadModel> allMembers = new List <MemberReadModel>
            {
                mike, diane, lisa, sara, ian, david
            };

            await this.groupManager.AddMembersToGroup(universeId, groupId, allMembers.ToList())
            .ConfigureAwait(false);

            await this.memberDetailManager.CreateBirthday(universeId, sara, mike.Id, new DateTime(1956, 12, 1), "Mt. Clemens, MI");

            await this.memberDetailManager.CreateBirthday(universeId, sara, diane.Id, new DateTime(1957, 1, 25), "Rochester, MI");

            await this.memberDetailManager.CreateBirthday(universeId, sara, lisa.Id, new DateTime(1988, 2, 21), "Rochester, MI");

            await this.memberDetailManager.CreateBirthday(universeId, sara, sara.Id, new DateTime(1993, 5, 11), "Rochester, MI");

            await this.memberDetailManager.CreateBirthday(universeId, sara, ian.Id, new DateTime(1993, 1, 19), "Reno, NV");

            await this.memberDetailManager.CreateBirthday(universeId, sara, david.Id, new DateTime(1991, 5, 25), "Grosse Pointe, MI");

            var mikeDianeRelationshipId = await this.relationshipManager.CreateTwoPersonRelationship(mike, diane, RelationshipTypeEnum.Husband, RelationshipTypeEnum.Wife, new DateTime(1986, 6, 14), null);

            await this.relationshipManager.CreateTwoPersonRelationship(mike, lisa, RelationshipTypeEnum.Father, RelationshipTypeEnum.Daughter, new DateTime(1988, 2, 21), null);

            await this.relationshipManager.CreateTwoPersonRelationship(diane, lisa, RelationshipTypeEnum.Mother, RelationshipTypeEnum.Daughter, new DateTime(1988, 2, 21), null);

            await this.relationshipManager.CreateTwoPersonRelationship(mike, sara, RelationshipTypeEnum.Father, RelationshipTypeEnum.Daughter, new DateTime(1993, 05, 11), null);

            await this.relationshipManager.CreateTwoPersonRelationship(diane, sara, RelationshipTypeEnum.Mother, RelationshipTypeEnum.Daughter, new DateTime(1993, 05, 11), null);

            await this.relationshipManager.CreateTwoPersonRelationship(lisa, sara, RelationshipTypeEnum.Sister, RelationshipTypeEnum.Sister, new DateTime(1993, 05, 11), null);

            await this.relationshipManager.CreateTwoPersonRelationship(lisa, sara, RelationshipTypeEnum.Sister, RelationshipTypeEnum.Friend, new DateTime(2011, 05, 11), null);

            await this.relationshipManager.CreateTwoPersonRelationship(david, sara, RelationshipTypeEnum.Boyfriend, RelationshipTypeEnum.Girlfriend, new DateTime(2018, 10, 26), null);

            await this.relationshipManager.CreateTwoPersonRelationship(ian, lisa, RelationshipTypeEnum.Boyfriend, RelationshipTypeEnum.Girlfriend, new DateTime(2018, 10, 11), null);

            await this.relationshipDetailManager.CreateWedding(mike, mikeDianeRelationshipId, new DateTime(1986, 6, 14), "St. Johns Lutheran Church in New Baltimore, MI")
            .ConfigureAwait(false);

            DateTime stevenWeddingDate = new DateTime(2020, 2, 29);

            await this.memberDetailManager.CreateEvent(mike, allMembers.Select(x => x.Id).ToList(), stevenWeddingDate, stevenWeddingDate, "Steven and Jonathan's Wedding Celebration")
            .ConfigureAwait(false);

            return(groupId);
        }
Exemple #9
0
        public async Task <DetailReadModel> CreateBirthday(Guid memoryBookUniverseId, MemberReadModel creator, Guid memberId, DateTime birthday, string birthplace = null)
        {
            Contract.RequiresNotNull(creator, nameof(creator));

            var detailsForMember = await this.detailProvider.GetDetailsForMembers(memoryBookUniverseId, memberId).ConfigureAwait(false);

            var details = detailsForMember?.FirstOrDefault()?.Details;

            if (details != null && details.Any(x => x.DetailTypeCode.Equals(DetailTypeEnum.LifeSpan.ToString())))
            {
                throw new InvalidOperationException($"Lifespan already existed for member {memberId} for universe {memoryBookUniverseId}");
            }

            string birthplaceText = string.Empty;

            if (!string.IsNullOrWhiteSpace(birthplace))
            {
                birthplaceText = $" in {birthplace}";
            }

            var customDetailText = $"Born {birthday.ToShortDateString()}{birthplaceText}";

            var detail = await this.detailProvider.CreateDetail(memoryBookUniverseId, creator, customDetailText, DetailTypeEnum.LifeSpan, birthday)
                         .ConfigureAwait(false);

            if (detail != null)
            {
                await this.detailAssociationProvider.CreateMemberDetailAssociation(detail, new List <Guid> {
                    memberId
                })
                .ConfigureAwait(false);
            }

            return(detail);
        }