コード例 #1
0
        public async Task <Result> SetUserInterests(User user, int[] interestIds)
        {
            if (interestIds == null || interestIds.Length <= 0)
            {
                return(Result.Ok());
            }

            var interestsResult = await _interestRepository.GetInterestsByIds(interestIds);

            if (!interestsResult.IsSuccessed)
            {
                return(Result.Fail(interestsResult.GetErrorString()));
            }
            var interests = interestsResult.Value;

            if (AreInvalidInterestIdsPresent(interestIds, interests))
            {
                return(Result.Fail(Invalid_Interest));
            }

            user.SetInterests(interests);

            return(Result.Ok());
        }