First, add two action in the Resumecontroller, as in the following code:
code is as follows |
copy code |
////Get:/RESUME/EDIT/5 public actionresult Edit (int id) {Resume.Models.Resume re Sume = context.
Resumes.find (ID); Viewbag.nationid = new SelectList (context. Nations, "Nationid", "Name", resume.
Nationid);
Return View (Resume); ///POST:/RESUME/EDIT/5 [httppost] public actionresult Edit (Resume.Models.Resume Resume) {if (Mod Elstate.isvalid) {context. Entry (Resume).
state = entitystate.modified; Context.
SaveChanges ();
Return redirecttoaction ("Index");
Return View (Resume); } |
Second, create edit.cshtml, just like creating create.cshtml, select empty.
Third, add the following code to the index.cshtml:
The code is as follows |
Copy Code |
$ ("a[rel= ' Editresume ']"). Click (function () {
$ (this). Colorbox ({
width:1000,
heigth:500,
Overlayclose:false, close
: "",
oncomplete:function () {
$ ("#btnCancel"). Click (function () {
$. Colorbox.close ();
});
},
onclosed:function () {
$.colorbox.remove ()
;}})
; |
Four, the operation effect:
More information about your resume
The code is as follows |
Copy Code |
////Get
:/RESUME/DETAILS/5
public actionresult Details (int id)
{
Resume.Models.Resume Resume = context. Resumes.find (ID);
Return View (resume);
} |
Second, create details.cshtml, ditto.
Third, the operation effect:
The deletion of the resume
The code is as follows |
Copy Code |
Public ActionResult Delete (int id)
{
Resume.Models.Resume Resume = context. Resumes.find (ID);
Context. Resumes.remove (resume);
Context. SaveChanges ();
Return redirecttoaction ("Index");
} |
Creating the action is OK.
Second, the operation effect:
The above features are very simple, this function is not difficult,
First, start by adding an action.
code is as follows |
copy code |
public Viewresult addexper (int id) {Viewbag.expersbyid = context.
Experiences.where (e => e.resumeid = ID);
return View (); [HttpPost] public actionresult addexper (Resume.Models.Experience exper) {if (modelstate.isvalid) {exp Er.
Resumeid = Convert.ToInt32 (routedata.values["id")); Context.
Experiences.add (Exper); Context.
SaveChanges ();
Return redirecttoaction ("Index");
Return View (Exper); |
Second, create addexper.cshtml with the following code:
The code is as follows |
Copy Code |
<body>@using (Html.BeginForm ()) {<table> <Tr> <Th>Start Time </th> <Th>End Time </th> <Th>Work Unit </th> <Th>Proof of human </th> </Tr>@foreach (var item in Viewbag.expersbyid) {<TR> <Td>@item. Starttime.tostring ("Yyyy-mm-dd") </td> <Td>@item. Endtime.tostring ("Yyyy-mm-dd") </td> <Td>@item. Workunit </td> <Td>@item. Voucher </TD> </Tr>} <tr> <Td>@Html. Editorfor (e => e.starttime) @Html. Validationmessagefor (E => e.starttime) & Lt;/td> <Td>@Html. Editorfor (e => e.endtime) @Html. Validationmessagefor (e => e.endtime) </ Td> <Td>@Html. Editorfor (e => e.workunit) @Html. Validationmessagefor (e => e.workunit) ;/td> <Td>@Html. Editorfor (e => e.voucher) @Html. Validationmessagefor (e => e.voucher) </ Td> </Tr> </Table> <P style= "Text-align: Center; " > <Input type= "Submit" value= "Add"/><input type= "button" id= "Btncancel" value= "Cancel"/></P>} </body> |
Third, add the following code to the index.cshtml:
The code is as follows |
Copy Code |
$ ("a[rel= ' Addexper ']"). Click (function () {$ (this). Colorbox ({width:950, overlayclose:false, close: ", Oncomplete:fun Ction () { $ ("#StartTime, #EndTime"). DatePicker ({ Changemonth:true, Changeyear:true, Daynamesmin: [' Day ', ' one ', ' two ', ' three ', ' four ', ' five ', ' six '], Monthnamesshort: [' January ', ' February ', ' March ', ' April ', ' May ', ' June ', ' July ', ' August ', ' September ', ' October ', ' November ', ' December '], DateFormat: ' Yy-mm-dd ', Yearrange: ' c-50:c+50 ', showmonthafteryear: true }; $ ("#btnCancel"). Click (function () {$.colorbox.close ();}); }, Onclosed:function () {$.colorbox.remove ();} }); }); |
Four, look at the effect of the operation: