public async Task <RetrieveEntityResult <IReadOnlyList <Transformation> > > GetTransformationsByPartAndSpeciesAsync ( Bodypart bodypart, Species species ) { var bodyparts = new List <Bodypart>(); if (bodypart.IsComposite()) { bodyparts.AddRange(bodypart.GetComposingParts()); } else { bodyparts.Add(bodypart); } var transformations = await _database.Transformations.AsQueryable() .Where(tf => bodyparts.Contains(tf.Part) && tf.Species.Name.ToLower().Equals(species.Name.ToLower())) .ToListAsync(); if (!transformations.Any()) { return(RetrieveEntityResult <IReadOnlyList <Transformation> > .FromError ( "No transformation found for that combination." )); } return(RetrieveEntityResult <IReadOnlyList <Transformation> > .FromSuccess(transformations)); }
/// <inheritdoc /> public async Task <ShiftBodypartResult> ShiftAsync(Bodypart bodypart, Chirality chirality) { if (bodypart.IsComposite()) { return(await ShiftCompositeBodypartAsync(bodypart)); } return(await ShiftBodypartAsync(bodypart, chirality)); }
/// <inheritdoc /> public async Task <Result <ShiftBodypartResult> > RemoveAsync(Bodypart bodypart, Chirality chirality) { if (bodypart.IsChiral() && chirality == Chirality.Center) { return(new UserError("Please specify left or right when removing one-sided bodyparts.")); } if (bodypart.IsComposite()) { return(await RemoveCompositeBodypartAsync(bodypart)); } return(await RemoveBodypartAsync(bodypart, chirality)); }
/// <inheritdoc /> public async Task <ShiftBodypartResult> ShiftAsync(Bodypart bodypart, Chirality chirality) { if (bodypart.IsChiral() && chirality == Chirality.Center) { return(ShiftBodypartResult.FromError("Please specify left or right when shifting one-sided bodyparts.")); } if (bodypart.IsComposite()) { return(await ShiftCompositeBodypartAsync(bodypart)); } return(await ShiftBodypartAsync(bodypart, chirality)); }
public AppearanceComponent GetAppearanceComponent(Bodypart bodypart, Chirality chirality) { if (bodypart.IsChiral() && chirality == Chirality.Center) { throw new ArgumentException("A chiral bodypart must have its chirality specified.", nameof(bodypart)); } if (!bodypart.IsChiral() && chirality != Chirality.Center) { throw new ArgumentException("A nonchiral transformation cannot have chirality.", nameof(bodypart)); } if (bodypart.IsComposite()) { throw new ArgumentException("The bodypart must not be a composite part."); } return(this.Components.First(c => c.Bodypart == bodypart && c.Chirality == chirality)); }