Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
using Intepro.DataAccess;
using System.Data;
using System.Data.SqlClient;
declaration (prop)
List.Add(b);
}
dr.Close();
dl.Close();
Return List;
}
Controller
using Intepro.BusinessLogic;
using System.Data.SqlClient;
[HttpPost]
public ActionResult AddNew(FormCollection form)
{
BLL bll = new BLL();
bll.ID = long.Parse(form["ID"]);
bll.Lastname = form("Lastname");
bll.Add();
return RedirectToAction("Index");
}
<div>
<h2>Web-App</h2>
<hr />
Don't have a record yet? Register
<a href="~/Participant/Register">
here
</a>
<br />
List of records
<a href="~/Participant/List">click here</a>
</div>
List
<div>
<table>
<thead>
<tr>
<th>Participant I.D.</th>
<th>Surname</th>
<th>Given Name</th>
</tr>
</thead>
<tbody>
@{
@*for (int i = 0; i < Model.Count(); i++)
{
<tr>
<td>@Model[i].ID</td>
<td>@Model[i].Lastname</td>
<td>@Model[i].Firstname</td>
</tr>
}*@
foreach (Intepro.BusinessLogic.ParticipantBLL p in Model)
{
<tr>
<td>@p.ID</td>
<td>@p.Lastname</td>
<td>@p.Firstname</td>
</tr>
}
}
</tbody>
</table>
</div>
Register
<div>
<h2>Participant Registration</h2>
<hr />
<form action="~/Participant/AddNew" method="post">
I.D. No.
<input type="number" name="ID" value="" />
<br />
Last name
<input type="text" name="Lastname" value="" />
<br />
First name
<input type="text" name="Firstname" value="" />
<br />
<button type="submit">
Register
</button>
</form>
<a href="~/Participant/DefaultAction">Go Back</a>
</div>
public class RouteConfig
{
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Participant", action = "Index", id =
UrlParameter.Optional }
);
}