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 }); }
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); }
public static string GetTimeSinceStart(DetailReadModel d, PeriodUnits pu, bool label) { return(GetTimeBetween(d.StartTime.Value, DateTime.Now, pu, label)); }
public async Task CreateGroupDetailAssociation(DetailReadModel detail, Guid groupId) { await this.CreateDetailAssociation(detail, EntityTypeEnum.Group, groupId) .ConfigureAwait(false); }
public async Task CreateRelationshipDetailAssociation(DetailReadModel detail, Guid relationshipId) { await this.CreateDetailAssociation(detail, EntityTypeEnum.Relationship, relationshipId) .ConfigureAwait(false); }
public async Task CreateMemberDetailAssociation(DetailReadModel detail, IList <Guid> memberIds) { await this.CreateDetailAssociation(detail, EntityTypeEnum.Member, memberIds?.ToArray()) .ConfigureAwait(false); }