public async Task <IEnumerable <CatEntity> > RetrieveTwoRandomCats(FurTypesValueObject?furType = null) { var parameter = new SelectMultipleCatsParameters(furType: furType); var cats = (await repository.GetAsync <CatEntity, SelectMultipleCatsParameters>(parameter)).OrderBy(x => x.ProbabilityWeight); var catOneId = await catChoiceStrategy.ChoseCatContestant(cats); var catTwoId = await catChoiceStrategy.GetAnotherCat(catOneId, cats); var parameters = new SelectTwoCatsParameters(catOneId, catTwoId, furType); return(await repository.GetAsync <CatEntity, SelectTwoCatsParameters>(parameters)); }
public async Task <IActionResult> GetCatsByFurType(FurTypesValueObject furType) { //-- //-- Applicative logic : should be factorized in Applicatio Layer (CatMash.Core.Application) //-- var parameters = new SelectMultipleCatsParameters(furType: furType); var cats = (await repository.GetAsync <CatEntity, SelectMultipleCatsParameters>(parameters)).OrderByDescending(x => x.ProbabilityWeight); if (cats.Count() > 0 && cats != null) { return(Ok(cats)); } return(NotFound()); }
public async Task <IEnumerable <Cat> > GetCats(FurTypesEnum?furType = null) { var parameters = new SelectMultipleCatsParameters(furType: furType); return((await _repository.GetAsync <Cat, SelectMultipleCatsParameters>(parameters)).OrderByDescending(x => x.ProbabilityWeight)); }