public IHttpHandler GetHttpHandler(RequestContext requestContext) { string title = HttpUtility.HtmlDecode((string)requestContext.RouteData.Values["title"]); HttpPageHelper.CurrentItem = null; HttpPageHelper.CurrentBlog = null; var p = new IdeaSeedCMS.Core.Domain.Page(); p = new PageServices().GetByNameAccessLevel(VirtualPath, 0, Convert.ToInt16(ConfigurationManager.AppSettings["APPLICATIONID"])); HttpPageHelper.CurrentPage = p; var b = new BlogServices().GetByTitle(title.Replace("-", " ")); var item = new Item(); item.Description = p.Name; item.Name = p.Name; item.SEOTitle = b.Title; item.SEODescription = b.SEODescription; item.SEOKeywords = b.SEOKeywords; item.ItemReference = item; p.SEODescription = b.SEODescription; p.SEOKeywords = b.SEOKeywords; p.SEOTitle = b.Title; HttpPageHelper.CurrentItem = item; HttpPageHelper.CurrentBlog = b; IdeaSeedCMSBasePage page; page = (IdeaSeedCMSBasePage)BuildManager.CreateInstanceFromVirtualPath(p.URLRoute, typeof(System.Web.UI.Page)); HttpPageHelper.IsValidRequest = true; return(page); }
public MainPageViewModel(INavigationService navigationService) : base(navigationService) { Title = "Blogs"; _blogService = new BlogServices(); Blogs = new ObservableCollection <Blog>(_blogService.GetBlogs()); }
void _view_LoadView(object sender, EventArgs e) { var sb = new StringBuilder(); IList <Blog> list = new List <Blog>(); if ((int)ApplicationContext.CurrentBlogPostType > 0) { list = new BlogServices().GetByPostType((int)ApplicationContext.CurrentBlogPostType); } else { list = new BlogServices().GetAll(); } int i = 0; foreach (var item in list) { i++; sb.Append("<div class='inner-content'><h4>"); sb.Append(item.Title); sb.Append("</h4><p>Posted by: <span style='color: #346699;'>"); sb.Append(item.BlogUser.FirstName); sb.Append(" "); sb.Append(item.BlogUser.LastName); sb.Append("</span> on <span style='color: #346699;'>"); sb.Append(item.StartDate.ToShortDateString()); sb.Append("</span></p><p>"); sb.Append(item.BlogContent); sb.Append("</p><div class='horizontal-line'></div><br /></div>"); if (i == 1) { var links = new PageLinkServices().GetByPageID(SecurityContextManager.Current.CurrentPage.ID); //var sblinks = new StringBuilder(); if (links != null && links.Count > 0) { sb.Append("<div class='one-fourth last'><p><strong class='colored'>Links</strong></p><ul class='simple-nav'>"); foreach (var link in links) { sb.Append("<li><a href='"); sb.Append(link.URL); sb.Append("' target='_blank'>"); sb.Append(link.Title); sb.Append("</a></li>"); } sb.Append("</ul></div>"); } else { sb.Append("<div class='one-fourth last'><p><strong class='colored'>Links</strong></p><ul class='simple-nav'><li>No Links Found</li></ul></div>"); } } } i = 0; _view.BlogHTML = sb.ToString(); //_view.Links = sblinks.ToString(); }
private void LoadBlogs(bool bindData) { var list = new BlogServices().GetAllByAccount(); rgList.DataSource = list; if (bindData) { rgList.DataBind(); } }
public async Task <ActionResult> CommentLike(CommentLikeModel model) { if (!ModelState.IsValid) { return(RedirectToAction("Post", new { id = model.PostId })); } BlogServices.CommentLike(model.Index, model.PostId); return(RedirectToAction("Post", new { id = model.PostId })); }
public async Task <ActionResult> NewComment(NewCommentModel model) { if (!ModelState.IsValid) { return(RedirectToAction("Post", new { id = model.PostId })); } BlogServices.AddComment(User.Identity.Name, model.Content, model.PostId); return(RedirectToAction("Post", new { id = model.PostId })); }
public async Task <ActionResult> NewPost(NewPostModel model) { if (!ModelState.IsValid) { return(View(model)); } var postId = BlogServices.AddPost(User.Identity.Name, model.Title, model.Content, model.Tags); return(RedirectToAction("Post", new { id = postId })); }
protected void ItemCommand(object o, GridCommandEventArgs e) { if (e.CommandName == RadGrid.InitInsertCommandName) { e.Canceled = true; var i = new HRR.Core.Domain.Blog(); i.Title = ""; i.AccountID = 0; i.BlogCategoryID = 0; i.BlogContent = ""; i.EndDate = DateTime.Now; i.EnteredBy = 0; i.IsActive = false; i.StartDate = DateTime.Now; i.ID = 0; e.Item.OwnerTableView.InsertItem(i); } if (e.CommandName == RadGrid.PerformInsertCommandName) { var t = new HRR.Core.Domain.Blog(); t.Title = (e.Item.FindControl("tbTitle") as IdeaSeed.Web.UI.TextBox).Text; t.BlogCategoryID = Convert.ToInt16((e.Item.FindControl("ddlCategory") as HRR.Web.Controls.BlogCategoryDDL).SelectedValue); t.BlogContent = (e.Item.FindControl("reContent") as Telerik.Web.UI.RadEditor).Content; t.EndDate = (DateTime)(e.Item.FindControl("tbEndDate") as Telerik.Web.UI.RadDatePicker).SelectedDate; t.EnteredBy = SecurityContextManager.Current.CurrentUser.ID; t.IsActive = (e.Item.FindControl("cbIsActive") as IdeaSeed.Web.UI.CheckBox).Checked; t.StartDate = (DateTime)(e.Item.FindControl("tbStartDate") as Telerik.Web.UI.RadDatePicker).SelectedDate; t.AccountID = ((Person)SecurityContextManager.Current.CurrentUser).AccountID; new BlogServices().Save(t); } if (e.CommandName == RadGrid.UpdateCommandName) { if (e.Item is GridEditableItem) { var t = new BlogServices().GetByID((int)e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["ID"]); t.Title = (e.Item.FindControl("tbTitle") as IdeaSeed.Web.UI.TextBox).Text; t.BlogCategoryID = Convert.ToInt16((e.Item.FindControl("ddlCategory") as HRR.Web.Controls.BlogCategoryDDL).SelectedValue); t.BlogContent = (e.Item.FindControl("reContent") as Telerik.Web.UI.RadEditor).Content; t.EndDate = (DateTime)(e.Item.FindControl("tbEndDate") as Telerik.Web.UI.RadDatePicker).SelectedDate; t.IsActive = (e.Item.FindControl("cbIsActive") as IdeaSeed.Web.UI.CheckBox).Checked; t.StartDate = (DateTime)(e.Item.FindControl("tbStartDate") as Telerik.Web.UI.RadDatePicker).SelectedDate; new BlogServices().Save(t); } } if (e.CommandName == RadGrid.DeleteCommandName) { var t = new BlogServices().GetByID((int)e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["ID"]); new BlogServices().Delete(t); } IdeaSeed.Core.Data.NHibernate.NHibernateSessionManager.Instance.CloseSession(); LoadBlogs(true); }
public ActionResult Index(int?id) { string mine = string.IsNullOrEmpty(Request.QueryString["mine"]) ? "false" : Request.QueryString["mine"]; string categoryCode = string.IsNullOrEmpty(Request.QueryString["CategoryCode"]) ? SystemConst.CategoryCode.Blog : Request.QueryString["CategoryCode"]; string order = string.IsNullOrEmpty(Request.QueryString["order"]) ? "default" : Request.QueryString["order"]; string keyword = Request.QueryString["keyword"]; int memberID = 0; if (mine == "true") { memberID = WebCookieHelper.GetUserId(0); if (memberID == 0) { return(Redirect("/member/login?returnurl=" + Request.Url)); } } string categoryName = EnterRepository.GetRepositoryEnter().CategoryRepository.LoadEntities(m => m.Code == categoryCode).FirstOrDefault().Name; Pagination pagination = new Pagination(); int page = 1; if (id != null) { page = int.Parse(id.ToString()); } int totalCount = 0; pagination.Size = 30; pagination.ActionUrl = "blog/index"; pagination.CurrentPageIndex = page; DateTime startTime = DateTime.Now; var myblogs = BlogServices.GetBlogs(keyword, memberID, categoryCode, order, page, pagination.Size, out totalCount); string time = (DateTime.Now - startTime).TotalSeconds.ToString(); pagination.TotalCount = totalCount; pagination.Order = order; pagination.CategoryCode = categoryCode; pagination.CategoryName = categoryName; pagination.Keyword = keyword; ViewBag.mine = mine; ViewBag.time = time; ViewBag.keyword = keyword; ViewBag.myblogs = myblogs; ViewBag.Pagination = pagination; return(View()); }
public HttpResponseMessage GetPost() { var recentPosts = BlogServices.GetPosts().Result; var tags = BlogServices.GetTags().Result; var model = new IndexModel { RecentPosts = recentPosts.ToList(), Tags = tags.ToList() }; return(Request.CreateResponse(HttpStatusCode.OK, new { Data = model, Status = HttpStatusCode.OK })); }
public async Task <ActionResult> Index() { var recentPosts = await BlogServices.GetPosts(); var tags = await BlogServices.GetTags(); var model = new IndexModel { RecentPosts = recentPosts, Tags = tags }; return(View(model)); }
// // GET: /Home/ public ActionResult Index() { int totalCount = 0; string order = "latest"; ViewBag.NewsGonggao = ArticleServices.GetArticles(SystemConst.CategoryCode.NewsGongGao, order, 1, 10, out totalCount); ViewBag.NewsExamData = ArticleServices.GetArticles(SystemConst.CategoryCode.NewsExamData, order, 1, 10, out totalCount); ViewBag.NewsReview = ArticleServices.GetArticles(SystemConst.CategoryCode.NewsReview, order, 1, 10, out totalCount); ViewBag.NewsScore = ArticleServices.GetArticles(SystemConst.CategoryCode.NewsScore, order, 1, 10, out totalCount); ViewBag.Book = BookServices.GetBooks(SystemConst.CategoryCode.Book, order, 1, 10, out totalCount); ViewBag.Train = TrainServices.GetTrains(SystemConst.CategoryCode.Train, order, 1, 8, out totalCount); ViewBag.Hotel = HotelServices.GetHotels(SystemConst.CategoryCode.Hotel, order, 1, 20, out totalCount); ViewBag.Blog = BlogServices.GetBlogs(null, 0, SystemConst.CategoryCode.Blog, order, 1, 10, out totalCount); return(View()); }
private void LoadBlogs() { var list = new BlogServices().GetForFeed(); if (list.Count < 1) { divBlog.Visible = true; } else { divBlog.Visible = false; } dlBlog.DataSource = list; dlBlog.DataBind(); }
protected void ItemCommand(object o, GridCommandEventArgs e) { switch (e.CommandName) { case RadGrid.InitInsertCommandName: Response.Redirect("/News/New"); break; case RadGrid.DeleteCommandName: var s = new BlogServices().GetByID(Convert.ToInt32(((LinkButton)e.Item.FindControl("lbDelete")).Attributes["linkid"])); new BlogServices().Delete(s); LoadNews(true); break; } }
/// <summary> /// 浏览文章 /// </summary> /// <param name="id"></param> /// <returns></returns> public ActionResult View(int id) { var blog = BlogServices.GetBlog(id); blog.ViewCount++; EnterRepository.GetRepositoryEnter().BlogRepository.EditEntity(blog, new string[] { "ViewCount" }); EnterRepository.GetRepositoryEnter().SaveChange(); var next = EnterRepository.GetRepositoryEnter().BlogRepository.LoadEntities(m => m.ModifyTime > blog.ModifyTime).FirstOrDefault(); var pre = EnterRepository.GetRepositoryEnter().BlogRepository.LoadEntities(m => m.ModifyTime < blog.ModifyTime).OrderByDescending(m => m.ModifyTime).FirstOrDefault(); ViewBag.Next = next; ViewBag.Pre = pre; DateTime date = DateTime.Now.AddMonths(-1); var others = EnterRepository.GetRepositoryEnter().BlogRepository.LoadEntities(m => m.ModifyTime > date).OrderByDescending(m => m.ViewCount).Take(4).ToList(); ViewBag.others = others; return(View(blog)); }
public HttpResponseMessage GetPostById(string id) { var post = BlogServices.GetPostsById(id).Result; if (post == null) { return(Request.CreateResponse(HttpStatusCode.NoContent, new { Data = "No post", Status = HttpStatusCode.NoContent })); } var model = new PostModel { Post = post, NewComment = new NewCommentModel { PostId = id } }; return(Request.CreateResponse(HttpStatusCode.OK, new { Data = model, Status = HttpStatusCode.OK })); }
public async Task <ActionResult> Post(string id) { var post = await BlogServices.GetPostsById(id); if (post == null) { return(RedirectToAction("Index")); } var model = new PostModel { Post = post, NewComment = new NewCommentModel { PostId = id } }; return(View(model)); }
/// <summary> /// 浏览文章 /// </summary> /// <param name="id"></param> /// <returns></returns> public ActionResult View(int id) { var blog = BlogServices.GetBlog(id); Random ran = new Random(); int RandKey = ran.Next(1, 500); if (blog == null) { blog = EnterRepository.GetRepositoryEnter().BlogRepository.LoadEntities(m => m.Zhuanzai == 1).OrderBy(m => m.CreateTime).Skip(RandKey).FirstOrDefault(); } blog.ViewCount++; EnterRepository.GetRepositoryEnter().BlogRepository.EditEntity(blog, new string[] { "ViewCount" }); EnterRepository.GetRepositoryEnter().SaveChange(); var next = EnterRepository.GetRepositoryEnter().BlogRepository.LoadEntities(m => m.ModifyTime > blog.ModifyTime).FirstOrDefault(); var pre = EnterRepository.GetRepositoryEnter().BlogRepository.LoadEntities(m => m.ModifyTime < blog.ModifyTime).OrderByDescending(m => m.ModifyTime).FirstOrDefault(); ViewBag.Next = next; ViewBag.Pre = pre; var others = EnterRepository.GetRepositoryEnter().BlogRepository.LoadEntities().OrderByDescending(m => m.ModifyTime).Skip(RandKey).Take(8).ToList(); ViewBag.others = others; return View(blog); }
public IHttpHandler GetHttpHandler(RequestContext requestContext) { string id = HttpUtility.HtmlDecode((string)requestContext.RouteData.Values["id"]); string isnew = HttpUtility.HtmlDecode((string)requestContext.RouteData.Values["new"]); HttpPageHelper.CurrentItem = null; if (!string.IsNullOrEmpty(id)) { var p = new BlogServices().GetByID(Convert.ToInt32(id)); var item = new Item(); item.Description = p.Title; item.Name = p.Title; item.ItemReference = p; item.SEOTitle = p.Title; item.SEODescription = p.SEODescription; item.SEOKeywords = p.SEOKeywords; HttpPageHelper.CurrentItem = item; } else { var item = new Item(); item.Description = "New Blog"; item.Name = "New Blog"; item.SEOTitle = "New Blog"; item.ItemReference = new Blog(); HttpPageHelper.CurrentItem = item; } var cp = new PageServices().GetByNameAccessLevel("News", 60, Convert.ToInt16(ConfigurationManager.AppSettings["APPLICATIONID"])); HttpPageHelper.CurrentPage = cp; AdminBasePage page; page = (AdminBasePage)BuildManager.CreateInstanceFromVirtualPath("~/News.aspx", typeof(System.Web.UI.Page)); HttpPageHelper.IsValidRequest = true; return(page); }
public HttpResponseMessage NewPost(PostData objData) { var postId = BlogServices.AddPost(objData.Name, objData.Title, objData.Content, objData.Tags); return(Request.CreateResponse(HttpStatusCode.OK, new { Data = postId })); }
static void Main() { Console.WriteLine("Creating Database first"); //Creating database first var dropCreateDatabaseAlways = new DropCreateDatabaseAlways <BloggerDbContext>(); Database.SetInitializer(dropCreateDatabaseAlways); var context = new BloggerDbContext(); dropCreateDatabaseAlways.InitializeDatabase(context); //Creating an user Console.WriteLine("Creating an user"); IUserServices userRepository = new UserServices(); var userId = userRepository.AddUser(new VoUser { Name = "TestUser", Occupation = "Software Developer" }); //Creating a blog and its post Console.WriteLine("Creating a blog post"); IBlogServices blogRepository = new BlogServices(); var blog = new VoBlog { CreatedDateTime = DateTime.Now, Overview = "This is a sample overview.", Post = new VoPost { Meta = "Sample, Test", Content = "This is a sample overview", ShortDescription = "This is a sample short description", Title = "Test Title" }, UserId = userId }; blogRepository.AddBlog(blog); //Retrieving the user in an async mode. This is where thread switching happens Console.WriteLine("Retrieving the created user"); var user = userRepository.GetUserAsync(userId).ConfigureAwait(false); Console.WriteLine("Name of the created user is " + user.GetAwaiter().GetResult().Name); //Get the user's most recent blog Console.WriteLine("Retrieving the user most recent blog"); var recentBlog = blogRepository.GetUserRecentBlog(userId); Console.WriteLine("Overview " + recentBlog.Overview); Console.WriteLine("BlogPost Meta " + recentBlog.Post.Meta); Console.WriteLine("BlogPost Short Description " + recentBlog.Post.ShortDescription); Console.WriteLine("BlogPost Content " + recentBlog.Post.Content); //Create a blog and try to save it. If the creation fails , update the creation failure count in the user profile. var blog2 = new VoBlog { CreatedDateTime = DateTime.Now, Post = new VoPost { Meta = "Sample, Test", Content = "This is a sample overview", ShortDescription = "This is a sample short description", Title = "Test Title" }, UserId = userId }; try { blogRepository.AddBlog(blog2); } catch (Exception ex) { Console.WriteLine(ex.InnerException.Message); } Console.ReadKey(); }
public async Task <ActionResult> Posts(string tag = null) { var posts = await BlogServices.GetPostsByTag(tag); return(View(posts)); }
public BlogController(AppDbContext context) { this.context = context; this.services = new BlogServices(context); }
public HttpResponseMessage GetPostBytag(string id = null) { var post = BlogServices.GetPostsByTag(id).Result; return(Request.CreateResponse(HttpStatusCode.OK, new { Data = post, Status = HttpStatusCode.OK })); }
public HttpResponseMessage CommentLike(CommentLikeModel objData) { BlogServices.CommentLike(objData.Index, objData.PostId); return(Request.CreateResponse(HttpStatusCode.OK, new { Data = objData.PostId })); }
public HttpResponseMessage NewComment(NewCommentAPIModel objData) { BlogServices.AddComment(objData.Name, objData.Content, objData.PostId); return(Request.CreateResponse(HttpStatusCode.OK, new { Data = objData.PostId })); }