Exemplo n.º 1
0
 public static ActorDto ToActorDto(this ICForestPlot entity)
 {
     return entity == null
         ? null
         : new ActorDto
         {
             Id = entity.APActor.Id,
             Email = entity.APActor.APActorEmail,
             Phone = entity.APActor.APActorPhone,
             Name = entity.APActor.APActorName,
             Website = entity.APActor.APActorWebsite,
             Avatar = entity.APActor.APActorAvatar.ToImageUrl(),
             //AverageRating = entity.APActorReviews.IsNullOrEmpty() ? 0 : (decimal)entity.APActorReviews.Sum(x => x.APActorReviewRating) / entity.APActorReviews.Count,
             AverageRating = entity.APActorReviews.Where(o => o.FK_APActorID == entity.FK_APActorID).Count() > 0
             ? entity.APActorReviews.ToAverageRating(entity) : 5,
             AggregateOfRatings = entity.APActorReviews.Where(o => o.FK_APActorID == entity.FK_APActorID).ToArray().ToAggregateOfRatings(),
             Reviews = entity.APActorReviews.Where(o => o.FK_APActorID == entity.FK_APActorID).ConvertArray(x => x.ToReviewItemDto()),
             AcronymName = entity.APActor.APActorAcronymName,
             Address = entity.APActor.APActorAddress,
             Commune = entity.APActor.GECommune.ToDictionaryItemDto(),
             District = entity.GEDistrict.ToDictionaryItemDto(),
             Fax = entity.APActor.APActorFax,
             HouseNumber = entity.APActor.APActorHouseNumber,
             IdentityCard = entity.APActor.APActorIdentityCard,
             Representative = entity.APActor.APActorRepresentative,
             StateProvince = entity.GEStateProvince.ToDictionaryItemDto(),
             Type = entity.APActor.APActorType.ToActorTypeDto(),
             Roles = entity.APActor.APActorRoles.ConvertArray(x => x?.APRole.ToDictionaryItemDto()),
             Status = entity.APActor.APActorStatus.ToDictionaryItemDto<UserStatus>(),
             ForestPlot = entity.ToForestPlotDto(),
             ContactName = entity.APActor.APActorContactName,
             ContactPhone = entity.APActor.APActorContactPhone,
             Note = entity.APActor.APActorNote
         };
 }
Exemplo n.º 2
0
 public static ShortActorDto ToShortActorDto(this ICForestPlot entity)
 {
     return entity == null
         ? null
         : new ShortActorDto
         {
             Name = entity.APActor.APActorName,
             Type = entity.APActor?.APActorType.ToActorTypeDto(),
             Email = entity.APActor.APActorEmail,
             Phone = entity.APActor.APActorPhone,
             Website = entity.APActor.APActorWebsite,
             ForestPlot = entity.ToForestPlotDto(),
             AverageRating = entity.APActorReviews.Where(o => o.FK_APActorID == entity.FK_APActorID).Count() > 0 
             ? entity.APActorReviews.ToAverageRating(entity) : 5,
             ReviewCount = entity.APActorReviews.Where(o => o.FK_APActorID == entity.FK_APActorID).Count() > 0 
             ? entity.APActorReviews.Where(o => o.FK_APActorID == entity.FK_APActorID).Count() : 0
         };
 }