/// <summary> /// User has answered the question. /// </summary> /// <param name="userId">The user identifier.</param> /// <param name="questionsAnswers">The questions answers.</param> /// <returns>Task{OperationResult}.</returns> /// <exception cref="System.ArgumentNullException">Wrong input</exception> public async Task <ColorResult> AnswerQuestions(string userId, PersonQualityIdWithScore[] questionsAnswers) { //TODO check if user has already answered questions if (string.IsNullOrEmpty(userId) || questionsAnswers == null) { throw new ArgumentNullException( string.IsNullOrEmpty(userId) ? "userId" : "questionsAnswers", "Wrong input"); } var user = await _userRepository.GetUser(userId); if (user == null) { return((ColorResult)OperationResult.NotFound); } RewardsCalculator.UpdateUserAfterAnsweringQuestion(questionsAnswers, user); await _assignmentService.AssignMissionSetLine(user); await RewardsCalculator.SetNewMissionSets(user, _missionRepository); RewardsCalculator.UpdateRadrugaColor(user, true); var userUpdateResult = await _userRepository.UpdateUser(user); return(userUpdateResult.Status == OperationResultStatus.Success ? new ColorResult(user.RadrugaColor) : (ColorResult)userUpdateResult); }