Ejemplo n.º 1
0
        /// <summary>
        ///     Deletes a given workout
        ///     Uses userid for validation purposes
        /// </summary>
        /// <param name="userId">uid of user</param>
        /// <param name="workoutId">uid of workout</param>
        /// <returns></returns>
        public async Task <bool> DeleteWorkoutAsync(int userId, int workoutId)
        {
            if (workoutId < 1 || userId < 1)
            {
                LogError("DeleteWorkoutAsync",
                         $"Provided one or more Ids were invalid : userid {userId}, workoutId {workoutId} ");
                return(false);
            }

            var user = await _userRepository.GetUser(userId);

            if (user == null)
            {
                return(false);
            }
            LogNonExistingUserError("DeleteWorkoutAsync", userId);

            var isSuccess = await _workoutRepository.DeleteAsync(workoutId);

            if (isSuccess)
            {
                LogCritical("DeleteWorkoutAsync", $"Deleted workout {workoutId} for user with id {userId}");
            }
            else
            {
                LogError("DeleteWorkoutAsync", $"Failed to workout {workoutId} for user with id {userId}");
            }
            return(isSuccess);
        }
Ejemplo n.º 2
0
        public async Task <WorkoutDTO> DeleteLastWorkoutFromRoutineAsync(long Id)
        {
            var workout = await _routineRepository.GetLastWorkoutFromRoutineAsync(Id);

            var deletedWorkout = await _workoutRepository.DeleteAsync(workout);

            return(_mapper.Map <WorkoutDTO>(deletedWorkout));
        }
Ejemplo n.º 3
0
        public async Task <Workout> DeleteAsync(int id)
        {
            await EnforceWorkoutExistenceAsync(id);

            return(await _workoutRepository.DeleteAsync(id));
        }