Пример #1
0
        public async Task <Guid?> AddMealScheduleEntryAsync(Guid userId, MealScheduleEntryCreationVM newMealScheduleEntry)
        {
            var dbMealScheduleEntry = _mapper.Map <MealScheduleEntry>(newMealScheduleEntry);

            dbMealScheduleEntry.UserId = userId;

            bool addedSuccessfully = await _mealScheduleRepository.AddAsync(dbMealScheduleEntry);

            if (!addedSuccessfully)
            {
                return(null);
            }

            var checkNumberOfMealUsesTask  = _achievementService.CheckForNumberOfMealUsesAsync(dbMealScheduleEntry.MealId);
            var checkConsequentUpdatesTask = _achievementService.CheckForConsequentScheduleUpdatesAsync(userId);

            await Task.WhenAll(checkNumberOfMealUsesTask, checkConsequentUpdatesTask);

            return(dbMealScheduleEntry.Id);
        }