Last time we set up the consultation framework , Now I'll finish the consultation in two parts :1、 User part ,2 Management part . This time, the user part , It contains two functions , Check out my consultation and conduct consultation .

Catalog :

ASP.NET MVC5 Website development practice - summary

ASP.NET MVC5 Website development practice ( One ) - The project framework

ASP.NET MVC5 Website development practice ( One ) - frame ( To continue ) Model 、 data storage 、 Business logic

ASP.NET MVC5 Website development practice ( Two ) - User part (1) User registration

ASP.NET MVC5 Website development practice ( Two ) - User part (2) The user login 、 Cancellation

ASP.NET MVC5 Website development practice ( Two ) - User part (3) Modify information 、 Change Password

ASP.NET MVC5 Website development practice ( Two ) Member Area - Article management structure

ASP.NET MVC5 Website development practice ( Two ) Member Area - Add the article

ASP.NET MVC5 Website development practice ( Two ) Member Area - List of all articles

ASP.NET MVC5 Website development practice ( Two ) Member Area - Modify and delete articles

ASP.NET MVC5 Website development practice ( Two ) Member Area - The structure of consulting management

 

One 、 menu

Open the last ConsultationController controller , add to Menu action, Back to the distribution view

/// <summary>
/// menu
/// </summary>
/// <returns></returns>
public ActionResult Menu()
{
return PartialView();
}

Right click Add view

<div class="easyui-accordion">
<div title=" Consulting Management ">
<ul id="navmenu" class="nav nav-pills nav-stacked">
<li> <a href="javascript:void()" data-options="'icons':'icon-folder-page','title': ' Consulting Management ', 'href': '@Url.Action("ManageList", "Consultation")'"><span class="glyphicon glyphicon-list"> Consulting Management </span></a></li>
<li> <a href="javascript:void()" data-options="'icons':'icon-folder-user','title': ' My consultation ', 'href': '@Url.Action("MyList", "Consultation")'"><span class="glyphicon glyphicon-list-alt"> My consultation </span></a></li>
</ul>
</div>
</div>

And on again Home/menu View

Add a distribution view reference

Run it , Take a look at it in the message machine /Member/Home. The effect is like .

 

Two 、 My consultation

My consulting section uses datagrid Show your own consultation list ,datagrid Use the detail view function , Click open to see the details .

The effect is like this , When folding :

After you click on it

This is a datagrid Extension of , First go to the official website to download jquery-easyui-datagridview.zip, And then put the inside jquery.easyui.datagrid.detailview.js Put the files in the project /Scripts Under the folder .

 

open ConsultationController controller , add to MyJsonList Method , Back to my consulting json list

public JsonResult MyJsonList(int pageIndex = 1, int pageSize = 20)
{
int _total;
var _list = commonModelService.FindPageList(out _total, pageIndex, pageSize, "Consultation", string.Empty, 0, User.Identity.Name, null, null, 0).ToList().Select(
cm => new Ninesky.Web.Models.CommonModelViewModel()
{
CategoryID = cm.CategoryID,
CategoryName = cm.Category.Name,
DefaultPicUrl = cm.DefaultPicUrl,
Hits = cm.Hits,
Inputer = cm.Inputer,
Model = cm.Model,
ModelID = cm.ModelID,
ReleaseDate = cm.ReleaseDate,
Status = cm.Status,
Title = cm.Title
});
return Json(new { total = _total, rows = _list.ToList() });
}

Add again MyList Method , Go directly back to the view

/// <summary>
/// My consultation
/// </summary>
/// <returns></returns>
public ActionResult MyList()
{
return View();
}

Right click for MyList Add view .

@{
ViewBag.Title = " My consultation ";
} <div id="toolbar">
<div>
<a href="#" id="btn_add" class="easyui-linkbutton" data-options="iconCls:'icon-add',plain:true"> Consultation </a>
<a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-reload',plain:true" onclick="$('#Consultation_List').datagrid('reload');"> Refresh </a>
</div>
</div> <table id="Consultation_List"></table> <script src="~/Scripts/Common.js"></script>
<script src="~/Scripts/jquery.easyui.datagrid.detailview.js"></script>
<script type="text/javascript">
$("#Consultation_List").datagrid({
loadMsg: ' Loading ……',
fitColumns:true,
pagination: true,
singleSelect: true,
url: '@Url.Action("MyJsonList", "Consultation")',
columns: [[
{ field: 'ModelID', title: 'ID' },
{ field: 'Title', title: ' title '},
{ field: 'Inputer', title: ' Consultants ', align: 'right' },
{ field: 'ReleaseDate', title: ' Consultation date ', align: 'right', formatter: function (value, row, index) { return jsonDateFormat(value); } },
{ field: 'StatusString', title: ' state ', width: 100, align: 'right' }
]],
toolbar: '#toolbar',
idField: 'ModelID',
view: detailview,
detailFormatter: function (rowIndex, rowData) { return '<div class="detail" style="padding:5px 0"></div>'; },
onExpandRow: function (index, row) {
var detail = $(this).datagrid('getRowDetail', index).find('div.detail');
detail.panel({
height: 160,
border: false,
cache: false,
href: '@Url.Content("~/Member/Consultation/Index")/' + row.ModelID,
onLoad: function () {
$('#Consultation_List').datagrid('fixDetailRowHeight', index);
}
});
$('#Consultation_List').datagrid('fixDetailRowHeight', index);
}
}); // Add a button
$("#btn_add").click(function () {
window.parent.addTab(" Consultation ", "@Url.Action("Add", "Consultation")", "icon-page");
});
</script>

This code is relatively long , Explain it. :

<div id="toolbar">
<div>
<a href="#" id="btn_add" class="easyui-linkbutton" data-options="iconCls:'icon-add',plain:true"> Consultation </a>
<a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-reload',plain:true" onclick="$('#Consultation_List').datagrid('reload');"> Refresh </a>
</div>
</div> <table id="Consultation_List"></table>

This is a datagrid Themes and toolbars for .

 

quote ~/Scripts/Common.js Because it contains date formatting methods ,json The transmitted date must be formatted before it can be displayed normally .

quote ~/Scripts/jquery.easyui.datagrid.detailview.js yes datagrid Like the view must be .

This is initialization datagrid. among 1 It's using Common.js Medium jsonDateFormater Method to format the date .2、 It's the detail view section

view: detailview,

        detailFormatter: function (rowIndex, rowData) { return '<div class="detail" style="padding:5px 0"></div>'; }

These two sentences use the detail view , And add a <DIV>

onExpandRow: function (index, row) {

            var detail = $(this).datagrid('getRowDetail', index).find('div.detail');

            detail.panel({

                height: 160,

                border: false,

                cache: false,

                href: '@Url.Content("~/Member/Consultation/Index")/' + row.ModelID,

                onLoad: function () {

                    $('#Consultation_List').datagrid('fixDetailRowHeight', index);

                }

            });

This is the detail view when the row is expanded div link to ~/Member/Consultation/Index/id View

 

Let's add Consultation/Index This distribution view

Add... To the controller Index action And return to the distribution view

public ActionResult Index(int id)
{
return PartialView(commonModelService.Find(id).Consultation);
}

Right click to add strong type (Consultation) Distribution of the view

@model Ninesky.Models.Consultation
<table style="width:100%">
<tr>
<th>@Html.DisplayNameFor(model => model.Name)</th>
<td>@Html.DisplayFor(model => model.Name)</td>
<th>@Html.DisplayNameFor(model => model.IsPublic)</th>
<td>@Html.DisplayFor(model => model.IsPublic)</td>
</tr>
<tr>
<th>@Html.DisplayNameFor(model => model.QQ)</th>
<td>@Html.DisplayFor(model => model.QQ)</td>
<th>@Html.DisplayNameFor(model => model.Email)</th>
<td>@Html.DisplayFor(model => model.Email)</td>
</tr>
<tr>
<th>@Html.DisplayNameFor(model => model.Content)</th>
<td colspan="3">@Html.DisplayFor(model => model.Content)</td>
</tr>
<tr>
<td colspan="4">
@if (Model.ReplyTime != null)
{
<span> Administrator in :@Model.ReplyTime The reply is as follows </span>
<p style="margin-top:8px">
@Model.ReplyContent
</p>
}
</td>
</tr>
</table>

to be finished

 

3、 ... and 、 Consultation

stay Consultation Controller add Add  action

/// <summary>
/// add to
/// </summary>
/// <returns></returns>
public ActionResult Add()
{
InterfaceUserService _userService = new UserService();
var _user = _userService.Find(User.Identity.Name);
CommonModel _cModel = new CommonModel();
_cModel.Consultation = new Consultation() { Email = _user.Email, IsPublic = true, Name = _user.DisplayName };
_user = null;
_userService = null;
return View(_cModel);
}

stay action Query user information first , Construct a CommonModel And pass it to the view

Right click to add view

@model Ninesky.Models.CommonModel
@{
ViewBag.Title = " Consultation ";
} @using (Html.BeginForm())
{
@Html.AntiForgeryToken()
<h4> Consultation </h4>
<hr />
<div class="form-horizontal">
@Html.ValidationSummary(true) <div class="form-group">
<label class = "control-label col-sm-2" > type </label>
<div class="col-sm-10">
<input id="CategoryID" name="CategoryID" data-options="url:'@Url.Action("JsonComboBox", "Category", new { model = "Consultation" })',valueField:'CategoryID',textField:'Name'" class="easyui-combobox" style="height: 34px; width: 280px;" />
@Html.ValidationMessageFor(model => model.CategoryID)
</div>
</div> <div class="form-group">
@Html.LabelFor(model => model.Title, new { @class = "control-label col-sm-2" })
<div class="col-sm-10">
@Html.TextBoxFor(model => model.Title, new { @class = "form-control" })
@Html.ValidationMessageFor(model => model.Title)
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.Consultation.Name, new { @class = "control-label col-sm-2" })
<div class="col-sm-10">
@Html.TextBoxFor(model => model.Consultation.Name, new { @class = "form-control", @readonly = "readonly" })
@Html.ValidationMessageFor(model => model.Consultation.Name)
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.Consultation.QQ, new { @class = "control-label col-sm-2" })
<div class="col-sm-10">
@Html.TextBoxFor(model => model.Consultation.QQ, new { @class = "form-control" })
@Html.ValidationMessageFor(model => model.Consultation.QQ)
</div>
</div> <div class="form-group">
@Html.LabelFor(model => model.Consultation.IsPublic, new { @class = "control-label col-sm-2" })
<div class="col-sm-10">
@Html.RadioButtonFor(model => model.Consultation.IsPublic,true) Open
@Html.RadioButtonFor(model => model.Consultation.IsPublic, false) Just check for yourself
@Html.ValidationMessageFor(model => model.Consultation.IsPublic)
</div>
</div> <div class="form-group">
@Html.LabelFor(model => model.Consultation.Email, new { @class = "control-label col-sm-2" })
<div class="col-sm-10">
@Html.TextBoxFor(model => model.Consultation.Email, new { @class = "form-control" })
@Html.ValidationMessageFor(model => model.Consultation.Email)
</div>
</div> <div class="form-group">
@Html.LabelFor(model => model.Consultation.Content, new { @class = "control-label col-sm-2" })
<div class="col-sm-10">
@Html.TextAreaFor(model => model.Consultation.Content, new { @class = "form-control" })
@Html.ValidationMessageFor(model => model.Consultation.Content)
</div>
</div> <div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<input type="submit" value=" Submit " class="btn btn-default" />
</div>
</div>
</div>
}

Very similar to adding articles , Here's how to accept

Add... To the controller again Add action

[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult Add(CommonModel commonModel)
{
if(ModelState.IsValid)
{
InterfaceUserService _userService = new UserService();
var _user = _userService.Find(User.Identity.Name);
if (commonModel.Article != null) commonModel.Article = null;
if (commonModel.Attachment != null) commonModel.Attachment = null;
if (commonModel.DefaultPicUrl != null) commonModel.DefaultPicUrl = null;
commonModel.Hits = 0;
commonModel.Inputer = User.Identity.Name;
commonModel.Model = "Consultation";
commonModel.ReleaseDate = System.DateTime.Now;
commonModel.Status = 20;
commonModel.Consultation.Name = _user.DisplayName;
_user = null;
_userService = null;
commonModel = commonModelService.Add(commonModel);
if (commonModel.ModelID > 0) return View("AddSucess", commonModel);
}
return View(commonModel);
}

stay action If the verification is passed , Look for users first , And will Article、Attachment Set to null, This is to prevent users from secretly carrying private goods . Then initialize commonModel Of Hits、Inputer And save .

effect :

 

Four 、 summary

My consultation realizes two functions: checking my consultation and consulting , Check that datagrid Detailed view of .

ASP.NET MVC5 Website development practice ( Two ) Member Area – My consultation list and more related articles to add consultation

  1. ASP.NET MVC5 Website development practice ( Two ) Member Area - Add the article

    Last time I did the architecture , This time, I'll add some articles . Adding articles involves the upload management of attachments and the use of rich text editor , Add articles as early as possible . The main points of : The rich text editor uses KindEditor. It's very powerful , Developed by Chinese people ,LGPL Open source , My good friend ...

  2. ASP.NET MVC5 Website development practice ( Two ) Member Area &ndash; Manage lists 、 Reply and delete

    I wanted to finish this last time , I didn't expect that some of the work later fell behind , It's time to make up for the holiday . Catalog : ASP.NET MVC5 Website development practice - summary ASP.NET MVC5 Website development practice ( One ) - The project framework ASP ...

  3. ASP.NET MVC5 Website development practice ( Two ) Member Area - The structure of consulting management

    consulting . Leaving a message. . Complaints and other functions are the basic functions of a website , It can strengthen the communication between administrators and users , After finishing the article section last time , This time we're going to do Member The consulting function of the region ( Leaving a message. . Complaints are consultation ). Consulting is very similar to writing , And less content . It's simpler . ...

  4. ASP.NET MVC5 Website development practice ( Two ) Member Area - Modify and delete articles

    Last time I did a list of articles , Then we can modify and delete this part of the article , This time, the content is relatively simple , Due to the added articles , Modifying an article is very similar to , Just one more TryUpdateModel Partially update model data .   Catalog : ASP.N ...

  5. ASP.NET MVC5 Website development practice ( Two ) Member Area - List of all articles

    The list of articles is divided into two parts , The administrator can display a list of all articles , General users only display their own list of articles . The list of articles is displayed by easyui-datagrid. The backstage needs the corresponding action return json Type data   Catalog ASP.N ...

  6. ASP.NET MVC5 Website development practice ( Two ) Member Area - Article management structure

    Last time I put member The user part of , Now let's start the article management section . The article section displays a list of real articles according to the content , Publish articles , Revise article , Delete articles and other functions . The ultimate goal is to use permissions to control whether the user can carry out the corresponding operation , Administrator permissions will be displayed ...

  7. ASP.NET MVC5 Website development practice ( Two ) Member Area - User part (3) Modify information 、 Change Password

    In the last blog, the user's logout and login are realized , There's something missing in the code , The last login time and login time should be updated when users log in IP, Make up this time . I'm going to change the information and password today ,TryUpdateModel It's something new . Catalog : AS ...

  8. ASP.NET MVC5 Website development practice ( Two ) Member Area - User part (2) The user login 、 Cancellation

    Last time, we realized user registration , This time to achieve user login , be used IAuthenticationManager Of SignOut.SignIn Methods and declaration based identities . Finally, modify the user registration code to login directly after successful registration . Catalog : ASP ...

  9. ASP.NET MVC5 Website development practice ( Two ) Member Area - User part (1) User registration

    Last time I built the basic framework , This time we're going to do the whole thing Web part , Finally you can see the interface. Let's get excited .web The project section starts with user functions , Basically there is registration , Sign in . Cancellation . lookup . see . Deletion, etc. involves Member Areas and Manage Area . Catalog : ...

Random recommendation

  1. Use 、 Support 、 help Moon.Orm

    1. About Moon.Orm Explanation 1) Anyone and organization can use the framework for free ;( The sponsor provides long-term technical advice )   Wechat wechat : 2)5.0 All of them have been open source before ; 3)5.0 The standard version is currently open source for participants ( Take a look at the simple ones below ), ...

  2. MyEclipse Several ways to install plug-ins turn

    http://www.cnblogs.com/pharen/archive/2012/02/08/2343342.html MyEclipse Several ways to install plug-ins This article explains MyEclipse(MyEcl ...

  3. A Game of Thrones(1) - Bran

    The morning had dawned clear and cold, with a crispness( fragile : Pure and fresh ) that hinted( Hint : schematic ) at the end of summ ...

  4. NSURLConnection Basic use

    One .NSURLConnection The common class of (1)NSURL: Request address (2)NSURLRequest: Encapsulate a request , Save all data sent to the server , Including a NSURL object , Request method . Request header . Request body .... ...

  5. event Event One

    event (Event) for example : Recent visual China ' Black hole event '. Most of us ( subscriber ) It's through XX platform ( Publisher ) I got the news , And then the subscriber A Sell shares in visual China ( How to trigger ), subscriber B Buy the stock of Vision China . using ...

  6. JS The first part --ECMAScript5.0 Standard grammar (JS Basic grammar )

    One , Debug statement Two ,JS How to introduce 3、 ... and , Use of variables Four , Basic data types 4.1, Basic data type conversion 4.2, Common methods of string 5、 ... and , Complex data type 5.1,Array( Array ) And common methods 6、 ... and , Process control ( Logic and ...

  7. php Passing data between pages

    b.php <?php function getClientIP() { if (getenv("HTTP_CLIENT_IP")) $ip = getenv("H ...

  8. 《 Full stack performance Jmeter》-1 Performance direction career development

  9. Mac Batch conversion mp3 by caf

    Create a sh file , Enter the following code and run . Traverse the... In the folder mp3 And then use afconvert Command to convert . #!/bin/bash for i in *.mp3; do afconvert $i " ...

  10. WEBBASE piece : Third articles , CSS knowledge 1

    Third articles , CSS knowledge 1 One ,CSS Introduce CSS: Cascading Style Sheets --- Style sheets HTML: Build a web page structure : CSS: Beautify the webpage on the basis of webpage structure : Two ,CSS Use ...