Esempio n. 1
0
        public async Task <IEnumerable <Training> > GetTrainingsAsync(CardItem.CardItem card, Guid userId)
        {
            var found = await repository.GetCardTrainingsAsync(card.Id);

            if (found.Count() == 0)
            {
                throw new AppException("Could not find created training for this card");
            }
            if (found.Any(t => t.UserId != userId))
            {
                throw new AppException("Not allowed for this user");
            }
            return(found);
        }
Esempio n. 2
0
        public async Task <Training> GetTrainingAsync(CardItem.CardItem card, Guid userId)
        {
            var found = await repository.GetCardTrainingAsync(card.Id);

            if (found == null)
            {
                throw new AppException("Could not find created training for this card");
            }
            if (found.UserId != userId)
            {
                throw new AppException("Not allowed for this user");
            }
            return(found);
        }