コード例 #1
0
ファイル: User.cs プロジェクト: scottccoates/CliqFlip
 public virtual void RemoveInterestPost(Post post)
 {
     _posts.Remove(post);
     UpdateLastActivity();
 }
コード例 #2
0
ファイル: User.cs プロジェクト: scottccoates/CliqFlip
 //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();
 }
コード例 #3
0
ファイル: PostTasks.cs プロジェクト: scottccoates/CliqFlip
 public void Save(Post post)
 {
     _postRepository.SaveOrUpdate(post);
 }
コード例 #4
0
ファイル: UserTasks.cs プロジェクト: scottccoates/CliqFlip
        public void PostWebPage(User user, int userInterestId, string linkUrl)
        {
            UserInterest interest = user.Interests.First(x => x.Id == userInterestId);

            linkUrl = linkUrl.FormatWebAddress();
            string html = _webContentService.GetHtmlFromUrl(linkUrl);
            PageDetails details = _pageParsingService.GetDetails(html);

            string description = details.Description;

            var uri = new Uri(linkUrl);
            var domain = uri.GetLeftPart(UriPartial.Authority).Replace(uri.GetLeftPart(UriPartial.Scheme), "");

            var medium = new WebPage { LinkUrl = linkUrl, WebPageDomainName = domain, Title = details.Title, CreateDate = DateTime.UtcNow };
            var post = new Post { Description = description, CreateDate = DateTime.UtcNow, Medium = medium };

            //determine if image is available
            if (!string.IsNullOrWhiteSpace(details.ImageUrl))
            {
                byte[] data = _webContentService.GetDataFromUrl(details.ImageUrl);
                string fileName = Path.GetFileName(details.ImageUrl);
                using (var memoryStream = new MemoryStream(data))
                {
                    var fileStreamDto = new FileStreamDto(memoryStream, fileName);
                    SaveImageForUser(
                        fileStreamDto, user.Username + "-Interest-WebPage-Image-" + interest.Interest.Name, imgFileNamesDto =>
                                                                                                            medium.AddImage(
                                                                                                                new ImageData(fileName, imgFileNamesDto.ThumbFilename, imgFileNamesDto.MediumFilename, imgFileNamesDto.FullFilename)));
                }
            }

            user.AddPost(post, interest.Interest);
        }
コード例 #5
0
ファイル: UserTasks.cs プロジェクト: scottccoates/CliqFlip
        public void PostVideo(User user, int userInterestId, string videoUrl)
        {
            UserInterest interest = user.Interests.First(x => x.Id == userInterestId);

            videoUrl = videoUrl.FormatWebAddress();
            string html = _webContentService.GetHtmlFromUrl(videoUrl);
            PageDetails details = _pageParsingService.GetDetails(html);

            string description = details.Description;

            if (string.IsNullOrWhiteSpace(details.VideoUrl))
            {
                throw new RulesException("Description", "Invalid video");
            }

            var medium = new Video { VideoUrl = details.VideoUrl, Title = details.Title, CreateDate = DateTime.UtcNow };

            var post = new Post { Medium = medium, Description = description, CreateDate = DateTime.UtcNow };

            //determine if image is available
            if (!string.IsNullOrWhiteSpace(details.ImageUrl))
            {
                byte[] data = _webContentService.GetDataFromUrl(details.ImageUrl);
                string fileName = Path.GetFileName(details.ImageUrl);
                using (var memoryStream = new MemoryStream(data))
                {
                    var fileStreamDto = new FileStreamDto(memoryStream, fileName);
                    SaveImageForUser(
                        fileStreamDto, user.Username + "-Interest-Video-Image-" + interest.Interest.Name, imgFileNamesDto =>
                                                                                                          medium.AddImage(
                                                                                                              new ImageData(fileName, imgFileNamesDto.ThumbFilename, imgFileNamesDto.MediumFilename, imgFileNamesDto.FullFilename)));
                }
            }

            user.AddPost(post, interest.Interest);
        }
コード例 #6
0
ファイル: UserTasks.cs プロジェクト: scottccoates/CliqFlip
 public void PostStatus(User user, int userInterestId, string description)
 {
     UserInterest interest = user.Interests.First(x => x.Id == userInterestId);
     var post = new Post { Description = description, CreateDate = DateTime.UtcNow };
     user.AddPost(post, interest.Interest);
 }