示例#1
0
        public string Edit(Post post, int sectedUserId, int selectedBlogId)
        {
            var slugExists = _context.Posts.FirstOrDefault(x => x.Slug == post.Slug);
            if (slugExists !=null && slugExists.Id != post.Id)
                return "The slug that was created already exists. Modify your title.";

            UserProfile user = _context.UserProfiles.Find(sectedUserId);
            Blog blog = _context.Blogs.Find(selectedBlogId);

            Post updatedPost = _context.Posts.Find(post.Id);
            if (updatedPost == null) return "The specified post could not be found.";

            updatedPost.Tags.Clear();
            _context.SaveChanges();

            updatedPost.Blog = blog;
            updatedPost.DateModified = post.DateModified;
            updatedPost.DatePublished = post.DatePublished;
            updatedPost.Description = post.Description;
            updatedPost.IsDeleted = post.IsDeleted;
            updatedPost.IsPublished = post.IsPublished;
            updatedPost.PostContent = post.PostContent;
            updatedPost.Tags = post.Tags;
            updatedPost.Slug = post.Slug;
            updatedPost.Title = post.Title;
            updatedPost.User = user;
            updatedPost.UniqueId = post.UniqueId;
            _context.SaveChanges();
            _context.Dispose();
            return string.Empty;
        }
示例#2
0
        public void Ping(Post entity)
        {
            IQueryable<PingService> pingList = _pingRepository.GetAll();

            //for now get the default blog name;
            Blog blog = _blogSiteRepository.GetAllBlogs().FirstOrDefault(x => x.IsActive && x.IsPrimary);
            string blogName = blog != null ? blog.BlogName : "Steven Moseley";

            foreach (PingService pingService in pingList)
            {
                _pingWebRequestHelper.Send(pingService.PingUrl, _httpHelper.GetUrl(entity.Slug).ToString(), blogName);
            }
        }
示例#3
0
        public string Add(Post post, int userId, int blogId)
        {
            var slugExists = _context.Posts.Any(x => x.Slug == post.Slug);
            if (slugExists)
                return "The slug that was created already exists. Modify your title.";

            UserProfile user = _context.UserProfiles.Find(userId);
            if (user != null) post.User = user;

            Blog blog = _context.Blogs.Find(blogId);
            post.Blog = blog;

            _context.Posts.Add(post);
            _context.SaveChanges();
            _context.Dispose();
            return string.Empty;
        }
示例#4
0
 public IList<Post> MapToEntity(BlogMLBlog blogML)
 {
     var list = new List<Post>();
     foreach (BlogMLPost blogMLPost in blogML.Posts)
     {
         var post = new Post();
         post.Categories = GetPostCategoryies(blogML.Categories, blogMLPost);
         post.DateCreated = blogMLPost.DateCreated;
         post.DateModified = blogMLPost.DateModified;
         post.IsPublished = true;
         post.DatePublished = blogMLPost.DateModified;
         if (blogMLPost.Excerpt != null) post.Description = blogMLPost.Excerpt.Text;
         post.IsDeleted = false;
         if (blogMLPost.Content != null) post.PostContent = blogMLPost.Content.Text;
         post.Slug = blogMLPost.Title.ToSlug();
         post.Title = blogMLPost.Title;
         Guid guid;
         if (!Guid.TryParse(blogMLPost.ID, out guid))
             guid = Guid.NewGuid();
         post.UniqueId = guid;
         list.Add(post);
     }
     return list;
 }
示例#5
0
 public string Edit(Post post)
 {
     throw new System.NotImplementedException();
 }
示例#6
0
 public PostViewModel MapToView(Post entity)
 {
     return Mapper.Map<Post, PostViewModel>(entity);
 }
示例#7
0
 private void SendPing(Post entity, string result)
 {
     //if post added is successful then ping all the services with the URL
     if (string.IsNullOrEmpty(result)) if (ConfigurationManager.AppSettings["PingService"].Equals("true")) _pingHttpPostService.Ping(entity);
 }
示例#8
0
 private IList<TagViewModel> MapTags(Post post)
 {
     return post.Tags.Select(
         item => new TagViewModel
             {
                 Id = item.Id,
                 Name = item.TagName
             }).ToList();
 }
示例#9
0
 public IndexingError(Post post, Exception exception)
 {
     _post = post;
     _exception = exception;
 }