示例#1
0
        public static DetailViewModel ToViewModel(this DetailReadModel readModel, IDictionary <Guid, DetailTypeReadModel> detailTypeDictionary)
        {
            Contract.RequiresNotNull(readModel, nameof(readModel));

            var detailType = detailTypeDictionary[readModel.DetailTypeId];

            Enum.TryParse <DetailTypeEnum>(detailType.Code, out var detailTypeEnum);

            return(new DetailViewModel
            {
                StartDate = readModel.StartTime,
                EndDate = readModel.EndTime,
                DetailType = detailTypeEnum,
                DetailTypeStartText = detailType.DetailStartText,
                DetailTypeEndText = detailType.DetailEndText,
                DetailTypeText = readModel.CustomDetailText,
                Story = readModel.Story
            });
        }
示例#2
0
        private async Task CreateDetailAssociation(DetailReadModel detail, EntityTypeEnum entityTypeEnum, params Guid[] entityIds)
        {
            if (detail == null)
            {
                return;
            }

            if (entityIds == null || entityIds.Length == 0)
            {
                return;
            }

            var detailAssociations = await this.detailAssociationQueryManager.GetDetailAssociationByDetailId(detail.Id)
                                     .ConfigureAwait(false);

            var entityType = await this.GetEntityType(entityTypeEnum).ConfigureAwait(false);

            IList <DetailAssociationCreateModel> detailAssociationsToCreate = new List <DetailAssociationCreateModel>();

            foreach (var id in entityIds)
            {
                if (detailAssociations != null && detailAssociations.Any(x => x.EntityId == id))
                {
                    continue;
                }

                detailAssociationsToCreate.Add(new DetailAssociationCreateModel
                {
                    DetailId     = detail.Id,
                    EntityTypeId = entityType.Id,
                    EntityId     = id
                });
            }

            await this.detailAssociationCommandManager.CreateDetailAssociation(detailAssociationsToCreate.ToArray())
            .ConfigureAwait(false);
        }
示例#3
0
 public static string GetTimeSinceStart(DetailReadModel d, PeriodUnits pu, bool label)
 {
     return(GetTimeBetween(d.StartTime.Value, DateTime.Now, pu, label));
 }
示例#4
0
 public async Task CreateGroupDetailAssociation(DetailReadModel detail, Guid groupId)
 {
     await this.CreateDetailAssociation(detail, EntityTypeEnum.Group, groupId)
     .ConfigureAwait(false);
 }
示例#5
0
 public async Task CreateRelationshipDetailAssociation(DetailReadModel detail, Guid relationshipId)
 {
     await this.CreateDetailAssociation(detail, EntityTypeEnum.Relationship, relationshipId)
     .ConfigureAwait(false);
 }
示例#6
0
 public async Task CreateMemberDetailAssociation(DetailReadModel detail, IList <Guid> memberIds)
 {
     await this.CreateDetailAssociation(detail, EntityTypeEnum.Member, memberIds?.ToArray())
     .ConfigureAwait(false);
 }