Esempio n. 1
0
        private async Task ProcessMixesAsync(Guid id, CocktailModel model, CancellationToken cancellationToken)
        {
            var mixes = await _mixRepository.GetAsync(x => QueryFunctions.GetByIdFunction <Mix>()(x, id), cancellationToken);

            foreach (var mix in mixes)
            {
                var modelMix = model.Mixes.FirstOrDefault(x => x.IngredientId == mix.IngredientId);
                if (modelMix != null)
                {
                    if (modelMix.Amount != mix.Amount)
                    {
                        mix.Amount = modelMix.Amount;
                        await _mixRepository.UpdateAsync(mix, cancellationToken, false);
                    }
                    model.Mixes.Remove(modelMix);
                }
                else
                {
                    await _mixRepository.DeleteAsync(mix, cancellationToken, false);
                }
            }
        }
Esempio n. 2
0
        public virtual async Task <TModel> GetByIdAsync(Guid id, CancellationToken cancellationToken)
        {
            var result = await Repository.GetSingleAsync(x => IncludeFunction(QueryFunctions.GetByIdFunction <TEntity>()(x, id)), cancellationToken);

            return(Mapper.Map <TModel>(result));
        }