コード例 #1
0
        public async Task <FishData> GetFishByIdAsync(int id)
        {
            FishEntity x = await _context.Fish.Include(x => x.SpeciesIllustrationPhoto).SingleOrDefaultAsync(x => x.Id == id);

            if (x == null)
            {
                return(new FishData()
                {
                    Id = id,
                    ScientificName = "Not Found",
                    SpeciesName = "Not Found"
                });
            }

            return(new FishData()
            {
                Id = x.Id,
                FisheryManagement = x.FisheryManagement,
                Habitat = x.Habitat,
                HabitatImpacts = x.HabitatImpacts,
                Location = x.Location,
                Population = x.Population,
                PopulationStatus = x.PopulationStatus,
                ScientificName = x.ScientificName,
                SpeciesAliases = x.SpeciesAliases,
                SpeciesIllustrationPhoto = new SpeciesIllustrationPhoto()
                {
                    Src = (x.SpeciesIllustrationPhoto == null) ? string.Empty : (x.SpeciesIllustrationPhoto.Src ?? string.Empty),
                    Alt = (x.SpeciesIllustrationPhoto == null) ? string.Empty : (x.SpeciesIllustrationPhoto.Alt ?? string.Empty),
                    Title = (x.SpeciesIllustrationPhoto == null) ? string.Empty : (x.SpeciesIllustrationPhoto.Title ?? string.Empty)
                },
                ImageGallery = FillGallery(x.ImageGallery),
                SpeciesName = x.SpeciesName,
                Availability = x.Availability,
                Biology = x.Biology,
                Bycatch = x.Bycatch,
                Calories = x.Calories,
                Cholesterol = x.Cholesterol,
                Color = x.Color,
                FatTotal = x.FatTotal,
                FishingRate = x.FishingRate,
                Harvest = x.Harvest,
                HealthBenefits = x.HealthBenefits,
                PhysicalDescription = x.PhysicalDescription,
                Protein = x.Protein,
                Quote = x.Quote,
                QuoteBackgroundColor = x.QuoteBackgroundColor,
                SaturatedFattyAcidsTotal = x.SaturatedFattyAcidsTotal,
                Selenium = x.Selenium,
                Servings = x.Servings,
                Sodium = x.Sodium,
                Source = x.Source,
                Taste = x.Taste,
                Texture = x.Texture,
                Path = x.Path,
                LastUpdate = x.LastUpdate
            });
        }
コード例 #2
0
    void initFish(GameObject fish, FishEntity entity)
    {
        fish.name = entity.id.ToString();
        GameObject go = Instantiate(fish);

        scaleForGameObject(go, entity);
        go.name = entity.id.ToString();
        fishOnScreen.Add(go);
    }
コード例 #3
0
 public static void scaleForGameObject(GameObject go, FishEntity entity)
 {
     go.GetComponent <Transform> ().localScale = new Vector3(entity.size, entity.size, -1);
 }