public static ShrimpCropResultDto ToShrimpCropResultDto(this ShrimpCrop entity) { if (entity == null) { return(null); } ShrimpCropResultDto dto = new ShrimpCropResultDto(); dto.CopyPropertiesFrom(entity); dto.FarmingLocation = entity.FarmingLocation.ToShortFarmingLocationDto(); dto.ShrimpBreed = entity.ShrimpBreed.ToShrimpBreedDto(); dto.FromDate = entity.FromDate.ToSecondsTimestamp(); dto.ToDate = entity.ToDate.ToSecondsTimestamp(); dto.Factors = entity.ShrimpCropManagementFactors == null ? null : entity.ShrimpCropManagementFactors.OrderBy(x => x.CreatedAt).Select(x => x.ToShrimpCropManagementFactorDto()).ToArray(); return(dto); }
public static ShrimpCrop ToShrimpCrop(this ShrimpCropResultDto dto) { if (dto == null) { return(null); } var entity = new ShrimpCrop(); entity.CopyPropertiesFrom(dto); entity.FromDate = dto.FromDate.FromUnixTimeStamp(); entity.ToDate = dto.ToDate.FromUnixTimeStamp(); entity.FarmingLocationId = dto.FarmingLocation.Id; entity.ShrimpBreedId = dto.ShrimpBreed.Id; return(entity); }