Пример #1
0
        public async Task <Guid> AddWorkoutScheduleAsync(string username, WorkoutScheduleDTO workoutScheduleDTO)
        {
            await ValidateWorkoutPlanSchedule(username, workoutScheduleDTO);

            var schedules = await GetWorkoutSchedules(username);

            if (ValidateWorkoutScheduleExist(schedules, workoutScheduleDTO))
            {
                throw new Exception("That Workout Already Exist");
            }
            var list = schedules.ToList();

            list.Add(workoutScheduleDTO);
            _workoutScheduleCacheService.Put(username, list);
            _backgroundJobClientService.Enqueue <IAddWorkoutScheduleJob>(x => x.Run(new AddWorkoutScheduleCommand
            {
                ExternalId            = workoutScheduleDTO.ExternalId,
                Created               = _dateTimeService.GetCurrentDate(),
                FirstDate             = workoutScheduleDTO.FirstDate,
                WorkoutPlanExternalId = workoutScheduleDTO.WorkoutPlanExternalId,
                Recurrence            = workoutScheduleDTO.Recurrence,
                RecurringTimes        = workoutScheduleDTO.RecurringTimes
            }));
            return(workoutScheduleDTO.ExternalId);
        }
        public async Task AddWorkoutPlanAsync(string username, WorkoutExecutionDTO workout)
        {
            await ValidateWorkout(workout);

            await _userRepository.AddUserIfNotExists(username);

            AddWorkoutPlanToCache(username, workout);
            _backgroundJobClientService.Enqueue <IAddWorkoutExecutionJob>(x => x.Run(username, workout));
        }
 private void HandleCloseToExpiration(CacheItem <IEnumerable <FatigueDTO> > cacheItem)
 {
     if (cacheItem.ExpirationTimeout < TimeSpan.FromMinutes(10))
     {
         _backgroundJobClientService.Enqueue <IPopulateFatiguesJob>(x => x.Run());
     }
 }