Beispiel #1
0
        public User AddInterest(int userId, string interestName)
        {
            User     user     = (User)_userRepo.Get(userId);
            Interest interest = _interestRepository.GetByName(interestName);

            if (user.Interests.Contains(interest))
            {
                return(null);
            }

            if (interest == null)
            {
                Interest newInterest = new Interest {
                    Name = interestName
                };

                var saved = _interestRepository.Save(newInterest);
                saved.AddUser(user);

                _interestRepository.Update(saved);
            }
            else
            {
                interest.AddUser(user);
                _interestRepository.Update(interest);
            }

            return(user);
        }
Beispiel #2
0
        public void TestGetByName()
        {
            var interest = new Interest {
                Name = "Skijanje"
            };

            _interestRepo.Save(interest);

            Assert.NotNull(_interestRepo.GetByName("skijanje"));
            Assert.NotNull(_interestRepo.GetByName("Skijanje"));
            Assert.NotNull(_interestRepo.GetByName("SkIjAnjE"));
            Assert.Null(_interestRepo.GetByName("nepostojece"));
        }