public Interest Create(string name, int? relatedTo) { //TODO: this formatting logic needs to be fixed for some things like iPhone not Iphone //and this logic should probably reside in the Interest Class string formattedName = Thread.CurrentThread.CurrentCulture.TextInfo.ToTitleCase(name.ToLower().Trim()); var interest = new Interest(formattedName) { CreateDate = DateTime.UtcNow, ParentInterest = relatedTo.HasValue ? Get(relatedTo.Value) : null }; _interestRepository.SaveOrUpdate(interest); return interest; }
//TODO: consider law of demeter violation - should we be working with user class instead of directly with userInterest?? //http://msdn.microsoft.com/en-us/magazine/cc947917.aspx#id0070040 - i think we can skip the law of demeter since we're working //directly with user intersts public virtual void AddPost(Post post, Interest interest) { post.User = this; post.Interest = interest; _posts.Add(post); UpdateLastActivity(); }
public virtual UserInterest AddInterest(Interest interest, int? socialityPoints) { var existingUserInterest = _interests.FirstOrDefault(x => x.Interest == interest); if (existingUserInterest == null) { existingUserInterest = new UserInterest { User = this, Interest = interest, SocialityPoints = socialityPoints }; _interests.Add(existingUserInterest); } UpdateLastActivity(); return existingUserInterest; }