Cleanup and fix

This commit is contained in:
Benjamin
2025-01-09 09:26:53 +01:00
parent 3beb8ef0d4
commit 670ed21386
10 changed files with 95 additions and 34 deletions

View File

@@ -42,7 +42,7 @@ namespace pointMaster.Controllers
public class HeaderNavViewModel
{
public List<NavUrl> links { get; set; } = null!;
public List<NavUrl> links { get; set; }
}
public class NavUrl
{
@@ -52,7 +52,7 @@ namespace pointMaster.Controllers
this.Title = title;
this.Url = url;
}
public string Url { get; set; } = null!;
public string Title { get; set; } = null!;
public string Url { get; set; }
public string Title { get; set; }
}
}

View File

@@ -53,6 +53,13 @@ namespace pointMaster.Controllers
vm.Points = vm.Points.OrderByDescending(x => x.point).ToList();
vm.Turnout = vm.Turnout.OrderByDescending(x => x.point).ToList();
var postId = Request.Cookies["Post"];
if (postId != null)
{
int.TryParse(postId, out var id);
var post = await context.Poster.FindAsync(id);
vm.Post = post;
}
return View(vm);
}
@@ -77,13 +84,14 @@ namespace pointMaster.Controllers
public class HomePageViewModel
{
public List<PatruljePlacering> Samlet { get; set; } = null!;
public List<PatruljePlacering> Turnout { get; set; } = null!;
public List<PatruljePlacering> Points { get; set; } = null!;
public List<PatruljePlacering> Samlet { get; set; }
public List<PatruljePlacering> Turnout { get; set; }
public List<PatruljePlacering> Points { get; set; }
public Post Post { get; set; }
}
public class PatruljePlacering
{
public Patrulje Patrulje { get; set; } = null!;
public Patrulje Patrulje { get; set; }
public int point { get; set; }
}
}

View File

@@ -129,9 +129,9 @@ namespace pointMaster.Controllers
public class IndexViewModel
{
public List<Patrulje> patruljeModels { get; set; } = null!;
public Dictionary<int, int> patruljePoints { get; set; } = null!;
public Dictionary<int, int> patruljeTurnout { get; set; } = null!;
public List<Patrulje> patruljeModels { get; set; }
public Dictionary<int, int> patruljePoints { get; set; }
public Dictionary<int, int> patruljeTurnout { get; set; }
}
}
}

View File

@@ -190,28 +190,28 @@ namespace pointMaster.Controllers
public class SelectPostViewModel
{
public List<Post> Poster { get; set; } = null!;
public List<Post> Poster { get; set; }
}
public class GivPointViewModel
{
public Post Runde { get; set; } = null!;
public Patrulje Patrulje { get; set; } = null!;
public Post Runde { get; set; }
public Patrulje Patrulje { get; set; }
public Point points { get; set; } = new Point();
}
public class SkiftPatruljeViewModel
{
public List<Patrulje> Patruljer { get; set; } = null!;
public Post? post { get; set; } = null!;
public List<Patrulje> Patruljer { get; set; }
public Post? post { get; set; }
}
public class PointViewModel
{
public List<Point> points { get; set; } = null!;
public List<Point> points { get; set; }
public bool AllowedToDelete { get; set; } = false;
}
public class PatruljeInfoModel
{
public Patrulje patrulje { get; set; } = null!;
public Patrulje patrulje { get; set; }
public int totalPoints { get; set; }
public int totalTurnout { get; set; }
}

View File

@@ -64,7 +64,7 @@ namespace pointMaster.Controllers
public class RundeViewModel
{
public List<Post> Rounds { get; set; } = null!;
public List<Post> Rounds { get; set; }
}
}
}

View File

@@ -32,10 +32,36 @@ namespace pointMaster.Controllers
return View(vm);
}
public async Task<IActionResult> Poster()
{
var vm = new PrintPosterModel();
vm.poster = await context.Poster.ToListAsync();
vm.QRcode = new Dictionary<int, string>();
foreach (var item in vm.poster)
{
QRCodeGenerator QrGenerator = new QRCodeGenerator();
QRCodeData QrCodeInfo = QrGenerator.CreateQrCode(Request.Host.Host + "/point/selectpost/" + item.Id, QRCodeGenerator.ECCLevel.Q);
vm.QRcode.Add(item.Id, "data:image/png;base64," + Convert.ToBase64String(new PngByteQRCode(QrCodeInfo).GetGraphic(20)));
}
return View(vm);
}
}
public class PrintPatruljerModel
{
public List<Patrulje> patruljer { get; set; } = null!;
public List<Patrulje> patruljer { get; set; }
public Dictionary<int, string> QRcode { get; set; } = new Dictionary<int, string>();
}
public class PrintPosterModel
{
public List<Post> poster { get; set; }
public Dictionary<int, string> QRcode { get; set; }
}
}

View File

@@ -51,9 +51,9 @@ namespace pointMaster.Controllers
public class PointChartModel
{
[JsonProperty("name")]
public string Name { get; set; } = null!;
public string Name { get; set; }
[JsonProperty("data")]
public List<PointChartDataModel> Data { get; set; } = null!;
public List<PointChartDataModel> Data { get; set; }
public static async Task<List<PointChartModel>> Calculate(DataContext dataContext)
{
@@ -101,14 +101,14 @@ namespace pointMaster.Controllers
}
public class PointChartDataModel
{
public string x { get; set; } = null!;
public string x { get; set; }
public int y { get; set; }
}
public class StatModel
{
public string Title { get; set; } = null!;
public string Value { get; set; } = null!;
public string Title { get; set; }
public string Value { get; set; }
public static async Task<List<StatModel>> Calculate(DataContext dataContext)
{
@@ -156,9 +156,9 @@ namespace pointMaster.Controllers
public class PointRatioModel
{
[JsonProperty("names")]
public List<string> Names { get; set; } = null!;
public List<string> Names { get; set; }
[JsonProperty("data")]
public List<int> Data { get; set; } = null!;
public List<int> Data { get; set; }
public static async Task<PointRatioModel> Calculate(DataContext dataContext)
{

View File

@@ -5,6 +5,10 @@
<div>
<h1>Velkommen til PointMaster</h1>
@if(Model.Post != null)
{
<p>Du giver point som @Model.Post.Name</p>
}
</div>
<div class="container">
<div class="row">
@@ -21,11 +25,11 @@
<tbody>
@for (var i = 0; i < Model.Points.Count; i++)
{
<tr>
<td>@(i + 1)</td>
<td>@Model.Points[i].Patrulje.Name</td>
<td>@Model.Points[i].point</td>
</tr>
<tr>
<td>@(i + 1)</td>
<td>@Model.Points[i].Patrulje.Name</td>
<td>@Model.Points[i].point</td>
</tr>
}
</tbody>
</table>

View File

@@ -9,10 +9,13 @@
<div class="print-card">
<div class="patrulje-info">
<h1>@patrulje.Name</h1>
<p>Medlemmer:</p>
@foreach (var medlem in patrulje.PatruljeMedlems)
@if(patrulje.PatruljeMedlems.Any())
{
<p>@medlem.Name</p>
<p>Medlemmer:</p>
@foreach (var medlem in patrulje.PatruljeMedlems)
{
<p>@medlem.Name</p>
}
}
</div>
<div class="flex-grow"></div>

View File

@@ -0,0 +1,20 @@
@model pointMaster.Controllers.PrintPosterModel;
@{
Layout = "_Point";
ViewData["Title"] = "Patruljer";
}
@foreach (var post in Model.poster)
{
<div class="print-card">
<div class="patrulje-info">
<h1>@post.Name</h1>
</div>
<div class="flex-grow"></div>
<img src="@Model.QRcode[post.Id]" width="300" height="300" />
</div>
}
<script>
print()
</script>