Teams creation and prizes creation are implemented
This commit is contained in:
@ -25,6 +25,7 @@ namespace MVCUI.Controllers
|
||||
}
|
||||
|
||||
// POST: People/Create
|
||||
[ValidateAntiForgeryToken()]
|
||||
[HttpPost]
|
||||
public ActionResult Create(PersonModel p)
|
||||
{
|
||||
|
||||
51
MVCUI/Controllers/PrizesController.cs
Normal file
51
MVCUI/Controllers/PrizesController.cs
Normal file
@ -0,0 +1,51 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using System.Web.Mvc;
|
||||
using TrackerLibrary;
|
||||
using TrackerLibrary.Models;
|
||||
|
||||
namespace MVCUI.Controllers
|
||||
{
|
||||
public class PrizesController : Controller
|
||||
{
|
||||
// GET: Prizes
|
||||
public ActionResult Index()
|
||||
{
|
||||
List<PrizeModel> allPrizes = GlobalConfig.Connection.GetPrizes_All();
|
||||
return View(allPrizes);
|
||||
}
|
||||
|
||||
|
||||
// GET: Prizes/Create
|
||||
public ActionResult Create()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
|
||||
// POST: Prizes/Create
|
||||
[ValidateAntiForgeryToken()]
|
||||
[HttpPost]
|
||||
public ActionResult Create(PrizeModel p)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
GlobalConfig.Connection.CreatePrize(p);
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
else
|
||||
{
|
||||
return View();
|
||||
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
return View();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
59
MVCUI/Controllers/TeamsController.cs
Normal file
59
MVCUI/Controllers/TeamsController.cs
Normal file
@ -0,0 +1,59 @@
|
||||
using MVCUI.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using System.Web.Mvc;
|
||||
using TrackerLibrary;
|
||||
using TrackerLibrary.Models;
|
||||
|
||||
namespace MVCUI.Controllers
|
||||
{
|
||||
public class TeamsController : Controller
|
||||
{
|
||||
// GET: Teams
|
||||
public ActionResult Index()
|
||||
{
|
||||
List<TeamModel> allTeams = GlobalConfig.Connection.GetTeam_All();
|
||||
return View(allTeams);
|
||||
}
|
||||
|
||||
|
||||
// GET: Teams/Create
|
||||
public ActionResult Create()
|
||||
{
|
||||
List<PersonModel> people = GlobalConfig.Connection.GetPerson_All();
|
||||
TeamMVCModel input = new TeamMVCModel();
|
||||
|
||||
input.TeamMembers = people.Select(x => new SelectListItem { Text = x.FullName, Value = x.Id.ToString() }).ToList();
|
||||
return View(input);
|
||||
}
|
||||
|
||||
// POST: Teams/Create
|
||||
[ValidateAntiForgeryToken()]
|
||||
[HttpPost]
|
||||
public ActionResult Create(TeamMVCModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
// TODO: Add insert logic here
|
||||
if(ModelState.IsValid && model.SelectedTeamMembers.Count > 0)
|
||||
{
|
||||
TeamModel t = new TeamModel();
|
||||
t.TeamName = model.TeamName;
|
||||
t.TeamMembers = model.SelectedTeamMembers.Select(x => new PersonModel { Id = int.Parse(x) }).ToList();
|
||||
GlobalConfig.Connection.CreateTeam(t);
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
else
|
||||
{
|
||||
return RedirectToAction("Create");
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
return View();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -124,9 +124,12 @@
|
||||
<Compile Include="App_Start\RouteConfig.cs" />
|
||||
<Compile Include="Controllers\HomeController.cs" />
|
||||
<Compile Include="Controllers\PeopleController.cs" />
|
||||
<Compile Include="Controllers\PrizesController.cs" />
|
||||
<Compile Include="Controllers\TeamsController.cs" />
|
||||
<Compile Include="Global.asax.cs">
|
||||
<DependentUpon>Global.asax</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Models\TeamMVCModel.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
@ -266,10 +269,13 @@
|
||||
<Content Include="Scripts\popper-utils.js.map" />
|
||||
<Content Include="Views\People\Index.cshtml" />
|
||||
<Content Include="Views\People\Create.cshtml" />
|
||||
<Content Include="Views\Teams\Index.cshtml" />
|
||||
<Content Include="Views\Teams\Create.cshtml" />
|
||||
<Content Include="Views\Prizes\Index.cshtml" />
|
||||
<Content Include="Views\Prizes\Create.cshtml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Folder Include="App_Data\" />
|
||||
<Folder Include="Models\" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="packages.config" />
|
||||
|
||||
19
MVCUI/Models/TeamMVCModel.cs
Normal file
19
MVCUI/Models/TeamMVCModel.cs
Normal file
@ -0,0 +1,19 @@
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Web.Mvc;
|
||||
|
||||
namespace MVCUI.Models
|
||||
{
|
||||
public class TeamMVCModel
|
||||
{
|
||||
[Display(Name = "Team Name")]
|
||||
[StringLength(100, MinimumLength = 2)]
|
||||
[Required]
|
||||
public string TeamName { get; set; }
|
||||
[Display(Name = "Team Member List")]
|
||||
public List<SelectListItem> TeamMembers { get; set; } = new List<SelectListItem>();
|
||||
|
||||
public List<string> SelectedTeamMembers { get; set; } = new List<string>();
|
||||
|
||||
}
|
||||
}
|
||||
63
MVCUI/Views/Prizes/Create.cshtml
Normal file
63
MVCUI/Views/Prizes/Create.cshtml
Normal file
@ -0,0 +1,63 @@
|
||||
@model TrackerLibrary.Models.PrizeModel
|
||||
|
||||
@{
|
||||
ViewBag.Title = "Create";
|
||||
}
|
||||
|
||||
<h2>Create A New Prize</h2>
|
||||
|
||||
|
||||
@using (Html.BeginForm())
|
||||
{
|
||||
@Html.AntiForgeryToken()
|
||||
|
||||
<div class="form-horizontal">
|
||||
<hr />
|
||||
@Html.ValidationSummary(true, "", new { @class = "text-danger" })
|
||||
<div class="form-group">
|
||||
@Html.LabelFor(model => model.PlaceNumber, htmlAttributes: new { @class = "control-label col-md-2" })
|
||||
<div class="col-md-10">
|
||||
@Html.EditorFor(model => model.PlaceNumber, new { htmlAttributes = new { @class = "form-control" } })
|
||||
@Html.ValidationMessageFor(model => model.PlaceNumber, "", new { @class = "text-danger" })
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
@Html.LabelFor(model => model.PlaceName, htmlAttributes: new { @class = "control-label col-md-2" })
|
||||
<div class="col-md-10">
|
||||
@Html.EditorFor(model => model.PlaceName, new { htmlAttributes = new { @class = "form-control" } })
|
||||
@Html.ValidationMessageFor(model => model.PlaceName, "", new { @class = "text-danger" })
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
@Html.LabelFor(model => model.PrizeAmount, htmlAttributes: new { @class = "control-label col-md-2" })
|
||||
<div class="col-md-10">
|
||||
@Html.EditorFor(model => model.PrizeAmount, new { htmlAttributes = new { @class = "form-control", @value = 0 } })
|
||||
@Html.ValidationMessageFor(model => model.PrizeAmount, "", new { @class = "text-danger" })
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
@Html.LabelFor(model => model.PrizePercentage, htmlAttributes: new { @class = "control-label col-md-2" })
|
||||
<div class="col-md-10">
|
||||
@Html.EditorFor(model => model.PrizePercentage, new { htmlAttributes = new { @class = "form-control", @value = 0 } })
|
||||
@Html.ValidationMessageFor(model => model.PrizePercentage, "", new { @class = "text-danger" })
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<div class="col-md-offset-2 col-md-10">
|
||||
<input type="submit" value="Create" class="btn btn-default" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
|
||||
<div>
|
||||
@Html.ActionLink("Back to List", "Index")
|
||||
</div>
|
||||
|
||||
@section Scripts {
|
||||
@Scripts.Render("~/bundles/jqueryval")
|
||||
}
|
||||
46
MVCUI/Views/Prizes/Index.cshtml
Normal file
46
MVCUI/Views/Prizes/Index.cshtml
Normal file
@ -0,0 +1,46 @@
|
||||
@model IEnumerable<TrackerLibrary.Models.PrizeModel>
|
||||
|
||||
@{
|
||||
ViewBag.Title = "Index";
|
||||
}
|
||||
|
||||
<h2>View All Prizes</h2>
|
||||
|
||||
<p>
|
||||
@Html.ActionLink("Create New", "Create")
|
||||
</p>
|
||||
<table class="table">
|
||||
<tr>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.PlaceNumber)
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.PlaceName)
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.PrizeAmount)
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.PrizePercentage)
|
||||
</th>
|
||||
</tr>
|
||||
|
||||
@foreach (var item in Model) {
|
||||
<tr>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.PlaceNumber)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.PlaceName)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.PrizeAmount)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.PrizePercentage)
|
||||
</td>
|
||||
|
||||
</tr>
|
||||
}
|
||||
|
||||
</table>
|
||||
@ -27,6 +27,12 @@
|
||||
<li class="nav-item">
|
||||
@Html.ActionLink("People", "Index", "People", new { area = "" }, new { @class = "nav-link text-light" })
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
@Html.ActionLink("Teams", "Index", "Teams", new { area = "" }, new { @class = "nav-link text-light" })
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
@Html.ActionLink("Prizes", "Index", "Prizes", new { area = "" }, new { @class = "nav-link text-light" })
|
||||
</li>
|
||||
@*<li class="nav-item">
|
||||
@Html.ActionLink("About", "About", "Home", new { area = "" }, new { @class = "nav-link text-light" })
|
||||
</li>
|
||||
|
||||
52
MVCUI/Views/Teams/Create.cshtml
Normal file
52
MVCUI/Views/Teams/Create.cshtml
Normal file
@ -0,0 +1,52 @@
|
||||
@model MVCUI.Models.TeamMVCModel
|
||||
|
||||
@{
|
||||
ViewBag.Title = "Create";
|
||||
}
|
||||
|
||||
<h2>Create New Team</h2>
|
||||
|
||||
|
||||
@using (Html.BeginForm())
|
||||
{
|
||||
@Html.AntiForgeryToken()
|
||||
|
||||
<div class="form-horizontal">
|
||||
<h4>TeamModel</h4>
|
||||
<hr />
|
||||
@Html.ValidationSummary(true, "", new { @class = "text-danger" })
|
||||
<div class="form-group">
|
||||
@Html.LabelFor(model => model.TeamName, htmlAttributes: new { @class = "control-label col-md-2" })
|
||||
<div class="col-md-10">
|
||||
@Html.EditorFor(model => model.TeamName, new { htmlAttributes = new { @class = "form-control" } })
|
||||
@Html.ValidationMessageFor(model => model.TeamName, "", new { @class = "text-danger" })
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
@Html.LabelFor(model => model.TeamMembers,htmlAttributes:new { @class = "control-label col-md-2"})
|
||||
<div class="col-md-10">
|
||||
@foreach (var item in Model.TeamMembers)
|
||||
{
|
||||
<div class="checkbox">
|
||||
<label>
|
||||
<input type="checkbox" name="SelectedTeamMembers" value="@item.Value" /> @item.Text
|
||||
</label>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<div class="col-md-offset-2 col-md-10">
|
||||
<input type="submit" value="Create" class="btn btn-default" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
|
||||
<div>
|
||||
@Html.ActionLink("Back to List", "Index")
|
||||
</div>
|
||||
|
||||
@section Scripts {
|
||||
@Scripts.Render("~/bundles/jqueryval")
|
||||
}
|
||||
43
MVCUI/Views/Teams/Index.cshtml
Normal file
43
MVCUI/Views/Teams/Index.cshtml
Normal file
@ -0,0 +1,43 @@
|
||||
@model IEnumerable<TrackerLibrary.Models.TeamModel>
|
||||
|
||||
@{
|
||||
ViewBag.Title = "Index";
|
||||
}
|
||||
|
||||
<h2>All Teams</h2>
|
||||
|
||||
<p>
|
||||
@Html.ActionLink("Create New", "Create")
|
||||
</p>
|
||||
<table class="table">
|
||||
<tr>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.TeamName)
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.TeamMembers)
|
||||
</th>
|
||||
</tr>
|
||||
|
||||
@foreach (var item in Model) {
|
||||
<tr>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.TeamName)
|
||||
</td>
|
||||
<td>
|
||||
@for (int i = 0; i < item.TeamMembers.Count; i++)
|
||||
{
|
||||
if (i == 0)
|
||||
{
|
||||
@(item.TeamMembers[i].FullName);
|
||||
}
|
||||
else
|
||||
{
|
||||
@(", " + item.TeamMembers[i].FullName);
|
||||
}
|
||||
}
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
|
||||
</table>
|
||||
@ -15,6 +15,7 @@ namespace TrackerLibrary.DataAccess
|
||||
void CompleteTournament(TournamentModel model);
|
||||
List<TeamModel> GetTeam_All();
|
||||
List<PersonModel> GetPerson_All();
|
||||
List<PrizeModel> GetPrizes_All();
|
||||
List<TournamentModel> GetTournament_All();
|
||||
}
|
||||
}
|
||||
|
||||
@ -225,6 +225,16 @@ namespace TrackerLibrary.DataAccess
|
||||
return output;
|
||||
}
|
||||
|
||||
public List<PrizeModel> GetPrizes_All()
|
||||
{
|
||||
List<PrizeModel> output;
|
||||
using (IDbConnection connection = new System.Data.SqlClient.SqlConnection(GlobalConfig.CnnString(db)))
|
||||
{
|
||||
output = connection.Query<PrizeModel>("dbo.spPrizes_GetAll").ToList();
|
||||
}
|
||||
return output;
|
||||
}
|
||||
|
||||
public List<TournamentModel> GetTournament_All()
|
||||
{
|
||||
List<TournamentModel> output;
|
||||
|
||||
@ -122,6 +122,13 @@ namespace TrackerLibrary.DataAccess
|
||||
.ConvertToTournamentModels();
|
||||
}
|
||||
|
||||
public List<PrizeModel> GetPrizes_All()
|
||||
{
|
||||
List<PrizeModel> output;
|
||||
output = GlobalConfig.PrizesFile.FullFilePath().LoadFile().ConvertToPrizeModels();
|
||||
return output;
|
||||
}
|
||||
|
||||
public void UpdateMatchup(MatchupModel model)
|
||||
{
|
||||
model.UpdateMatchupToFile();
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Text;
|
||||
|
||||
namespace TrackerLibrary.Models
|
||||
@ -7,13 +8,26 @@ namespace TrackerLibrary.Models
|
||||
public class PrizeModel
|
||||
|
||||
{
|
||||
/// <summary>
|
||||
/// The unique identifier for the prize
|
||||
/// </summary>
|
||||
/// <summary>
|
||||
/// The unique identifier for the prize
|
||||
/// </summary>
|
||||
public int Id { get; set; }
|
||||
|
||||
[Display(Name = "Place Number")]
|
||||
[Range(1, 100)]
|
||||
[Required]
|
||||
public int PlaceNumber { get; set; }
|
||||
|
||||
[Display(Name = "Place Name")]
|
||||
[StringLength(100, MinimumLength = 3)]
|
||||
[Required]
|
||||
public string PlaceName { get; set; }
|
||||
|
||||
[Display(Name = "Prize Amount")]
|
||||
[DataType(DataType.Currency)]
|
||||
public decimal PrizeAmount { get; set; }
|
||||
|
||||
[Display(Name = "Prize Percentage")]
|
||||
public double PrizePercentage { get; set; }
|
||||
|
||||
public PrizeModel()
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Text;
|
||||
|
||||
namespace TrackerLibrary.Models
|
||||
@ -7,7 +8,11 @@ namespace TrackerLibrary.Models
|
||||
public class TeamModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
[Display(Name = "Team Member List")]
|
||||
public List<PersonModel> TeamMembers { get; set; } = new List<PersonModel>();
|
||||
[Display(Name = "Team Name")]
|
||||
//[StringLength(100, MinimumLength = 2)]
|
||||
//[Required]
|
||||
public string TeamName { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user