I. Blog system Progress Review
On the blog introduced to the system has been implemented to the release and the front layout display, the next is to implement some, details page, message, Wheel Map management, the right blog statistics information.
second, the blog System details page implementation
2.1 First look at the details of the page to show the effect
2.2 Implementation controller in the foreground controller to create a blog controller, mainly display blog classification and details page
Action Detail Page Implementation:
1///<summary> 2///details Page 3///</summary> 4///<param name= "id" ></p Aram> 5///<returns></returns> 6 public actionresult Detail (int id) 7 {8 Gets the controller name 9 Viewbag.controllername = routedata.values["Controller"]. ToString ().
ToLower ();
The var model = blogarticleservive.getblogdetails (ID); One viewbag.gblist = Guestbookservices.queryorderby (c => c.blogid = = ID, c => c.createdate, false).
Topagedlist (1, 5); 12 13//Publish time sort Viewbag.blogtimelist = Blogarticleservive.queryorderby (c => true, C =>
C.bcreatetime, false); 15//Comment Sort viewbag.blogtrafficlist = Blogarticleservive.queryorderby (c => true, C => c.bt
Raffic, false); 17//Message sort a String sql = @ "Select A.*,b.btitle from (select Blogid,count (1) as counts from Gues
Tbook GROUP by BlogId) as aThe INNER join blogarticle as B on B.bid=a.blogid order by counts Desc ";
viewbag.blogguestbooklist = guestbookservices.runproc<topgbviewmodels> (sql);
return View (model); 26}
View Code
Because the content of the display is more than the actual information stored in the database, so all the information can be displayed in the Blogviewmodels, in the blog business Logic layer to implement a separate one containing the next page, and the summary assignment method.
Since this section needs to retain only a portion of the text from the details, there is a need to deal with the requested details, as the details are added through rich-text editing containing a lot of HTML code information, so in the common Assembly, create a tool class, the tools class to store, Auxiliary related methods.
Replacehtmltag Method:
1 #region Remove HTML tags in rich text
2 ///<summary>
3 ///Remove HTML tags in rich text
4 ///</summary >
5 ///<param name= "html" ></param>
6 ///<param name= "Length" ></param >
7 ///<returns></returns>
8 public static string Replacehtmltag (string html, int length = 0)
9 {
Ten string strText = System.Text.RegularExpressions.Regex.Replace (HTML, "<[ ^>]+> "," ");
One StrText = System.Text.RegularExpressions.Regex.Replace (StrText, "&[^;] +;", ""); if (length > 0 && strtext.length > Length) return strtext.substring (0, length);
return StrText; #endregion
View Code
Then in the acquisition of more information, the place to deal with is to use the ternary operator to determine, intercept the previous text part
2.3 Details Page View Code
1 @model Wchl.WMBlog.Model.VeiwModels.BlogViewModels 2 3 @{4 viewbag.title = "blog Details page"; 5} 6 <link href= "~/content/lib/zui/doc.css" rel= "stylesheet"/> 7 <section> 8 <article> 9 <div spellcheck= "false" class= "Example" > <br> <ul class= "breadcrumb" > <li><i class= "Icon-location-arrow icon-muted" ></i></li> 13 <li><a href= "/home/index" > Home </a></li> <li><a href= "/blog/index" ; blog </a></li> <li class= "Active" >Data</li> </ul> 17 View Code
The details page of this blog is also implemented through the layout page.
third, the blog System details page message implementation
3.1 Message Display page effect
First create a class to create a table in the database:
Guestbook class
1 Namespace Wchl.WMBlog.Model.Models 2 {3 public class Guestbook 4 {5 6///<summar
Y> Message Table 7///8///</summary> 9 public int ID {get; set;} ///<summary> Blog ID//////</summary> public int?
blogId {get; set;} ///<summary> creation Time//////</summary> public DateTime Createdat
e {get; set;}
public string Username {get; set;} ///<summary> Mobile//////</summary> public string Phone { Get Set ///<summary>qq//////</summary> public string qq {get; Set ///<summary> message://////</summary> public string bod
y {get; set;}