Beispiel #1
0
 protected bool AnyWildlifeEffects() =>
 (PlantInfo.WildlifeEffects != null && PlantInfo.WildlifeEffects.Any()) ||
 (ChosenWildlifeEffects != null && ChosenWildlifeEffects.Any());
Beispiel #2
0
        protected async Task SavePlantInfoAsync()
        {
            var isNewPlantInfo = PlantInfo.PlantInfoId == 0;

            if (isNewPlantInfo)
            {
                PlantInfo.DateCreated = DateTime.UtcNow;
            }
            else
            {
                PlantInfo.DateModified = DateTime.UtcNow;
            }

            PlantInfo.Origin    = SelectedOrigin;
            PlantInfo.Photos    = UploadedPhotos.Any() ? UploadedPhotos : null;
            PlantInfo.Lifeform  = PlantInfo.SelectedLifeform;
            PlantInfo.CreatedBy = UserId;
            PlantInfo.Requirements.StratificationStages = ChosenStratificationStages != null && ChosenStratificationStages.Any() ? ChosenStratificationStages.ToList() : null;
            PlantInfo.WildlifeEffects = ChosenWildlifeEffects != null && ChosenWildlifeEffects.Any() ? ChosenWildlifeEffects.ToList() : null;
            PlantInfo.SoilTypes       = ChosenSoilTypes != null && ChosenSoilTypes.Any() ? ChosenSoilTypes.ToList() : null;

            if (PlantInfo.Height.MinimumHeight.HasValue || PlantInfo.Height.MaximumHeight.HasValue)
            {
                PlantInfo.Height.Unit = DistanceUnit.Feet;
            }
            else
            {
                PlantInfo.Height.Unit = DistanceUnit.Unknown;
            }

            if (PlantInfo.Spread.MinimumSpread.HasValue || PlantInfo.Spread.MaximumSpread.HasValue)
            {
                PlantInfo.Spread.Unit = DistanceUnit.Feet;
            }
            else
            {
                PlantInfo.Spread.Unit = DistanceUnit.Unknown;
            }

            if (MinimumZoneId != PlantInfo.Requirements.ZoneRequirements?.MinimumZone?.Id)
            {
                PlantInfo.Requirements.ZoneRequirements = new ZoneRequirements
                {
                    MinimumZone = Zones.First(z => z.Id == MinimumZoneId)
                };
            }

            if (MaximumZoneId != PlantInfo.Requirements.ZoneRequirements?.MaximumZone?.Id)
            {
                if (PlantInfo.Requirements.ZoneRequirements == null)
                {
                    PlantInfo.Requirements.ZoneRequirements = new ZoneRequirements
                    {
                        MaximumZone = Zones.First(z => z.Id == MaximumZoneId)
                    };
                }
                else
                {
                    PlantInfo.Requirements.ZoneRequirements.MaximumZone = Zones.First(z => z.Id == MaximumZoneId);
                }
            }

            PlantInfo = await ApiClient.PutPlantInfoAsync(PlantInfo);

            if (BlazoredModal != null)
            {
                await BlazoredModal.Close(ModalResult.Ok(PlantInfo));
            }
            else
            {
                await CancelAsync(isNewPlantInfo);
            }
        }