Initial
This commit is contained in:
5
.gitignore
vendored
Normal file
5
.gitignore
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
bin/
|
||||
obj/
|
||||
/packages/
|
||||
.blob
|
||||
.idea/
|
||||
23
EstusShots.Gtk/EstusShots.Gtk.csproj
Normal file
23
EstusShots.Gtk/EstusShots.Gtk.csproj
Normal file
@@ -0,0 +1,23 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<TargetFramework>netcoreapp3.1</TargetFramework>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Remove="**\*.glade" />
|
||||
<EmbeddedResource Include="**\*.glade">
|
||||
<LogicalName>%(Filename)%(Extension)</LogicalName>
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="GtkSharp" Version="3.22.25.*" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\EstusShots.Shared\EstusShots.Shared.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
70
EstusShots.Gtk/MainWindow.cs
Normal file
70
EstusShots.Gtk/MainWindow.cs
Normal file
@@ -0,0 +1,70 @@
|
||||
using System;
|
||||
using System.Net.Http;
|
||||
using System.Text;
|
||||
using System.Text.Json;
|
||||
using EstusShots.Shared.Models;
|
||||
using Gtk;
|
||||
using UI = Gtk.Builder.ObjectAttribute;
|
||||
|
||||
namespace EstusShots.Gtk
|
||||
{
|
||||
class MainWindow : Window
|
||||
{
|
||||
private const string ApiUrl = "http://localhost:5000/api/";
|
||||
|
||||
[UI] private TreeView _seasonsView = null;
|
||||
[UI] private Button _loadButton = null;
|
||||
[UI] private Label _infoLabel = null;
|
||||
|
||||
public MainWindow() : this(new Builder("MainWindow.glade")) { }
|
||||
|
||||
private MainWindow(Builder builder) : base(builder.GetObject("MainWindow").Handle)
|
||||
{
|
||||
builder.Autoconnect(this);
|
||||
|
||||
DeleteEvent += Window_DeleteEvent;
|
||||
_loadButton.Clicked += _loadButton_Clicked;
|
||||
}
|
||||
|
||||
private void Window_DeleteEvent(object sender, DeleteEventArgs a)
|
||||
{
|
||||
Application.Quit();
|
||||
}
|
||||
|
||||
private void _loadButton_Clicked(object sender, EventArgs a)
|
||||
{
|
||||
var season = new Season()
|
||||
{
|
||||
Game = "Test Game",
|
||||
Start = DateTime.Now
|
||||
};
|
||||
|
||||
var content = new StringContent(JsonSerializer.Serialize(season), Encoding.UTF8, "application/json");
|
||||
var client = new HttpClient();
|
||||
try
|
||||
{
|
||||
var response = client.PostAsync(ApiUrl + "seasons", content).Result;
|
||||
|
||||
if (response.Headers.Location == null)
|
||||
{
|
||||
_infoLabel.Text = $"Error while creating Season: {response.ReasonPhrase}";
|
||||
return;
|
||||
}
|
||||
|
||||
var data = client.GetAsync(response.Headers.Location).Result;
|
||||
var jsonData = data.Content.ReadAsStringAsync().Result;
|
||||
var options = new JsonSerializerOptions
|
||||
{
|
||||
PropertyNameCaseInsensitive = true,
|
||||
};
|
||||
var s = JsonSerializer.Deserialize<Season>(jsonData, options);
|
||||
_infoLabel.Text = $"Created new Season: {s.Game} ({s.SeasonId})";
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_infoLabel.Text = $"Exception Occured: {e.Message}";
|
||||
Console.WriteLine(e.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
59
EstusShots.Gtk/MainWindow.glade
Normal file
59
EstusShots.Gtk/MainWindow.glade
Normal file
@@ -0,0 +1,59 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- Generated with glade 3.22.1 -->
|
||||
<interface>
|
||||
<requires lib="gtk+" version="3.18"/>
|
||||
<object class="GtkWindow" id="MainWindow">
|
||||
<property name="can_focus">False</property>
|
||||
<property name="title" translatable="yes">Example Window</property>
|
||||
<property name="default_width">480</property>
|
||||
<property name="default_height">240</property>
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="orientation">vertical</property>
|
||||
<child>
|
||||
<object class="GtkLabel" id="_infoLabel">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkTreeView" id="_seasonsView">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<child internal-child="selection">
|
||||
<object class="GtkTreeSelection"/>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkButton" id="_loadButton">
|
||||
<property name="label" translatable="yes">Load Seasons</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">2</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</interface>
|
||||
23
EstusShots.Gtk/Program.cs
Normal file
23
EstusShots.Gtk/Program.cs
Normal file
@@ -0,0 +1,23 @@
|
||||
using System;
|
||||
using Gtk;
|
||||
|
||||
namespace EstusShots.Gtk
|
||||
{
|
||||
class Program
|
||||
{
|
||||
[STAThread]
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
Application.Init();
|
||||
|
||||
var app = new Application("EstusShots.Gtk", GLib.ApplicationFlags.None);
|
||||
app.Register(GLib.Cancellable.Current);
|
||||
|
||||
var win = new MainWindow();
|
||||
app.AddWindow(win);
|
||||
|
||||
win.Show();
|
||||
Application.Run();
|
||||
}
|
||||
}
|
||||
}
|
||||
36
EstusShots.Server/Controllers/SeasonsController.cs
Normal file
36
EstusShots.Server/Controllers/SeasonsController.cs
Normal file
@@ -0,0 +1,36 @@
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using EstusShots.Server.Services;
|
||||
using EstusShots.Shared.Models;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace EstusShots.Server.Controllers
|
||||
{
|
||||
[ApiController]
|
||||
[Route("/api/[controller]")]
|
||||
public class SeasonsController : ControllerBase
|
||||
{
|
||||
private readonly EstusShotsContext _context;
|
||||
|
||||
public SeasonsController(EstusShotsContext context)
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
|
||||
[HttpGet("{id}")]
|
||||
public async Task<ActionResult<Season>> GetSeason(Guid id)
|
||||
{
|
||||
var season = await _context.Seasons.FindAsync(id);
|
||||
if (season == null) return NotFound();
|
||||
return season;
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public async Task<ActionResult<Season>> CreateSeason(Season season)
|
||||
{
|
||||
_context.Seasons.Add(season);
|
||||
await _context.SaveChangesAsync();
|
||||
return CreatedAtAction(nameof(GetSeason), new {id = season.SeasonId}, season);
|
||||
}
|
||||
}
|
||||
}
|
||||
25
EstusShots.Server/EstusShots.Server.csproj
Normal file
25
EstusShots.Server/EstusShots.Server.csproj
Normal file
@@ -0,0 +1,25 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netcoreapp3.1</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
|
||||
<WarningsAsErrors>NU1605;CS8618</WarningsAsErrors>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
|
||||
<WarningsAsErrors>NU1605;CS8618</WarningsAsErrors>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="3.1.2" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="3.1.2" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="3.1.2" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\EstusShots.Shared\EstusShots.Shared.csproj" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
23
EstusShots.Server/Program.cs
Normal file
23
EstusShots.Server/Program.cs
Normal file
@@ -0,0 +1,23 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace EstusShots.Server
|
||||
{
|
||||
public class Program
|
||||
{
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
CreateHostBuilder(args).Build().Run();
|
||||
}
|
||||
|
||||
public static IHostBuilder CreateHostBuilder(string[] args) =>
|
||||
Host.CreateDefaultBuilder(args)
|
||||
.ConfigureWebHostDefaults(webBuilder => { webBuilder.UseStartup<Startup>(); });
|
||||
}
|
||||
}
|
||||
30
EstusShots.Server/Properties/launchSettings.json
Normal file
30
EstusShots.Server/Properties/launchSettings.json
Normal file
@@ -0,0 +1,30 @@
|
||||
{
|
||||
"$schema": "http://json.schemastore.org/launchsettings.json",
|
||||
"iisSettings": {
|
||||
"windowsAuthentication": false,
|
||||
"anonymousAuthentication": true,
|
||||
"iisExpress": {
|
||||
"applicationUrl": "http://localhost:26850",
|
||||
"sslPort": 44318
|
||||
}
|
||||
},
|
||||
"profiles": {
|
||||
"IIS Express": {
|
||||
"commandName": "IISExpress",
|
||||
"launchBrowser": true,
|
||||
"launchUrl": "weatherforecast",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
}
|
||||
},
|
||||
"EstusShots.Server": {
|
||||
"commandName": "Project",
|
||||
"launchBrowser": false,
|
||||
"launchUrl": "",
|
||||
"applicationUrl": "https://localhost:5001;http://localhost:5000",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
14
EstusShots.Server/Services/EstusShotsContext.cs
Normal file
14
EstusShots.Server/Services/EstusShotsContext.cs
Normal file
@@ -0,0 +1,14 @@
|
||||
using EstusShots.Shared.Models;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace EstusShots.Server.Services
|
||||
{
|
||||
public class EstusShotsContext : DbContext
|
||||
{
|
||||
public EstusShotsContext(DbContextOptions options) : base(options)
|
||||
{
|
||||
}
|
||||
|
||||
public DbSet<Season> Seasons { get; set; } = default!;
|
||||
}
|
||||
}
|
||||
47
EstusShots.Server/Startup.cs
Normal file
47
EstusShots.Server/Startup.cs
Normal file
@@ -0,0 +1,47 @@
|
||||
using EstusShots.Server.Services;
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
|
||||
namespace EstusShots.Server
|
||||
{
|
||||
public class Startup
|
||||
{
|
||||
public Startup(IConfiguration configuration)
|
||||
{
|
||||
Configuration = configuration;
|
||||
}
|
||||
|
||||
public IConfiguration Configuration { get; }
|
||||
|
||||
// This method gets called by the runtime. Use this method to add services to the container.
|
||||
public void ConfigureServices(IServiceCollection services)
|
||||
{
|
||||
services.AddDbContext<EstusShotsContext>(
|
||||
opt => opt.UseInMemoryDatabase("debug.db"));
|
||||
services.AddControllers();
|
||||
}
|
||||
|
||||
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
|
||||
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
|
||||
{
|
||||
if (env.IsDevelopment())
|
||||
{
|
||||
app.UseDeveloperExceptionPage();
|
||||
}
|
||||
|
||||
if (!env.IsDevelopment())
|
||||
{
|
||||
app.UseHttpsRedirection();
|
||||
}
|
||||
|
||||
app.UseRouting();
|
||||
app.UseAuthorization();
|
||||
|
||||
app.UseEndpoints(endpoints => { endpoints.MapControllers(); });
|
||||
}
|
||||
}
|
||||
}
|
||||
9
EstusShots.Server/appsettings.Development.json
Normal file
9
EstusShots.Server/appsettings.Development.json
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Information",
|
||||
"Microsoft": "Warning",
|
||||
"Microsoft.Hosting.Lifetime": "Information"
|
||||
}
|
||||
}
|
||||
}
|
||||
10
EstusShots.Server/appsettings.json
Normal file
10
EstusShots.Server/appsettings.json
Normal file
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Information",
|
||||
"Microsoft": "Warning",
|
||||
"Microsoft.Hosting.Lifetime": "Information"
|
||||
}
|
||||
},
|
||||
"AllowedHosts": "*"
|
||||
}
|
||||
16
EstusShots.Shared/EstusShots.Shared.csproj
Normal file
16
EstusShots.Shared/EstusShots.Shared.csproj
Normal file
@@ -0,0 +1,16 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netcoreapp3.1</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
|
||||
<WarningsAsErrors>NU1605;CS8618</WarningsAsErrors>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
|
||||
<WarningsAsErrors>NU1605;CS8618</WarningsAsErrors>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
18
EstusShots.Shared/Models/Season.cs
Normal file
18
EstusShots.Shared/Models/Season.cs
Normal file
@@ -0,0 +1,18 @@
|
||||
using System;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace EstusShots.Shared.Models
|
||||
{
|
||||
public class Season
|
||||
{
|
||||
public Guid SeasonId { get; set; }
|
||||
|
||||
[MaxLength(50)] public string Game { get; set; } = default!;
|
||||
|
||||
public string? Description { get; set; }
|
||||
|
||||
public DateTime Start { get; set; }
|
||||
|
||||
public DateTime? End { get; set; }
|
||||
}
|
||||
}
|
||||
28
EstusShots.sln
Normal file
28
EstusShots.sln
Normal file
@@ -0,0 +1,28 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EstusShots.Server", "EstusShots.Server\EstusShots.Server.csproj", "{E5D0D7FB-5F7C-43E8-88F5-15DD60104AE9}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EstusShots.Shared", "EstusShots.Shared\EstusShots.Shared.csproj", "{1E26150D-ADFE-41ED-9896-941B486E8777}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EstusShots.Gtk", "EstusShots.Gtk\EstusShots.Gtk.csproj", "{165F3B5C-9802-46C5-BCE2-F40C42819045}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{E5D0D7FB-5F7C-43E8-88F5-15DD60104AE9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{E5D0D7FB-5F7C-43E8-88F5-15DD60104AE9}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{E5D0D7FB-5F7C-43E8-88F5-15DD60104AE9}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{E5D0D7FB-5F7C-43E8-88F5-15DD60104AE9}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{1E26150D-ADFE-41ED-9896-941B486E8777}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{1E26150D-ADFE-41ED-9896-941B486E8777}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{1E26150D-ADFE-41ED-9896-941B486E8777}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{1E26150D-ADFE-41ED-9896-941B486E8777}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{165F3B5C-9802-46C5-BCE2-F40C42819045}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{165F3B5C-9802-46C5-BCE2-F40C42819045}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{165F3B5C-9802-46C5-BCE2-F40C42819045}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{165F3B5C-9802-46C5-BCE2-F40C42819045}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
Reference in New Issue
Block a user