The volleyball scoring of the MVC series Blog (vii) Concrete realization

Source: Internet
Author: User
Tags actionlink

The previous few have already talked about the implementation of the program, now specifically to achieve

Open Visual Studio2015, click New Project, name volleyball

Click OK

Then add a coachcontroller and Refreecontroller,

As follows:

Add two model classes

Click Models, right-click Add Class, Score.cs and player

The code is as follows:

Players class:

 public class Players
    {
        public int ID { Get Set }
        [DisplayName ("player number")]
         public string Name {get; set;}
        [DisplayName ("player name")]
         public string Teamname {get; set;}
        [DisplayName ("Team name")]
         public string Status {get; set;}
        [DisplayName ("player positioning")]



         public class Pdbcontext:dbcontext
        {
             public dbset<players> Player {get; set;}
       }
   }

Score class:

public class Score
{

public string ScorePlayer1 {get; set;}
[DisplayName ("Chinese team scoring player")]
public int TotalScore1 {get; set;}
[DisplayName ("Chinese team total score")]
public string ScoreType1 {get; set;}
[DisplayName ("Score type")]
public string ScorePlayer2 {get; set;}
[DisplayName ("Serbia scoring player")]
public int TotalScore2 {get; set;}
[DisplayName ("Serbia total score")]
public string ScoreType2 {get; set;}
[DisplayName ("Score type")]


public class Gdbcontext:dbcontext
{
Public dbset<score> Students {get; set;}
}

}

Coachcontroller The Index View interface code:

@model ienumerable<volleyball.models.players>

@{
Viewbag.title = "Coach scoring";
}
<style>

div {width:1000px;
height:800px;
margin:50px 20px;
BORDER:1PX Red;
Background-color: #b6ff00;
padding-left:100px;
padding-top:80px;
}

. Three {
Text-align:right;
}
</style>
<title>
Volleyball scoring
</title>
<body>
<div>

<p>
@Html. ActionLink ("Please start editing player info", "Create")
</p>
<table>
<tr>
<th>
@Html. displaynamefor (model = model.id)
</th>
<th>
@Html. displaynamefor (model = model. Name)
</th>
<th>
@Html. displaynamefor (model = model. Teamname)
</th>
<th>
@Html. displaynamefor (model = model. Status)
</th>

<th></th>
</tr>

@foreach (var item in Model) {
<tr>
<td>
@Html. displayfor (ModelItem = Item. Teamname)
</td>
<td>
@Html. displayfor (ModelItem = Item. Name)
</td>
<td>
@Html. displayfor (ModelItem = Item. Status)
</td>

<td>
@Html. ActionLink ("Editing Score", "edit", new {id=item.id}) |
@Html. ActionLink ("Score Details", "details", new {id=item.id}) |
@Html. ActionLink ("Delete record", "delete", new {id=item.id})
</td>
</tr>
}

</table>
<p class= "three" > @Html. ActionLink ("Back to Main interface", "Index", "Home") </p>

</div>
</body>

Coachcontroller and additions and changes to the View interface code:

@model VolleyBall.Models.Players

@{
viewbag.title = "add Record";
}

<style>

. one {width:700px;
height:500px;
margin:50px Auto;
border:1px solid red;
background-color: #F1F1F1;
padding-left:80px;
padding-top:50px;
    }
</style>


<title></title>

<body>
<div class= "one" >
@using (Html.BeginForm ()) {
@Html. ValidationSummary (True)

<fieldset>
<legend> audience scoring </legend>

<div class= "Editor-label" >
@Html. labelfor (model = model.id)
</div>
<div class= "Editor-field" >
@Html. editorfor (model = model.id)
@Html. validationmessagefor (model = model.id)
</div>

<div class= "Editor-label" >
@Html. labelfor (model = model. Name)
</div>
<div class= "Editor-field" >
@Html. editorfor (model = model. Name)
@Html. validationmessagefor (model = model. Name)
</div>

<div class= "Editor-label" >
@Html. labelfor (model = model. Teamname)
</div>
<div class= "Editor-field" >
@Html. editorfor (model = model. Teamname)
@Html. validationmessagefor (model = model. Teamname)
</div>

<div class= "Editor-label" >
@Html. labelfor (model = model. Status)
</div>
<div class= "Editor-field" >
@Html. editorfor (model = model. Status)
@Html. validationmessagefor (model = model. Status)
</div>

      

<p>
<input type= "Submit" value= "OK record"/>
</p>
</fieldset>
}

<div>
@Html. ActionLink ("Back to List", "Index")
</div>

@section Scripts {
@Scripts. Render ("~/bundles/jqueryval")
}
</div>
</body>

.....

Code is similar, omitting the

At this point, the program is basically complete.

The volleyball scoring of the MVC series Blog (vii) Concrete realization

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.