Beispiel #1
0
 public InterestDto GetInterestById(string userId, string interestId)
 {
     try
     {
         //Validate user
         if (_userRepository.IsAuthenticated(userId))
         {
             //GetUserProfile
             var interest = _interestRepository.GetInterestById(interestId);
             if (interest != null)
             {
                 //Success
                 return(interest);
             }
             _loggingService.Info("Not profile for the user found: " + userId);
         }
         _loggingService.Info("UserId Authenticated Failed: " + userId);
     }
     catch (Exception ex)
     {
         //Error
         _loggingService.Error("An error has occurred", ex);
     }
     //Fail
     return(null);
 }
Beispiel #2
0
        public async Task <Result> UpdateInterest(InterestDTO interestDTO)
        {
            if (interestDTO == null)
            {
                return(Result.Fail(Constants.InterestErrorMessages.Interest_Should_Not_Be_Empty));
            }
            var interest = Interest.Create(interestDTO.InterestName, interestDTO.InterestDescription);

            if (!interest.IsSuccessed)
            {
                return(Result.Fail(interest.GetErrorString()));
            }
            var actualInterest = await _interestRepository.GetInterestById(interestDTO.Id);

            if (!actualInterest.IsSuccessed)
            {
                return(Result.Fail(actualInterest.GetErrorString()));
            }
            actualInterest.Value.UpdateInterest(interest.Value);
            _interestRepository.Update(actualInterest.Value);
            return(await _interestRepository.SaveChangesAsync(InterestErrorMessages.Error_Occured_While_Updating_Interest));
        }