Skip to content
This repository has been archived by the owner on Jun 23, 2022. It is now read-only.

Commit

Permalink
Merge branch 'unstable'
Browse files Browse the repository at this point in the history
  • Loading branch information
DigiWorm0 committed Jun 24, 2020
2 parents 0ac5315 + 47a47d6 commit 915140a
Show file tree
Hide file tree
Showing 26 changed files with 417 additions and 371 deletions.
9 changes: 5 additions & 4 deletions BlitzScouter/BlitzScouter.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.App" Version="2.2.8" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="3.1.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="3.1.1" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="3.1.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="3.1.5" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="3.1.5" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="3.1.5" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="3.1.3" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
<PackageReference Include="YamlDotNet" Version="8.1.0" />
<PackageReference Include="YamlDotNet" Version="8.1.2" />
</ItemGroup>

</Project>
39 changes: 17 additions & 22 deletions BlitzScouter/Controllers/DashController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public IActionResult Index()
BSConfig.initialize();
ViewBag.upcomingRounds = service.getUpcomingRounds();
List<BSTeam> tms = service.getTopTeams();
/*
List<PlotData> list = new List<PlotData>();
foreach (BSTeam tm in tms)
{
Expand All @@ -38,6 +39,7 @@ public IActionResult Index()
});
}
ViewBag.graphData = list;
*/
return View(tms);
}

Expand All @@ -63,32 +65,25 @@ public IActionResult Team(String teamnum, int code)
BSTeam tm = service.getTeam(ex);
ViewBag.code = code;

ViewBag.graphData = tm.rounds;

return View(tm);
}

[HttpPost]
public IActionResult Team(String teamnum, String teamname, String abilities, String performance, String downfalls, bool star)
public IActionResult Team(BSTeam tm)
{
BSConfig.initialize();
ViewBag.upcomingRounds = service.getUpcomingRounds();
int ex;
bool isNumeric = int.TryParse(teamnum, out ex);
if (ex < 0)
ex = -ex;
BSTeam tm = service.getTeam(ex);
if (isNumeric && tm != null)
{
tm.name = teamname;
tm.abilities = abilities;
tm.performance = performance;
tm.downfalls = downfalls;
tm.star = star;

service.setTeam(tm);
}
return RedirectToAction("Team", new { controller = "Dash", action = "Team", teamnum = teamnum, code = 1 });
if (tm == null)
return RedirectToAction("Team", new { controller = "Dash", action = "Team", code = 2 });
if (tm.comments != null)
if (tm.comments.Length >= 1024)
tm.comments = tm.comments.Substring(0, 1024);
if (tm.commentsP != null)
if (tm.commentsP.Length >= 1024)
tm.commentsP = tm.commentsP.Substring(0, 1024);
service.setTeam(tm);
return RedirectToAction("Team", new { controller = "Dash", action = "Team", teamnum = tm.team, code = 1 });
}

// Rounds
Expand Down Expand Up @@ -136,7 +131,7 @@ public IActionResult SetMatch(String roundnum, String comments)
}

[HttpPost]
public IActionResult Edit(BSRaw raw)
public IActionResult Edit(BSScout raw)
{
BSConfig.initialize();
ViewBag.upcomingRounds = service.getUpcomingRounds();
Expand All @@ -147,7 +142,7 @@ public IActionResult Edit(BSRaw raw)
raw.comments = raw.comments.Substring(0, 256);
service.setRound(raw);
ViewBag.code = 1;
BSRaw r = service.getById(raw.id);
BSScout r = service.getById(raw.id);
if (r == null)
{
return RedirectToAction("Rounds", new { controller = "Dash", code = 3 });
Expand All @@ -162,7 +157,7 @@ public IActionResult Edit(int id)
{
BSConfig.initialize();
ViewBag.upcomingRounds = service.getUpcomingRounds();
BSRaw r = service.getById(id);
BSScout r = service.getById(id);
if (r == null)
{
return RedirectToAction("Rounds", new { controller = "Dash", code = 3 });
Expand Down Expand Up @@ -191,7 +186,7 @@ public IActionResult Import(String num)
bool isFailure = false;

String section = num.Substring(i * length, length);
BSRaw raw = new BSRaw();
BSScout raw = new BSScout();
raw.checkboxes = new List<bool>();
raw.counters = new List<int>();

Expand Down
4 changes: 2 additions & 2 deletions BlitzScouter/Controllers/MainController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public IActionResult Index(int code)
}

[HttpPost]
public IActionResult Scout(BSRaw data)
public IActionResult Scout(BSScout data)
{
BSConfig.initialize();
if (service.containsTeam(data.team))
Expand All @@ -36,7 +36,7 @@ public IActionResult Scout(BSRaw data)
}

[HttpPost]
public IActionResult Data(BSRaw model)
public IActionResult Data(BSScout model)
{
if (model == null)
return RedirectToAction("Index", new { controller = "Main", action = "Index", code = 3 });
Expand Down
3 changes: 2 additions & 1 deletion BlitzScouter/Models/BSConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class BSConfig
* -----------------------------
*/

private const String CONFIG_FILE_LOCATION = "./config.yml";
private const String CONFIG_FILE_LOCATION = "../config.yml";
public static YAMLRoot c;
public static bool initialized = false;

Expand Down Expand Up @@ -53,6 +53,7 @@ public class YAMLRoot
public string tbaComp { get; set; }
public int teamnum { get; set; }
public List<Component> matchScout { get; set; }
public List<Component> pitScout { get; set; }
}

public class Component
Expand Down
2 changes: 1 addition & 1 deletion BlitzScouter/Models/BSContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace BlitzScouter.Models
{
public class BSContext : DbContext
{
public DbSet<BSRaw> BS_Rounds { get; set; }
public DbSet<BSScout> BS_Rounds { get; set; }
public DbSet<BSTeam> BS_Teams { get; set; }
public DbSet<BSMatch> BS_Matches { get; set; }

Expand Down
59 changes: 30 additions & 29 deletions BlitzScouter/Models/BSRaw.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ public class BSRaw
[System.ComponentModel.DataAnnotations.Key]
public int id { get; set; }
public int team { get; set; }
public int round { get; set; }
public String comments { get; set; }

// For SQL Use (Serialized)
Expand All @@ -31,44 +30,46 @@ public class BSRaw
// SQL --> ASP.NET (Deserializer)
public void toObj()
{
if (checkbox == null || counter == null)
return;

String[] checkboxSplit = checkbox.Split(',');
checkboxes = new List<bool>();
for (int i = 0; i < checkboxSplit.Length; i++)
checkboxes.Add(bool.Parse(checkboxSplit[i]));
if (checkbox != null)
{
String[] checkboxSplit = checkbox.Split(',');
checkboxes = new List<bool>();
for (int i = 0; i < checkboxSplit.Length; i++)
checkboxes.Add(bool.Parse(checkboxSplit[i]));
}

String[] counterSplit = counter.Split(',');
counters = new List<int>();
for (int i = 0; i < counterSplit.Length; i++)
counters.Add(int.Parse(counterSplit[i]));
if (counter != null)
{
String[] counterSplit = counter.Split(',');
counters = new List<int>();
for (int i = 0; i < counterSplit.Length; i++)
counters.Add(int.Parse(counterSplit[i]));
}
}

// ASP.NET --> SQL (Serializer)
public void toStr()
{
if (checkboxes == null || counters == null)
return;

checkbox = "";
counter = "";

for (int i = 0; i < checkboxes.Count; i++)
if (checkboxes != null)
{
checkbox += checkboxes[i].ToString();
if (i + 1 != checkboxes.Count)
checkbox += ",";
checkbox = "";
for (int i = 0; i < checkboxes.Count; i++)
{
checkbox += checkboxes[i].ToString();
if (i + 1 != checkboxes.Count)
checkbox += ",";
}
}
System.Diagnostics.Debug.WriteLine(checkbox);

for (int i = 0; i < counters.Count; i++)
if (counters != null)
{
counter += counters[i].ToString();
if (i + 1 != counters.Count)
counter += ",";
counter = "";
for (int i = 0; i < counters.Count; i++)
{
counter += counters[i].ToString();
if (i + 1 != counters.Count)
counter += ",";
}
}
System.Diagnostics.Debug.WriteLine(counter);
}
}
}
15 changes: 15 additions & 0 deletions BlitzScouter/Models/BSScout.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.EntityFrameworkCore;

namespace BlitzScouter.Models
{
public class BSScout : BSRaw
{
public int round { get; set; }
}
}
20 changes: 7 additions & 13 deletions BlitzScouter/Models/BSTeam.cs
Original file line number Diff line number Diff line change
@@ -1,30 +1,24 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.EntityFrameworkCore;

namespace BlitzScouter.Models
{
public class BSTeam
public class BSTeam : BSRaw
{
// SQL data
[System.ComponentModel.DataAnnotations.Key]
public int id { get; set; }
public int team { get; set; }
public String name { get; set; }
public String abilities { get; set; }
public String performance { get; set; }
public String downfalls { get; set; }
public bool star { get; set; }
public String commentsP { get; set; }


// Other Data
[NotMapped]
public List<double> checkboxAverages;
[NotMapped]
public List<double> counterAverages;
public List<BSRaw> rounds;
[NotMapped]
public List<BSScout> rounds;
}


}
20 changes: 14 additions & 6 deletions BlitzScouter/Repository/BSRepo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,15 @@ public bool containsTeam(int team)
{
return getTeam(team) != null;
}
public bool containsRound(BSRaw m)
public bool containsRound(BSScout m)
{
return getById(m.id) != null;
}
public bool containsMatch(String match)
{
return getMatch(match) != null;
}
public List<BSRaw> getRounds(int team)
public List<BSScout> getRounds(int team)
{
var rounds = db.BS_Rounds.Where(t => t.team.Equals(team)).OrderBy(r => r.round).ToList();
return rounds;
Expand All @@ -60,15 +60,15 @@ public BSMatch getMatch(String match)
{
return db.BS_Matches.FirstOrDefault(m => m.match == match);
}
public List<BSRaw> getAll()
public List<BSScout> getAll()
{
return db.BS_Rounds.OrderBy(val => val.round).ToList();
}
public List<BSTeam> GetAllTeams()
{
return db.BS_Teams.ToList();
}
public BSRaw getById(int id)
public BSScout getById(int id)
{
return db.BS_Rounds.FirstOrDefault(t => t.id == id);
}
Expand All @@ -85,19 +85,27 @@ public void addTeam(BSTeam teamData)
saveData();
}

public void addRound(BSRaw roundData)
public void addRound(BSScout roundData)
{
db.BS_Rounds.Add(roundData);
saveData();
}
public void updateRound(BSRaw round)
public void updateRound(BSScout round)
{
var dup = db.BS_Rounds.FirstOrDefault(m => m.id == round.id);
db.Entry(dup).State = EntityState.Detached;
db.BS_Rounds.Attach(round);
db.Entry(round).State = EntityState.Modified;
saveData();
}
public void updateTeam(BSTeam team)
{
var dup = db.BS_Teams.FirstOrDefault(m => m.id == team.id);
db.Entry(dup).State = EntityState.Detached;
db.BS_Teams.Attach(team);
db.Entry(team).State = EntityState.Modified;
saveData();
}
public void deleteRound(int id)
{
var round = db.BS_Rounds.First(r => r.id == id);
Expand Down
Loading

0 comments on commit 915140a

Please sign in to comment.