public RecentsController(IPost postRepository, ISettings settingsRepository, ICacheService cacheService) : base(settingsRepository) { _postRepository = postRepository; _cacheService = cacheService; ExpectedMasterName = string.Empty; }
public static void NotifyRoom(IRoom room, IPost post, IMailSender mailSender) { var context = GlobalHost.ConnectionManager.GetHubContext<RoomHub>(); context.Clients.Group(String.Concat("room-", post.RoomId)) .post(post.Id, post.Type, post.AuthorAlias, post.AvatarUrl, post.Text, post.Timestamp.ToString("MMM dd yy @ hh:mm tt")); IEnumerable<string> emailAddresses; if (post.AuthorId == room.OwnerId) emailAddresses = room.Players.Select(x => x.MemberEmailAddress); else emailAddresses = room.Players .Where(x => x.MemberId != post.AuthorId) .Select(x => x.MemberEmailAddress) .Concat(new[] { room.OwnerEmailAddress }); var subject = String.Concat("[", room.Slug, "] ", "New Post"); const string bodyFormat = @"There's a new post to {0}: {1} Visit the room at {2}."; var body = String.Format(CultureInfo.CurrentUICulture, bodyFormat, room.Title, post.Text, MakeAbsoluteUri(Paths.Room(room.Slug))); emailAddresses.ForEach(x => SendMail(x, subject, body)); }
public IPost SavePost(IPost post) { post.UpdatedAt = DateTime.UtcNow; return ((post.Id > 0) ? Cmd("/posts/" + post.Id + "/", RequestType.Put) : Cmd("/posts/", RequestType.Post)) .WithBody(post.ToJson().ToString()).Execute().To<Post>(JsonHelper.CheckResponseForError); }
public void Init(IPost View) { _view = View; if(_webContext.BlogID > 0) { _view.LoadPost(Blog.GetBlogByBlogID(_webContext.BlogID)); } }
public ViewPageController(IPost postRepository, IUser userRepository, ISettings settingsRepository, ICacheService cacheService) : base(settingsRepository) { _postRepository = postRepository; _userRepository = userRepository; _cacheService = cacheService; ExpectedMasterName = "_LayoutPage"; }
private void AddTweetToFollowers(List<IUser> twitterUserList, IPost twitterPost) { foreach (IUser user in twitterUserList) { if (user.Twitterers.Contains(twitterPost.User)) user.TwitterPosts.Add(twitterPost); } }
public CommentController(IPost postRepository, IComment commentsRepository, ISettings settingsRepository, ICacheService cacheService, IError errorLogger) : base(settingsRepository) { _postRepository = postRepository; _cacheService = cacheService; _commentsRepository = commentsRepository; _errorLogger = errorLogger; }
public AdminController(std s, Postings p, Filings f, Contactus c, Commenting com) { studnt = s; post = p; comment = com; file = f; cont = c; }
public void SaveCommit(IPost post, out bool success) { using (IUnitOfWork uow = UnitOfWork.Begin()) { Save(post, out success); if (success) uow.Commit(); } }
public HomeController(IPost postRepository, IUser userRepository, ICategory categoryRepository, ITag tagRepository, ISettings settingsRepository, ICacheService cacheService) : base (settingsRepository) { _postRepository = postRepository; _userRepository = userRepository; _categoryRepository = categoryRepository; _tagRepository = tagRepository; _cacheService = cacheService; }
public AuthorController(IPost postRepository, IUser userRepository, ICacheService cacheService, ISettings settingsRepository) : base(settingsRepository) { _postRepository = postRepository; _userRepository = userRepository; _cacheService = cacheService; _postsPerPage = SettingsRepository.BlogPostsPerPage; }
public static void InitContext() { if (InitEvent != null) { CategoryService = InitEvent(typeof(ICategory)) as ICategory; PostService = InitEvent(typeof(IPost)) as IPost; PostTagMapService = InitEvent(typeof(IPostTagMap)) as IPostTagMap; TagService = InitEvent(typeof(ITag)) as ITag; } }
//make it delete any shows it is related to. or not if you want those always kept. public void Delete(IPost post) { Checks.Argument.IsNotNull(post, "post"); using (IUnitOfWork u = UnitOfWork.Begin()) { _repo.Remove(post); u.Commit(); } }
public static List<PostEntity> GetPagesFromCache(this ICacheService cacheService, IPost postRepository, string keyName, bool isMarkdown) { var markdown = new MarkdownDeep.Markdown{ ExtraMode = true }; var pages = cacheService.Get(keyName, () => postRepository.GetPages()); if (isMarkdown) { pages.ForEach(p => p.PostContent = markdown.Transform(p.PostContent)); } return pages; }
public static string FindUniqueUrl(IPost postRepository, string currentUrl, byte entryType, int? excludeId = null) { var allPosts = postRepository.GetAllPostsOrPages(false); var postEntities = entryType == 1 ? allPosts.Where(p => p.EntryType == 1) : allPosts.Where(p => p.EntryType == 2); if (excludeId.HasValue) { postEntities = postEntities.Where(p => p.PostID != excludeId); } var currentUrls = postEntities.Select(p => p.PostUrl).ToList(); return currentUrl.GetUniqueSlug(currentUrls); }
public CategoryAdminController(ICategory categoryRepository, IPost postRepository, ISettings settingsRepository) : base(settingsRepository) { _categoryRepository = categoryRepository; _postRepository = postRepository; ExpectedMasterName = string.Empty; _itemsPerPage = settingsRepository.ManageItemsPerPage; IsAdminController = true; }
public PageController(IPost postRepository, ITag tagRepository, ISettings settingsRepository) : base(settingsRepository) { _postRepository = postRepository; _tagRepository = tagRepository; ExpectedMasterName = string.Empty; _itemsPerPage = settingsRepository.ManageItemsPerPage; IsAdminController = true; }
public CommentAdminController(IPost postRepository, IComment commentRepository, ISettings settingsRepository) : base(settingsRepository) { _postRepository = postRepository; _commentRepository = commentRepository; ExpectedMasterName = string.Empty; _itemsPerPage = settingsRepository.ManageItemsPerPage; IsAdminController = true; }
public AdminController(IPost postRepository, IComment commentRepository, ICategory categoryRepository, ITag tagRepository, ISettings settingsRepository, IPathMapper pathMapper, IUser userRepository) : base(settingsRepository) { _postRepository = postRepository; _commentRepository = commentRepository; _categoryRepository = categoryRepository; _tagRepository = tagRepository; _pathMapper = pathMapper; _userRepository = userRepository; ExpectedMasterName = string.Empty; IsAdminController = true; }
public static CompactPost Create(IPost post) { return new CompactPost { Id = post.GetKey(), LoadFromWebDate = post.GetLoadFromWebDate(), CreationDate = post.GetPostCreationDate(), PrintType = post.GetPrintType(), Title = post.GetTitle(), Url = post.GetDataHttpRequest().Url, Images = (from image in post.GetImages() select image.Image).ToArray(), DownloadLinks = post.GetDownloadLinks() }; }
public void Init(IPost View,bool isPostBack) { _view = View; if (_userSession.LoggedIn) { if (_webContext.BlogID > 0) { if (!isPostBack) _view.LoadPost(_blogRepository.GetBlogByBlogID(_webContext.BlogID)); } } else _redirector.GoToAccountLoginPage(); }
public UserAdminController(IPost postRepository, IComment commentRepository, ICategory categoryRepository, ITag tagRepository, IUser userRepository, ISettings settingsRepository) : base(settingsRepository) { _postRepository = postRepository; _commentRepository = commentRepository; _categoryRepository = categoryRepository; _tagRepository = tagRepository; _userRepository = userRepository; ExpectedMasterName = string.Empty; _itemsPerPage = settingsRepository.ManageItemsPerPage; IsAdminController = true; }
public void AddPost(IPost post) { using (var transaction = this.dbContext.GetTransaction()) { var postPoco = SetupPostBeforeSave(post, null); this.dbContext.Insert(postPoco); //Add relationship foreach (var tag in post.Tags.Where(t => t.TagId < 1)) this.dbContext.Insert(new PostTag() { PostId = post.PostId, TagId = tag.TagId }); transaction.Complete(); } }
public void Init(IPost View) { _view = View; _view.SetDisplay(_webContext.IsThread); BoardForum forum=_forumRepository.GetForumByID(_webContext.ForumID); BoardPost thread=_postRepository.GetPostByID(_webContext.PostID); if (forum != null && thread != null) _view.SetData(forum, thread); else if (forum != null) _view.SetData(forum, thread); else { forum = _forumRepository.GetForumByID(thread.ForumID); _view.SetData(forum, thread); } }
//consider changing the out parameter to a validation type object public void Save(IPost post, out bool success) { Checks.Argument.IsNotNull(post, "post"); success = false; if (null == _repo.FindByPostId(post.PostId)) { try { _repo.Add(post); success = true; } catch (Exception ex) { success = false; } } }
public async Task <IPost> RepostAsync(IPost post, string text = null, string cw = null, Visiblity visiblity = Visiblity.Default) { var t = $"{text ?? ""} RP: {(post.User as DCUser).Native.Mention}\n```{post.Text ?? ""}```\n{(post as DCPost).Native.GetJumpUrl()}"; return(new DCPost(await PostAsync(t, cw, null))); }
public async Task DeletePostAsync(IPost post) { await(post as DCPost).Native.DeleteAsync(); }
public void UpdatePost(IPost originalPost, IPost updatedPost) { using (var transaction = this.dbContext.GetTransaction()) { //Main update var postPoco = SetupPostBeforeSave(updatedPost, originalPost); this.dbContext.Update(postPoco); //Add relationship foreach (var tag in updatedPost.Tags.Except(originalPost.Tags)) this.dbContext.Insert(new PostTag() { PostId = postPoco.PostId, TagId = tag.TagId }); //Remove relationship foreach (var tag in originalPost.Tags.Except(updatedPost.Tags)) this.dbContext.Delete(new PostTag() { PostId = postPoco.PostId, TagId = tag.TagId }); transaction.Complete(); } }
public ForumController(IForum forumService, IPost postService, ApplicationDbContext context) { _forumService = forumService; _postService = postService; _context = context; }
public SearchController(IPost postService) { _postService = postService; }
public SearchController(IPost postRepositories) { _postRepositories = postRepositories; }
public HomeController(IPost postService) { _postService = postService; }
public HomeController(ILogger <HomeController> logger, IPost postService) { _logger = logger; _postService = postService; }
public ReplyController(IPost postService, IApplicationUser userService, UserManager <ApplicationUser> userManager) { _postService = postService; _userService = userService; _userManager = userManager; }
public PostsController(IPost repository) { _repository = repository; }
private Group getGroup( IPost post ) { return groupService.GetById( post.OwnerId ); }
public ForumController(IForum forum, IPost post) { _forum = forum; _post = post; }
public bool Equals(IPost other) => Id == other?.Id;
public PostController() { _posty = new PostDAL(); _tagi = new TagDAL(); _komentarze = new KomentarzDAL(); }
public PostController(IPost Post, DBContext db) { _Post = Post; _db = db; }
public async Task UnlikeAsync(IPost post) { await(post as IUserMessage)?.RemoveAllReactionsAsync(); }
public async Task <IActionResult> Edit(PostEditViewModel model) { if (!ModelState.IsValid) { if (string.IsNullOrEmpty(model.Id)) { ViewData["Title"] = sr["New Post"]; } else { ViewData["Title"] = string.Format(CultureInfo.CurrentUICulture, sr["Edit - {0}"], model.Title); } return(View(model)); } var project = await projectService.GetCurrentProjectSettings(); if (project == null) { log.LogInformation("redirecting to index because project settings not found"); return(RedirectToRoute(blogRoutes.BlogIndexRouteName)); } var canEdit = await User.CanEditPages(project.Id, authorizationService); if (!canEdit) { log.LogInformation("redirecting to index because user is not allowed to edit"); return(RedirectToRoute(blogRoutes.BlogIndexRouteName)); } var categories = new List <string>(); if (!string.IsNullOrEmpty(model.Categories)) { if (config.ForceLowerCaseCategories) { categories = model.Categories.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries).Select(x => x.Trim().ToLower()) .Where(x => !string.IsNullOrWhiteSpace(x) && x != "," ) .Distinct() .ToList(); } else { categories = model.Categories.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries).Select(x => x.Trim()) .Where(x => !string.IsNullOrWhiteSpace(x) && x != "," ) .Distinct() .ToList(); } } IPost post = null; if (!string.IsNullOrEmpty(model.Id)) { post = await blogService.GetPost(model.Id); } var isNew = false; bool slugAvailable; string slug; if (post != null) { post.Title = model.Title; post.MetaDescription = model.MetaDescription; post.Content = model.Content; post.Categories = categories; if (model.Slug != post.Slug) { // remove any bad chars model.Slug = ContentUtils.CreateSlug(model.Slug); slugAvailable = await blogService.SlugIsAvailable(project.Id, model.Slug); if (slugAvailable) { post.Slug = model.Slug; } else { //log.LogWarning($"slug {model.Slug} was requested but not changed because it is already in use"); this.AlertDanger(sr["The post slug was not changed because the requested slug is already in use."], true); } } } else { isNew = true; if (!string.IsNullOrEmpty(model.Slug)) { // remove any bad chars model.Slug = ContentUtils.CreateSlug(model.Slug); slug = model.Slug; slugAvailable = await blogService.SlugIsAvailable(project.Id, slug); if (!slugAvailable) { slug = ContentUtils.CreateSlug(model.Title); } } else { slug = ContentUtils.CreateSlug(model.Title); } slugAvailable = await blogService.SlugIsAvailable(project.Id, slug); if (!slugAvailable) { //log.LogInformation("returning 409 because slug already in use"); ModelState.AddModelError("postediterror", sr["slug is already in use."]); return(View(model)); } post = new Post() { BlogId = project.Id, Author = await authorNameResolver.GetAuthorName(User), Title = model.Title, MetaDescription = model.MetaDescription, Content = model.Content, Slug = slug , Categories = categories.ToList() }; } if (!string.IsNullOrEmpty(model.Author)) { post.Author = model.Author; } post.IsPublished = model.IsPublished; post.CorrelationKey = model.CorrelationKey; post.ImageUrl = model.ImageUrl; post.ThumbnailUrl = model.ThumbnailUrl; post.IsFeatured = model.IsFeatured; if (!string.IsNullOrEmpty(model.PubDate)) { var localTime = DateTime.Parse(model.PubDate); post.PubDate = timeZoneHelper.ConvertToUtc(localTime, project.TimeZoneId); } if (isNew) { await blogService.Create(post); } else { await blogService.Update(post); } if (project.IncludePubDateInPostUrls) { return(RedirectToRoute(blogRoutes.PostWithDateRouteName, new { year = post.PubDate.Year, month = post.PubDate.Month.ToString("00"), day = post.PubDate.Day.ToString("00"), slug = post.Slug })); } else { return(RedirectToRoute(blogRoutes.PostWithoutDateRouteName, new { slug = post.Slug })); } }
public ForumController(IForum forumService, IPost postService) { _postService = postService; _forumService = forumService; }
public PostController(IPost servicePost, IForum serviceForum, UserManager <ApplicationUser> userManager) { _servicePost = servicePost; _serviceForum = serviceForum; _userManager = userManager; }
public ReplyController(IPost postService, UserManager <IdentityUser> userManager, IReply replyService) { _postService = postService; _userManager = userManager; _replyService = replyService; }
private ContentFilterResult FilterHtmlForList(IPost post, IProjectSettings settings, bool useTeaser) { var result = new ContentFilterResult(); if (useTeaser) { TeaserResult teaserResult = null; string teaser = null; if (!string.IsNullOrWhiteSpace(post.TeaserOverride)) { if (post.ContentType == "markdown") { teaser = MapImageUrlsToCdn( ConvertMarkdownToHtml(post.TeaserOverride), settings.CdnUrl, settings.LocalMediaVirtualPath); } else { teaser = MapImageUrlsToCdn( post.TeaserOverride, settings.CdnUrl, settings.LocalMediaVirtualPath); } result.FilteredContent = teaser; result.IsFullContent = false; } else { // need to generate teaser if (post.ContentType == "markdown") { var html = MapImageUrlsToCdn( ConvertMarkdownToHtml(post.Content), settings.CdnUrl, settings.LocalMediaVirtualPath); teaserResult = _teaserService.GenerateTeaser( settings.TeaserTruncationMode, settings.TeaserTruncationLength, html, post.Id, post.Slug, settings.LanguageCode ); } else { var html = MapImageUrlsToCdn( post.Content, settings.CdnUrl, settings.LocalMediaVirtualPath); teaserResult = _teaserService.GenerateTeaser( settings.TeaserTruncationMode, settings.TeaserTruncationLength, html, post.Id, post.Slug, settings.LanguageCode ); } result.FilteredContent = teaserResult.Content; result.IsFullContent = !teaserResult.DidTruncate; } } else { // using full content if (post.ContentType == "markdown") { result.FilteredContent = MapImageUrlsToCdn( ConvertMarkdownToHtml(post.Content), settings.CdnUrl, settings.LocalMediaVirtualPath); } else { result.FilteredContent = MapImageUrlsToCdn( post.Content, settings.CdnUrl, settings.LocalMediaVirtualPath); } result.IsFullContent = true; } return(result); }
public PostController(IPost postService, IForum forumService, UserManager <ApplicationUser> userManager) { _postService = postService; _forumService = forumService; _userManager = userManager; }
private void AddNewPostChilds(IPost post) { using (var transaction = this.dbContext.GetTransaction()) { //Save series if new if (post.Series != null && post.Series.SeriesId < 1) this.AddSeries(post.Series); //Save tags if new foreach (var tag in post.Tags.Where(t => t.TagId < 1)) this.AddTag(tag); transaction.Complete(); } }
public IndexModel(IPost post) { _post = post; }
public ContentFilterResult FilterHtmlForList(IPost post, IProjectSettings settings) { bool useTeaser = (settings.TeaserMode == TeaserMode.ListsAndFeed || settings.TeaserMode == TeaserMode.ListOnly) && !post.SuppressTeaser; return(FilterHtmlForList(post, settings, useTeaser)); }
public ForumController(IForum forumService, IPost postService, IMapper mapper) { this._forumService = forumService; this._postService = postService; this._mapper = mapper; }
public async Task VoteAsync(IPost post, int choice) { // Discord has no vote feature :3 throw new NotSupportedException(); }
private Post SetupPostBeforeSave(IPost post, IPost originalPost = null) { var postPoco = (Post) post; //Save new childs in post AddNewPostChilds(postPoco); postPoco.SeriesId = postPoco.Series == null ? (int?)null : postPoco.Series.SeriesId; postPoco.CreatedByUserId = postPoco.CreatedByUser.UserId; postPoco.ModifiedByUserId = postPoco.ModifiedByUser.UserId; postPoco.TagIdCsv = postPoco.Tags.Select(t => t.TagId).ToDelimitedString(","); if (originalPost == null) { //Override non-settable properties postPoco.CreateDate = DateTimeOffset.UtcNow; postPoco.ModifyDate = postPoco.CreateDate; postPoco.RevisionCount = 0; } else { postPoco.CreateDate = originalPost.CreateDate; postPoco.ModifyDate = DateTimeOffset.UtcNow; postPoco.RevisionCount = originalPost.RevisionCount + 1; postPoco.PostId = originalPost.PostId; } return postPoco; }
public void AddPost(IPost newPost, int Id) { _context.AddPost(newPost, Id); }
private Group getGroup(IPost post) { return(groupService.GetById(post.OwnerId)); }
public SearchController(IPost postSearch) { _postSearch = postSearch; }
public async Task OnGet() { var rawPageTitle = RouteData.Values[RawTitleRoute].ToString(); Post = await _postProvider.TryGetPost(rawPageTitle); }
public Task LikeAsync(IPost post) { return(ReactAsync(post, "⭐️")); }
public apiPostController() { _adapter = new PostAdapter(); }
public bool ValidatePost(IPost post) { //TODO: add post elements verification return(true); }