Exemple #1
0
        public bool UpdateInterest(string userId, InterestDto interest)
        {
            try
            {
                //Validate user
                if (_userRepository.IsAuthenticated(userId))
                {
                    var record = _interestRepository.GetInterestById(interest.Id.ToString());;
                    if (record != null)
                    {
                        interest.CreateDate = record.CreateDate;
                        //Validate Model
                        ICollection <ValidationResult> results;
                        if (IsValidModel(interest, out results))
                        {
                            if (ModelCompareChecker.Compare(interest, record))
                            {
                                return(true);
                            }

                            record.Title   = interest.Title;
                            record.Summary = interest.Summary;

                            return(_interestRepository.UpdateInterest(record));
                        }
                        _loggingService.Info("Model Validation Failed: " + interest);
                    }
                }
                _loggingService.Info("UserId Authenticated Failed: " + userId);
            }
            catch (Exception ex)
            {
                //Error
                _loggingService.Error("An error has occurred", ex);
            }
            //Fail
            return(false);
        }