public bool UpdatePost(PostDTO model) { model.SeoLink = SeoLink.GenerateUrl(model.Title); dao.UpdatePost(model); LogDAO.AddLog(General.ProcessType.PostUpdate, General.TableName.post, model.ID); if (model.PostImages != null) { SavePostImage(model.PostImages, model.ID); } dao.DeleteTags(model.ID); AddTag(model.TagText, model.ID); return(true); }
public PostDTO GetPostWithID(int ID) { PostDTO dto = new PostDTO(); dto = dao.GetPostWithID(ID); dto.PostImages = dao.GetPostImagesWithPostID(ID); List <PostTag> tagList = dao.GetPostTagsWithPostID(ID); string tagValue = ""; foreach (PostTag item in tagList) { tagValue += item.TagContent; tagValue += ","; } dto.TagText = tagValue; return(dto); }
public PostDTO GetPostById(int iD) { PostDTO dto = new PostDTO(); dto = dao.GetPostById(iD); dto.PostImageList = dao.GetPostImagesByPostId(iD); List <PostTag> tagList = dao.GetTagsByPostId(iD); string tagValue = string.Empty; foreach (var item in tagList) { tagValue += item.TagContent; tagValue += ","; } dto.PostTag = tagValue; return(dto); }
public static PostDTO GetPostById(int id) { //var res = (PostDTO)null; using (var ctx = new DbEntities()) { var dbpost = ctx.Posts.Where(x => x.Id == id).FirstOrDefault(); var post = new PostDTO { ImageIds = new List <int>(), Id = dbpost.Id, Comments = new List <int>(), CreateDate = dbpost.CreateDate, Description = dbpost.Description, Location = dbpost.Location, UserId = dbpost.UserId }; dbpost.PostImages.Select(x => x.ImageId).ToList().ForEach(post.ImageIds.Add); dbpost.Comments.Select(x => x.Id).ToList().ForEach(post.Comments.Add); return(post); } }