Permalink
Browse files

Add Autofac

  • Loading branch information...
petermorlion committed Sep 29, 2018
1 parent ba2b01c commit 42be49bd5191c1585750f5f51b94eb14478c60c3
Showing with 23,193 additions and 48,761 deletions.
  1. +16 −0 KotProno2.Tests/app.config
  2. BIN KotProno2/App_Data/KotProno2.mdf
  3. BIN KotProno2/App_Data/KotProno2_log.ldf
  4. +0 −1 KotProno2/App_Start/Startup.Auth.cs
  5. +30 −0 KotProno2/App_Start/Startup.Autofac.cs
  6. +0 −78 KotProno2/Content/breeze.directives.css
  7. +1 −5 KotProno2/Controllers/AccountController.cs
  8. +10 −5 KotProno2/Controllers/BettingsController.cs
  9. +2 −2 KotProno2/Controllers/HasStageStartedQuery.cs
  10. +1 −5 KotProno2/Controllers/HomeController.cs
  11. +7 −3 KotProno2/Controllers/MatchController.cs
  12. +8 −3 KotProno2/Controllers/MatchDetailsController.cs
  13. +10 −6 KotProno2/Controllers/OverviewController.cs
  14. +9 −4 KotProno2/Controllers/PointsController.cs
  15. +9 −4 KotProno2/Controllers/ScoresController.cs
  16. +8 −4 KotProno2/Controllers/StatsController.cs
  17. +7 −2 KotProno2/Controllers/TopScorerController.cs
  18. +7 −2 KotProno2/Controllers/TopScorersController.cs
  19. +8 −3 KotProno2/Controllers/TournamentsController.cs
  20. +0 −19 KotProno2/EntityFramework/MatchesContext.cs
  21. +6 −4 KotProno2/Global.asax.cs
  22. +51 −53 KotProno2/KotProno2.csproj
  23. BIN KotProno2/Scripts/_references.js
  24. +0 −144 KotProno2/Scripts/breeze.angular.js
  25. +0 −16,356 KotProno2/Scripts/breeze.debug.js
  26. +0 −420 KotProno2/Scripts/breeze.directives.js
  27. +0 −2,851 KotProno2/Scripts/breeze.intellisense.js
  28. +0 −6 KotProno2/Scripts/breeze.min.js
  29. +1 −0 KotProno2/Startup.cs
  30. +31 −15 KotProno2/Web.config
  31. +15 −14 KotProno2/packages.config
  32. BIN packages/Autofac.4.8.1/Autofac.4.8.1.nupkg
  33. BIN packages/Autofac.4.8.1/lib/net45/Autofac.dll
  34. +7,949 −0 packages/Autofac.4.8.1/lib/net45/Autofac.xml
  35. BIN packages/Autofac.4.8.1/lib/netstandard1.1/Autofac.dll
  36. +7,949 −0 packages/Autofac.4.8.1/lib/netstandard1.1/Autofac.xml
  37. BIN packages/Autofac.Mvc5.4.0.2/Autofac.Mvc5.4.0.2.nupkg
  38. BIN packages/Autofac.Mvc5.4.0.2/lib/net45/Autofac.Integration.Mvc.dll
  39. +964 −0 packages/Autofac.Mvc5.4.0.2/lib/net45/Autofac.Integration.Mvc.xml
  40. BIN packages/Autofac.Mvc5.Owin.4.0.1/Autofac.Mvc5.Owin.4.0.1.nupkg
  41. BIN packages/Autofac.Mvc5.Owin.4.0.1/lib/net45/Autofac.Integration.Mvc.Owin.dll
  42. +20 −0 packages/Autofac.Mvc5.Owin.4.0.1/lib/net45/Autofac.Integration.Mvc.Owin.xml
  43. BIN packages/Autofac.Owin.4.0.0/Autofac.Owin.4.0.0.nupkg
  44. BIN packages/Autofac.Owin.4.0.0/lib/net45/Autofac.Integration.Owin.dll
  45. +294 −0 packages/Autofac.Owin.4.0.0/lib/net45/Autofac.Integration.Owin.xml
  46. BIN packages/Autofac.WebApi2.4.0.0/Autofac.WebApi2.4.0.0.nupkg
  47. BIN packages/Autofac.WebApi2.4.0.0/lib/net45/Autofac.Integration.WebApi.dll
  48. +872 −0 packages/Autofac.WebApi2.4.0.0/lib/net45/Autofac.Integration.WebApi.xml
  49. BIN packages/Autofac.WebApi2.Owin.4.0.0/.signature.p7s
  50. BIN packages/Autofac.WebApi2.Owin.4.0.0/Autofac.WebApi2.Owin.4.0.0.nupkg
  51. BIN packages/Autofac.WebApi2.Owin.4.0.0/lib/net45/Autofac.Integration.WebApi.Owin.dll
  52. +24 −0 packages/Autofac.WebApi2.Owin.4.0.0/lib/net45/Autofac.Integration.WebApi.Owin.xml
  53. BIN packages/Breeze.Angular.0.8.5/Breeze.Angular.0.8.5.nupkg
  54. +0 −23 packages/Breeze.Angular.0.8.5/Breeze.Angular.0.8.5.nuspec
  55. +0 −144 packages/Breeze.Angular.0.8.5/content/scripts/breeze.angular.js
  56. BIN packages/Breeze.Angular.Directives.1.3.6/Breeze.Angular.Directives.1.3.6.nupkg
  57. +0 −19 packages/Breeze.Angular.Directives.1.3.6/Breeze.Angular.Directives.1.3.6.nuspec
  58. +0 −78 packages/Breeze.Angular.Directives.1.3.6/content/content/breeze.directives.css
  59. +0 −420 packages/Breeze.Angular.Directives.1.3.6/content/scripts/breeze.directives.js
  60. BIN packages/Breeze.Client.1.4.12/Breeze.Client.1.4.12.nupkg
  61. +0 −23 packages/Breeze.Client.1.4.12/Breeze.Client.1.4.12.nuspec
  62. +0 −16,356 packages/Breeze.Client.1.4.12/content/Scripts/breeze.debug.js
  63. +0 −2,851 packages/Breeze.Client.1.4.12/content/Scripts/breeze.intellisense.js
  64. +0 −6 packages/Breeze.Client.1.4.12/content/Scripts/breeze.min.js
  65. +0 −19 packages/Breeze.Client.1.4.12/readme.txt
  66. BIN packages/Breeze.Client.1.4.12/tools/install.ps1
  67. BIN packages/Breeze.Server.ContextProvider.1.4.12/Breeze.Server.ContextProvider.1.4.12.nupkg
  68. +0 −23 packages/Breeze.Server.ContextProvider.1.4.12/Breeze.Server.ContextProvider.1.4.12.nuspec
  69. BIN packages/Breeze.Server.ContextProvider.1.4.12/lib/Breeze.ContextProvider.dll
  70. +0 −2 packages/Breeze.Server.ContextProvider.1.4.12/readme.txt
  71. BIN packages/Breeze.Server.ContextProvider.EF6.1.4.12/Breeze.Server.ContextProvider.EF6.1.4.12.nupkg
  72. +0 −24 packages/Breeze.Server.ContextProvider.EF6.1.4.12/Breeze.Server.ContextProvider.EF6.1.4.12.nuspec
  73. BIN packages/Breeze.Server.ContextProvider.EF6.1.4.12/lib/Breeze.ContextProvider.EF6.dll
  74. +0 −2 packages/Breeze.Server.ContextProvider.EF6.1.4.12/readme.txt
  75. BIN packages/Breeze.Server.WebApi2.1.4.12/Breeze.Server.WebApi2.1.4.12.nupkg
  76. +0 −26 packages/Breeze.Server.WebApi2.1.4.12/Breeze.Server.WebApi2.1.4.12.nuspec
  77. +0 −22 packages/Breeze.Server.WebApi2.1.4.12/content/App_Start/BreezeWebApiConfig.cs.pp
  78. BIN packages/Breeze.Server.WebApi2.1.4.12/lib/Breeze.WebApi2.dll
  79. +0 −2 packages/Breeze.Server.WebApi2.1.4.12/readme.txt
  80. BIN packages/Microsoft.AspNet.Mvc.5.0.0/Microsoft.AspNet.Mvc.5.0.0.nupkg
  81. +0 −22 packages/Microsoft.AspNet.Mvc.5.0.0/Microsoft.AspNet.Mvc.5.0.0.nuspec
  82. BIN packages/Microsoft.AspNet.Mvc.5.0.0/lib/net45/System.Web.Mvc.dll
  83. BIN packages/Microsoft.AspNet.Mvc.5.1.0/.signature.p7s
  84. +34 −0 packages/Microsoft.AspNet.Mvc.5.1.0/Content/Web.config.install.xdt
  85. +10 −0 packages/Microsoft.AspNet.Mvc.5.1.0/Content/Web.config.uninstall.xdt
  86. BIN packages/Microsoft.AspNet.Mvc.5.1.0/Microsoft.AspNet.Mvc.5.1.0.nupkg
  87. BIN packages/Microsoft.AspNet.Mvc.5.1.0/lib/net45/System.Web.Mvc.dll
  88. +362 −89 packages/{Microsoft.AspNet.Mvc.5.0.0 → Microsoft.AspNet.Mvc.5.1.0}/lib/net45/System.Web.Mvc.xml
  89. BIN packages/Microsoft.AspNet.Razor.3.0.0/Microsoft.AspNet.Razor.3.0.0.nupkg
  90. +0 −18 packages/Microsoft.AspNet.Razor.3.0.0/Microsoft.AspNet.Razor.3.0.0.nuspec
  91. BIN packages/Microsoft.AspNet.Razor.3.0.0/lib/net45/System.Web.Razor.dll
  92. BIN packages/Microsoft.AspNet.Razor.3.1.0/Microsoft.AspNet.Razor.3.1.0.nupkg
  93. BIN packages/Microsoft.AspNet.Razor.3.1.0/lib/net45/System.Web.Razor.dll
  94. 0 ...ages/{Microsoft.AspNet.Razor.3.0.0 → Microsoft.AspNet.Razor.3.1.0}/lib/net45/System.Web.Razor.xml
  95. BIN packages/Microsoft.AspNet.WebApi.Client.5.1.2/Microsoft.AspNet.WebApi.Client.5.1.2.nupkg
  96. +0 −31 packages/Microsoft.AspNet.WebApi.Client.5.1.2/Microsoft.AspNet.WebApi.Client.5.1.2.nuspec
  97. BIN packages/Microsoft.AspNet.WebApi.Client.5.1.2/lib/net45/System.Net.Http.Formatting.dll
  98. BIN ...rosoft.AspNet.WebApi.Client.5.1.2/lib/portable-wp8+netcore45+net45/System.Net.Http.Formatting.dll
  99. BIN packages/Microsoft.AspNet.WebApi.Client.5.2.0/Microsoft.AspNet.WebApi.Client.5.2.0.nupkg
  100. BIN packages/Microsoft.AspNet.WebApi.Client.5.2.0/lib/net45/System.Net.Http.Formatting.dll
  101. +77 −1 ...Api.Client.5.1.2 → Microsoft.AspNet.WebApi.Client.5.2.0}/lib/net45/System.Net.Http.Formatting.xml
  102. BIN ...et.WebApi.Client.5.2.0/lib/portable-wp8+netcore45+net45+wp81+wpa81/System.Net.Http.Formatting.dll
  103. 0 ...t.WebApi.Client.5.2.0/lib/portable-wp8+netcore45+net45+wp81+wpa81}/System.Net.Http.Formatting.xml
  104. BIN packages/Microsoft.AspNet.WebApi.Core.5.1.2/Microsoft.AspNet.WebApi.Core.5.1.2.nupkg
  105. +0 −22 packages/Microsoft.AspNet.WebApi.Core.5.1.2/Microsoft.AspNet.WebApi.Core.5.1.2.nuspec
  106. BIN packages/Microsoft.AspNet.WebApi.Core.5.1.2/lib/net45/System.Web.Http.dll
  107. 0 ...osoft.AspNet.WebApi.Core.5.1.2 → Microsoft.AspNet.WebApi.Core.5.2.0}/Content/web.config.transform
  108. BIN packages/Microsoft.AspNet.WebApi.Core.5.2.0/Microsoft.AspNet.WebApi.Core.5.2.0.nupkg
  109. BIN packages/Microsoft.AspNet.WebApi.Core.5.2.0/lib/net45/System.Web.Http.dll
  110. +107 −7 ...soft.AspNet.WebApi.Core.5.1.2 → Microsoft.AspNet.WebApi.Core.5.2.0}/lib/net45/System.Web.Http.xml
  111. BIN packages/Microsoft.AspNet.WebApi.OData.5.1.2/Microsoft.AspNet.WebApi.OData.5.1.2.nupkg
  112. +0 −27 packages/Microsoft.AspNet.WebApi.OData.5.1.2/Microsoft.AspNet.WebApi.OData.5.1.2.nuspec
  113. BIN packages/Microsoft.AspNet.WebApi.OData.5.1.2/lib/net45/System.Web.Http.OData.dll
  114. BIN packages/Microsoft.AspNet.WebApi.OData.5.2.0/.signature.p7s
  115. BIN packages/Microsoft.AspNet.WebApi.OData.5.2.0/Microsoft.AspNet.WebApi.OData.5.2.0.nupkg
  116. BIN packages/Microsoft.AspNet.WebApi.OData.5.2.0/lib/net45/System.Web.Http.OData.dll
  117. +964 −1,253 ...Net.WebApi.OData.5.1.2 → Microsoft.AspNet.WebApi.OData.5.2.0}/lib/net45/System.Web.Http.OData.xml
  118. BIN packages/Microsoft.AspNet.WebApi.Owin.5.2.0/.signature.p7s
  119. BIN packages/Microsoft.AspNet.WebApi.Owin.5.2.0/Microsoft.AspNet.WebApi.Owin.5.2.0.nupkg
  120. BIN packages/Microsoft.AspNet.WebApi.Owin.5.2.0/lib/net45/System.Web.Http.Owin.dll
  121. +195 −0 packages/Microsoft.AspNet.WebApi.Owin.5.2.0/lib/net45/System.Web.Http.Owin.xml
  122. BIN packages/Microsoft.AspNet.WebApi.WebHost.5.1.2/Microsoft.AspNet.WebApi.WebHost.5.1.2.nupkg
  123. +0 −22 packages/Microsoft.AspNet.WebApi.WebHost.5.1.2/Microsoft.AspNet.WebApi.WebHost.5.1.2.nuspec
  124. BIN packages/Microsoft.AspNet.WebApi.WebHost.5.1.2/lib/net45/System.Web.Http.WebHost.dll
  125. BIN packages/Microsoft.AspNet.WebApi.WebHost.5.2.0/.signature.p7s
  126. BIN packages/Microsoft.AspNet.WebApi.WebHost.5.2.0/Microsoft.AspNet.WebApi.WebHost.5.2.0.nupkg
  127. BIN packages/Microsoft.AspNet.WebApi.WebHost.5.2.0/lib/net45/System.Web.Http.WebHost.dll
  128. 0 ...bApi.WebHost.5.1.2 → Microsoft.AspNet.WebApi.WebHost.5.2.0}/lib/net45/System.Web.Http.WebHost.xml
  129. BIN packages/Microsoft.AspNet.WebPages.3.0.0/Microsoft.AspNet.WebPages.3.0.0.nupkg
  130. +0 −22 packages/Microsoft.AspNet.WebPages.3.0.0/Microsoft.AspNet.WebPages.3.0.0.nuspec
  131. BIN packages/Microsoft.AspNet.WebPages.3.0.0/lib/net45/System.Web.Helpers.dll
  132. +0 −836 packages/Microsoft.AspNet.WebPages.3.0.0/lib/net45/System.Web.Helpers.xml
  133. BIN packages/Microsoft.AspNet.WebPages.3.0.0/lib/net45/System.Web.WebPages.Deployment.dll
  134. +0 −60 packages/Microsoft.AspNet.WebPages.3.0.0/lib/net45/System.Web.WebPages.Deployment.xml
  135. BIN packages/Microsoft.AspNet.WebPages.3.0.0/lib/net45/System.Web.WebPages.Razor.dll
  136. +0 −292 packages/Microsoft.AspNet.WebPages.3.0.0/lib/net45/System.Web.WebPages.Razor.xml
  137. BIN packages/Microsoft.AspNet.WebPages.3.0.0/lib/net45/System.Web.WebPages.dll
  138. +0 −2,688 packages/Microsoft.AspNet.WebPages.3.0.0/lib/net45/System.Web.WebPages.xml
  139. +41 −0 packages/Microsoft.AspNet.WebPages.3.1.0/Content/Web.config.install.xdt
  140. +13 −0 packages/Microsoft.AspNet.WebPages.3.1.0/Content/Web.config.uninstall.xdt
  141. BIN packages/Microsoft.AspNet.WebPages.3.1.0/Microsoft.AspNet.WebPages.3.1.0.nupkg
  142. BIN packages/Microsoft.AspNet.WebPages.3.1.0/lib/net45/System.Web.Helpers.dll
  143. +587 −0 packages/Microsoft.AspNet.WebPages.3.1.0/lib/net45/System.Web.Helpers.xml
  144. BIN packages/Microsoft.AspNet.WebPages.3.1.0/lib/net45/System.Web.WebPages.Deployment.dll
  145. +231 −0 packages/Microsoft.AspNet.WebPages.3.1.0/lib/net45/System.Web.WebPages.Deployment.xml
  146. BIN packages/Microsoft.AspNet.WebPages.3.1.0/lib/net45/System.Web.WebPages.Razor.dll
  147. +111 −0 packages/Microsoft.AspNet.WebPages.3.1.0/lib/net45/System.Web.WebPages.Razor.xml
  148. BIN packages/Microsoft.AspNet.WebPages.3.1.0/lib/net45/System.Web.WebPages.dll
  149. +1,039 −0 packages/Microsoft.AspNet.WebPages.3.1.0/lib/net45/System.Web.WebPages.xml
  150. BIN packages/Microsoft.Owin.2.0.0/Microsoft.Owin.2.0.0.nupkg
  151. +0 −18 packages/Microsoft.Owin.2.0.0/Microsoft.Owin.2.0.0.nuspec
  152. +0 −2,523 packages/Microsoft.Owin.2.0.0/lib/net40/Microsoft.Owin.XML
  153. BIN packages/Microsoft.Owin.2.0.0/lib/net40/Microsoft.Owin.dll
  154. BIN packages/Microsoft.Owin.2.0.0/lib/net45/Microsoft.Owin.dll
  155. BIN packages/Microsoft.Owin.3.0.0/Microsoft.Owin.3.0.0.nupkg
  156. +1,113 −781 packages/{Microsoft.Owin.2.0.0 → Microsoft.Owin.3.0.0}/lib/net45/Microsoft.Owin.XML
  157. BIN packages/Microsoft.Owin.3.0.0/lib/net45/Microsoft.Owin.dll
@@ -22,6 +22,22 @@
<assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-1.5.2.14234" newVersion="1.5.2.14234" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Owin" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Autofac" publicKeyToken="17863af14b0044da" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.8.1.0" newVersion="4.8.1.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Autofac.Integration.Owin" publicKeyToken="17863af14b0044da" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Autofac.Integration.WebApi" publicKeyToken="17863af14b0044da" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" /></startup></configuration>
BIN +0 Bytes (100%) KotProno2/App_Data/KotProno2.mdf
Binary file not shown.
Binary file not shown.
@@ -13,7 +13,6 @@ public void ConfigureAuth(IAppBuilder app)
{
AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
LoginPath = new PathString("/Account/Login")

});
}
}
@@ -0,0 +1,30 @@
using System.Web.Http;
using System.Web.Mvc;
using Autofac;
using Autofac.Integration.Mvc;
using Autofac.Integration.WebApi;
using KotProno2.EntityFramework;
using Owin;

namespace KotProno2
{
public partial class Startup
{
public void ConfigureAutofac(IAppBuilder app)
{
var builder = new ContainerBuilder();
builder.RegisterApiControllers(typeof(MvcApplication).Assembly);
builder.RegisterControllers(typeof(MvcApplication).Assembly);
builder.RegisterType<MatchesDbContext>().InstancePerRequest();
var container = builder.Build();

DependencyResolver.SetResolver(new AutofacDependencyResolver(container));

app.UseAutofacMiddleware(container);
app.UseAutofacMvc();

var config = GlobalConfiguration.Configuration;
config.DependencyResolver = new AutofacWebApiDependencyResolver(container);
}
}
}

This file was deleted.

Oops, something went wrong.
@@ -1,8 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Claims;
using System.Threading.Tasks;
using System.Threading.Tasks;
using System.Web;
using System.Web.Mvc;
using Microsoft.AspNet.Identity;
@@ -9,13 +9,18 @@ namespace KotProno2.Controllers
{
public class BettingsController : ApiController
{
private readonly MatchesContext _contextProvider = new MatchesContext();
private readonly MatchesDbContext _context;

public BettingsController(MatchesDbContext context)
{
_context = context;
}

[HttpGet]
[Authorize]
public IList<Betting> Get()
{
return _contextProvider.Context.Bettings.Where(x => x.UserName == User.Identity.Name).ToList();
return _context.Bettings.Where(x => x.UserName == User.Identity.Name).ToList();
}

[HttpPost]
@@ -30,9 +35,9 @@ public void Post(object data)
UserName = User.Identity.Name,
};

command.Execute(_contextProvider.Context);
_contextProvider.Context.Commands.Add(command);
_contextProvider.Context.SaveChangesAsync();
command.Execute(_context);
_context.Commands.Add(command);
_context.SaveChangesAsync();
}
}
}
@@ -8,11 +8,11 @@ namespace KotProno2.Controllers
{
public class HasStageStartedQuery
{
private readonly MatchesContext _matchesContext = new MatchesContext();
private readonly MatchesDbContext _context = new MatchesDbContext();

public bool Execute(int tournamentId, Stage stage)
{
var matches = _matchesContext.Context.Matches.Where(x => x.TournamentId == tournamentId).OrderBy(x => x.DateTime).ToList();
var matches = _context.Matches.Where(x => x.TournamentId == tournamentId).OrderBy(x => x.DateTime).ToList();

var stageStart = GetStageStart(matches, stage);

@@ -1,8 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Mvc;

namespace KotProno2.Controllers
{
@@ -1,4 +1,3 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web.Http;
@@ -9,12 +8,17 @@ namespace KotProno2.Controllers
{
public class MatchController : ApiController
{
private readonly MatchesContext _matchesContext = new MatchesContext();
private readonly MatchesDbContext _context;

public MatchController(MatchesDbContext context)
{
_context = context;
}

[HttpGet]
public IList<Match> Get(int id)
{
var matches = _matchesContext.Context.Matches.Where(x => x.TournamentId == id).OrderBy(x => x.DateTime).ToList();
var matches = _context.Matches.Where(x => x.TournamentId == id).OrderBy(x => x.DateTime).ToList();

return matches;
}
@@ -7,15 +7,20 @@ namespace KotProno2.Controllers
{
public class MatchDetailsController : ApiController
{
private readonly MatchesContext _contextProvider = new MatchesContext();
private readonly MatchesDbContext _context;

public MatchDetailsController(MatchesDbContext context)
{
_context = context;
}

/// <param name="id">The match id</param>
[HttpGet]
[Authorize]
public MatchDetails MatchDetails(int id)
{
var match = _contextProvider.Context.Matches.Single(x => x.Id == id);
var bettings = _contextProvider.Context.Bettings.Where(x => x.MatchId == id);
var match = _context.Matches.Single(x => x.Id == id);
var bettings = _context.Bettings.Where(x => x.MatchId == id);

return new MatchDetails
{
@@ -1,5 +1,4 @@
using System;
using System.Linq;
using System.Linq;
using System.Web.Http;
using KotProno2.EntityFramework;
using KotProno2.Models;
@@ -8,22 +7,27 @@ namespace KotProno2.Controllers
{
public class OverviewController : ApiController
{
private readonly MatchesContext _matchesContext = new MatchesContext();
private readonly MatchesDbContext _context;
private readonly ApplicationDbContext _applicationDbContext = new ApplicationDbContext();

public OverviewController(MatchesDbContext context)
{
_context = context;
}

[HttpGet]
public Overview Get(int id)
{
var result = new Overview();
var users = _applicationDbContext.Users.OrderBy(x => x.UserName).ToList();
var bettings = _matchesContext.Context.Bettings.Where(x => x.Match.TournamentId == id).ToLookup(x => x.MatchId);
var matches = _matchesContext.Context.Matches
var bettings = _context.Bettings.Where(x => x.Match.TournamentId == id).ToLookup(x => x.MatchId);
var matches = _context.Matches
.Where(x => x.TournamentId == id)
.OrderByDescending(x => x.DateTime)
.ToList()
.Where(x => x.IsReadOnly)
.ToList();
var usersWithCorrectTopScorer = _matchesContext.Context.TopScorers.Where(x => x.TournamentId == id && x.IsCorrect).Select(x => x.UserName).ToList();
var usersWithCorrectTopScorer = _context.TopScorers.Where(x => x.TournamentId == id && x.IsCorrect).Select(x => x.UserName).ToList();

//TODO: code grew organically with increasing number of ifs, indenting,... Crap
foreach (var user in users)
@@ -8,16 +8,21 @@ namespace KotProno2.Controllers
{
public class PointsController : ApiController
{
private readonly MatchesContext _matchesContext = new MatchesContext();
private readonly MatchesDbContext _context;

public PointsController(MatchesDbContext context)
{
_context = context;
}

[HttpGet]
public IList<Points> Get(int id)
{
var result = new List<Points>();
var bettings = _matchesContext.Context.Bettings.Where(x => x.Match.TournamentId == id).ToList();
var matches = _matchesContext.Context.Matches.Where(x => x.TournamentId == id).ToList();
var bettings = _context.Bettings.Where(x => x.Match.TournamentId == id).ToList();
var matches = _context.Matches.Where(x => x.TournamentId == id).ToList();
var users = new ApplicationDbContext().Users.ToList();
var usersWithCorrectTopScorer = _matchesContext.Context.TopScorers.Where(x => x.TournamentId == id && x.IsCorrect).Select(x => x.UserName).ToList();
var usersWithCorrectTopScorer = _context.TopScorers.Where(x => x.TournamentId == id && x.IsCorrect).Select(x => x.UserName).ToList();

foreach (var user in users)
{
@@ -7,7 +7,12 @@ namespace KotProno2.Controllers
{
public class ScoresController : ApiController
{
private readonly MatchesContext _contextProvider = new MatchesContext();
private readonly MatchesDbContext _context;

public ScoresController(MatchesDbContext context)
{
_context = context;
}

[HttpPost]
[Authorize]
@@ -27,9 +32,9 @@ public void Post(object data)
UserName = User.Identity.Name,
};

command.Execute(_contextProvider.Context);
_contextProvider.Context.Commands.Add(command);
_contextProvider.Context.SaveChangesAsync();
command.Execute(_context);
_context.Commands.Add(command);
_context.SaveChangesAsync();
}
}
}
@@ -1,5 +1,4 @@
using System.Collections.Generic;
using System.IO.Ports;
using System.Linq;
using System.Web.Http;
using KotProno2.EntityFramework;
@@ -9,18 +8,23 @@ namespace KotProno2.Controllers
{
public class StatsController : ApiController
{
private readonly MatchesContext _matchesContext = new MatchesContext();
private readonly MatchesDbContext _context;
private readonly ApplicationDbContext _applicationDbContext = new ApplicationDbContext();

public StatsController(MatchesDbContext context)
{
_context = context;
}

[HttpGet]
public Statistics Statistics(int id)
{
var exactResultsPerUser = new Dictionary<string, int>();

var result = new Statistics();
var users = _applicationDbContext.Users.OrderBy(x => x.UserName).ToList();
var bettings = _matchesContext.Context.Bettings.Where(x => x.Match.TournamentId == id).ToLookup(x => x.MatchId);
var matches = _matchesContext.Context.Matches.Where(x => x.TournamentId == id).OrderBy(x => x.DateTime).ToList();
var bettings = _context.Bettings.Where(x => x.Match.TournamentId == id).ToLookup(x => x.MatchId);
var matches = _context.Matches.Where(x => x.TournamentId == id).OrderBy(x => x.DateTime).ToList();

result.Categories = new List<string>();
result.Series = new List<Serie>();
Oops, something went wrong.

0 comments on commit 42be49b

Please sign in to comment.