first commit

main
vladzvx 2024-08-05 03:22:49 +03:00
commit 5a060b0afe
116 changed files with 3703 additions and 0 deletions

30
.dockerignore Normal file
View File

@ -0,0 +1,30 @@
**/.classpath
**/.dockerignore
**/.env
**/.git
**/.gitignore
**/.project
**/.settings
**/.toolstarget
**/.vs
**/.vscode
**/*.*proj.user
**/*.dbmdl
**/*.jfm
**/azds.yaml
**/bin
**/charts
**/docker-compose*
**/Dockerfile*
**/node_modules
**/npm-debug.log
**/obj
**/secrets.dev.yaml
**/values.dev.yaml
LICENSE
README.md
!**/.gitignore
!.git/HEAD
!.git/config
!.git/packed-refs
!.git/refs/heads/**

279
.gitignore vendored Normal file
View File

@ -0,0 +1,279 @@
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
# User-specific files
*.suo
*.user
*.userosscache
*.sln.docstates
*.yaml
# User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs
# Build results
[Dd]ebug/
[Dd]ebugPublic/
[Rr]elease/
[Rr]eleases/
x64/
x86/
env/
bld/
[Bb]in/
[Oo]bj/
[Ll]og/
output/
[Pp]roperties/
# Visual Studio 2015 cache/options directory
.vs/
# Uncomment if you have tasks that create the project's static files in wwwroot
#wwwroot/
# MSTest test Results
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*
# NUNIT
*.VisualState.xml
TestResult.xml
# Build Results of an ATL Project
[Dd]ebugPS/
[Rr]eleasePS/
dlldata.c
# DNX
project.lock.json
project.fragment.lock.json
artifacts/
[Log]log*
*_i.c
*_p.c
*_i.h
*.ilk
*.meta
*.obj
*.pch
*.pdb
*.pgc
*.pgd
*.rsp
*.sbr
*.tlb
*.tli
*.tlh
*.tmp
*.tmp_proj
*.log
*.vspscc
*.vssscc
.builds
*.pidb
*.svclog
*.scc
# Chutzpah Test files
_Chutzpah*
# Visual C++ cache files
ipch/
*.aps
*.ncb
*.opendb
*.opensdf
*.sdf
*.cachefile
*.VC.db
*.VC.VC.opendb
# Visual Studio profiler
*.psess
*.vsp
*.vspx
*.sap
# TFS 2012 Local Workspace
$tf/
# Guidance Automation Toolkit
*.gpState
# ReSharper is a .NET coding add-in
_ReSharper*/
*.[Rr]e[Ss]harper
*.DotSettings.user
# JustCode is a .NET coding add-in
.JustCode
# TeamCity is a build add-in
_TeamCity*
# DotCover is a Code Coverage Tool
*.dotCover
# NCrunch
_NCrunch_*
.*crunch*.local.xml
nCrunchTemp_*
# MightyMoose
*.mm.*
AutoTest.Net/
# Web workbench (sass)
.sass-cache/
# Installshield output folder
[Ee]xpress/
# DocProject is a documentation generator add-in
DocProject/buildhelp/
DocProject/Help/*.HxT
DocProject/Help/*.HxC
DocProject/Help/*.hhc
DocProject/Help/*.hhk
DocProject/Help/*.hhp
DocProject/Help/Html2
DocProject/Help/html
# Click-Once directory
publish/
# Publish Web Output
*.[Pp]ublish.xml
*.azurePubxml
# TODO: Comment the next line if you want to checkin your web deploy settings
# but database connection strings (with potential passwords) will be unencrypted
#*.pubxml
*.publishproj
*.pwd
*.env
# Microsoft Azure Web App publish settings. Comment the next line if you want to
# checkin your Azure Web App publish settings, but sensitive information contained
# in these scripts will be unencrypted
PublishScripts/
# NuGet Packages
*.nupkg
# The packages folder can be ignored because of Package Restore
**/packages/*
# except build/, which is used as an MSBuild target.
!**/packages/build/
# Uncomment if necessary however generally it will be regenerated when needed
#!**/packages/repositories.config
# NuGet v3's project.json files produces more ignoreable files
*.nuget.props
*.nuget.targets
# Microsoft Azure Build Output
csx/
*.build.csdef
# Microsoft Azure Emulator
ecf/
rcf/
# Windows Store app package directories and files
AppPackages/
BundleArtifacts/
Package.StoreAssociation.xml
_pkginfo.txt
# Visual Studio cache files
# files ending in .cache can be ignored
*.[Cc]ache
# but keep track of directories ending in .cache
!*.[Cc]ache/
# Others
ClientBin/
~$*
*~
*.dbmdl
*.dbproj.schemaview
*.jfm
*.pfx
*.publishsettings
node_modules/
orleans.codegen.cs
# Since there are multiple workflows, uncomment next line to ignore bower_components
# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
#bower_components/
# RIA/Silverlight projects
Generated_Code/
# Backup & report files from converting an old project file
# to a newer Visual Studio version. Backup files are not needed,
# because we have git ;-)
_UpgradeReport_Files/
Backup*/
UpgradeLog*.XML
UpgradeLog*.htm
# SQL Server files
*.mdf
*.ldf
# Business Intelligence projects
*.rdl.data
*.bim.layout
*.bim_*.settings
# Microsoft Fakes
FakesAssemblies/
# GhostDoc plugin setting file
*.GhostDoc.xml
# Node.js Tools for Visual Studio
.ntvs_analysis.dat
# Visual Studio 6 build log
*.plg
# Visual Studio 6 workspace options file
*.opt
# Visual Studio LightSwitch build output
**/*.HTMLClient/GeneratedArtifacts
**/*.DesktopClient/GeneratedArtifacts
**/*.DesktopClient/ModelManifest.xml
**/*.Server/GeneratedArtifacts
**/*.Server/ModelManifest.xml
_Pvt_Extensions
# Paket dependency manager
.paket/paket.exe
paket-files/
# FAKE - F# Make
.fake/
# JetBrains Rider
.idea/
*.sln.iml
# CodeRush
.cr/
# Python Tools for Visual Studio (PTVS)
__pycache__/
*.pyc
#deploy
deploy*.bat
.github
docker-compose-env/
*.env
.vs
.vscode

454
BGC.Client/.gitignore vendored Normal file
View File

@ -0,0 +1,454 @@
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
##
## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
# User-specific files
*.rsuser
*.suo
*.user
*.userosscache
*.sln.docstates
# User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs
# Mono auto generated files
mono_crash.*
# Build results
[Dd]ebug/
[Dd]ebugPublic/
[Rr]elease/
[Rr]eleases/
x64/
x86/
[Ww][Ii][Nn]32/
[Aa][Rr][Mm]/
[Aa][Rr][Mm]64/
bld/
[Bb]in/
[Oo]bj/
[Ll]og/
[Ll]ogs/
# Visual Studio 2015/2017 cache/options directory
.vs/
# Uncomment if you have tasks that create the project's static files in wwwroot
#wwwroot/
# Visual Studio 2017 auto generated files
Generated\ Files/
# MSTest test Results
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*
# NUnit
*.VisualState.xml
TestResult.xml
nunit-*.xml
# Build Results of an ATL Project
[Dd]ebugPS/
[Rr]eleasePS/
dlldata.c
# Benchmark Results
BenchmarkDotNet.Artifacts/
# .NET Core
project.lock.json
project.fragment.lock.json
artifacts/
# Tye
.tye/
# ASP.NET Scaffolding
ScaffoldingReadMe.txt
# StyleCop
StyleCopReport.xml
# Files built by Visual Studio
*_i.c
*_p.c
*_h.h
*.ilk
*.meta
*.obj
*.iobj
*.pch
*.pdb
*.ipdb
*.pgc
*.pgd
*.rsp
*.sbr
*.tlb
*.tli
*.tlh
*.tmp
*.tmp_proj
*_wpftmp.csproj
*.log
*.vspscc
*.vssscc
.builds
*.pidb
*.svclog
*.scc
# Chutzpah Test files
_Chutzpah*
# Visual C++ cache files
ipch/
*.aps
*.ncb
*.opendb
*.opensdf
*.sdf
*.cachefile
*.VC.db
*.VC.VC.opendb
# Visual Studio profiler
*.psess
*.vsp
*.vspx
*.sap
# Visual Studio Trace Files
*.e2e
# TFS 2012 Local Workspace
$tf/
# Guidance Automation Toolkit
*.gpState
# ReSharper is a .NET coding add-in
_ReSharper*/
*.[Rr]e[Ss]harper
*.DotSettings.user
# TeamCity is a build add-in
_TeamCity*
# DotCover is a Code Coverage Tool
*.dotCover
# AxoCover is a Code Coverage Tool
.axoCover/*
!.axoCover/settings.json
# Coverlet is a free, cross platform Code Coverage Tool
coverage*.json
coverage*.xml
coverage*.info
# Visual Studio code coverage results
*.coverage
*.coveragexml
# NCrunch
_NCrunch_*
.*crunch*.local.xml
nCrunchTemp_*
# MightyMoose
*.mm.*
AutoTest.Net/
# Web workbench (sass)
.sass-cache/
# Installshield output folder
[Ee]xpress/
# DocProject is a documentation generator add-in
DocProject/buildhelp/
DocProject/Help/*.HxT
DocProject/Help/*.HxC
DocProject/Help/*.hhc
DocProject/Help/*.hhk
DocProject/Help/*.hhp
DocProject/Help/Html2
DocProject/Help/html
# Click-Once directory
publish/
# Publish Web Output
*.[Pp]ublish.xml
*.azurePubxml
# Note: Comment the next line if you want to checkin your web deploy settings,
# but database connection strings (with potential passwords) will be unencrypted
*.pubxml
*.publishproj
# Microsoft Azure Web App publish settings. Comment the next line if you want to
# checkin your Azure Web App publish settings, but sensitive information contained
# in these scripts will be unencrypted
PublishScripts/
# NuGet Packages
*.nupkg
# NuGet Symbol Packages
*.snupkg
# The packages folder can be ignored because of Package Restore
**/[Pp]ackages/*
# except build/, which is used as an MSBuild target.
!**/[Pp]ackages/build/
# Uncomment if necessary however generally it will be regenerated when needed
#!**/[Pp]ackages/repositories.config
# NuGet v3's project.json files produces more ignorable files
*.nuget.props
*.nuget.targets
# Microsoft Azure Build Output
csx/
*.build.csdef
# Microsoft Azure Emulator
ecf/
rcf/
# Windows Store app package directories and files
AppPackages/
BundleArtifacts/
Package.StoreAssociation.xml
_pkginfo.txt
*.appx
*.appxbundle
*.appxupload
# Visual Studio cache files
# files ending in .cache can be ignored
*.[Cc]ache
# but keep track of directories ending in .cache
!?*.[Cc]ache/
# Others
ClientBin/
~$*
*~
*.dbmdl
*.dbproj.schemaview
*.jfm
*.pfx
*.publishsettings
orleans.codegen.cs
# Including strong name files can present a security risk
# (https://github.com/github/gitignore/pull/2483#issue-259490424)
#*.snk
# Since there are multiple workflows, uncomment next line to ignore bower_components
# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
#bower_components/
# RIA/Silverlight projects
Generated_Code/
# Backup & report files from converting an old project file
# to a newer Visual Studio version. Backup files are not needed,
# because we have git ;-)
_UpgradeReport_Files/
Backup*/
UpgradeLog*.XML
UpgradeLog*.htm
ServiceFabricBackup/
*.rptproj.bak
# SQL Server files
*.mdf
*.ldf
*.ndf
# Business Intelligence projects
*.rdl.data
*.bim.layout
*.bim_*.settings
*.rptproj.rsuser
*- [Bb]ackup.rdl
*- [Bb]ackup ([0-9]).rdl
*- [Bb]ackup ([0-9][0-9]).rdl
# Microsoft Fakes
FakesAssemblies/
# GhostDoc plugin setting file
*.GhostDoc.xml
# Node.js Tools for Visual Studio
.ntvs_analysis.dat
node_modules/
# Visual Studio 6 build log
*.plg
# Visual Studio 6 workspace options file
*.opt
# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
*.vbw
# Visual Studio LightSwitch build output
**/*.HTMLClient/GeneratedArtifacts
**/*.DesktopClient/GeneratedArtifacts
**/*.DesktopClient/ModelManifest.xml
**/*.Server/GeneratedArtifacts
**/*.Server/ModelManifest.xml
_Pvt_Extensions
# Paket dependency manager
.paket/paket.exe
paket-files/
# FAKE - F# Make
.fake/
# CodeRush personal settings
.cr/personal
# Python Tools for Visual Studio (PTVS)
__pycache__/
*.pyc
# Cake - Uncomment if you are using it
# tools/**
# !tools/packages.config
# Tabs Studio
*.tss
# Telerik's JustMock configuration file
*.jmconfig
# BizTalk build output
*.btp.cs
*.btm.cs
*.odx.cs
*.xsd.cs
# OpenCover UI analysis results
OpenCover/
# Azure Stream Analytics local run output
ASALocalRun/
# MSBuild Binary and Structured Log
*.binlog
# NVidia Nsight GPU debugger configuration file
*.nvuser
# MFractors (Xamarin productivity tool) working folder
.mfractor/
# Local History for Visual Studio
.localhistory/
# BeatPulse healthcheck temp database
healthchecksdb
# Backup folder for Package Reference Convert tool in Visual Studio 2017
MigrationBackup/
# Ionide (cross platform F# VS Code tools) working folder
.ionide/
# Fody - auto-generated XML schema
FodyWeavers.xsd
##
## Visual studio for Mac
##
# globs
Makefile.in
*.userprefs
*.usertasks
config.make
config.status
aclocal.m4
install-sh
autom4te.cache/
*.tar.gz
tarballs/
test-results/
# Mac bundle stuff
*.dmg
*.app
# content below from: https://github.com/github/gitignore/blob/master/Global/macOS.gitignore
# General
.DS_Store
.AppleDouble
.LSOverride
# Icon must end with two \r
Icon
# Thumbnails
._*
# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent
# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk
# content below from: https://github.com/github/gitignore/blob/master/Global/Windows.gitignore
# Windows thumbnail cache files
Thumbs.db
ehthumbs.db
ehthumbs_vista.db
# Dump file
*.stackdump
# Folder config file
[Dd]esktop.ini
# Recycle Bin used on file shares
$RECYCLE.BIN/
# Windows Installer files
*.cab
*.msi
*.msix
*.msm
*.msp
# Windows shortcuts
*.lnk
# JetBrains Rider
.idea/
*.sln.iml
##
## Visual Studio Code
##
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json

View File

@ -0,0 +1,28 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0-android</TargetFramework>
<SupportedOSPlatformVersion>21</SupportedOSPlatformVersion>
<Nullable>enable</Nullable>
<ApplicationId>com.CompanyName.BGC.Client</ApplicationId>
<ApplicationVersion>1</ApplicationVersion>
<ApplicationDisplayVersion>1.0</ApplicationDisplayVersion>
<AndroidPackageFormat>apk</AndroidPackageFormat>
<AndroidEnableProfiledAot>False</AndroidEnableProfiledAot>
</PropertyGroup>
<ItemGroup>
<AndroidResource Include="Icon.png">
<Link>Resources\drawable\Icon.png</Link>
</AndroidResource>
</ItemGroup>
<ItemGroup>
<PackageReference Include="Avalonia.Android" Version="$(AvaloniaVersion)" />
<PackageReference Include="Xamarin.AndroidX.Core.SplashScreen" Version="1.0.1.1" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\BGC.Client\BGC.Client.csproj" />
</ItemGroup>
</Project>

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

View File

@ -0,0 +1,24 @@
using Android.App;
using Android.Content.PM;
using Avalonia;
using Avalonia.Android;
using Avalonia.ReactiveUI;
namespace BGC.Client.Android
{
[Activity(
Label = "BGC.Client.Android",
Theme = "@style/MyTheme.NoActionBar",
Icon = "@drawable/icon",
MainLauncher = true,
ConfigurationChanges = ConfigChanges.Orientation | ConfigChanges.ScreenSize | ConfigChanges.UiMode)]
public class MainActivity : AvaloniaMainActivity<App>
{
protected override AppBuilder CustomizeAppBuilder(AppBuilder builder)
{
return base.CustomizeAppBuilder(builder)
.WithInterFont()
.UseReactiveUI();
}
}
}

View File

@ -0,0 +1,44 @@
Images, layout descriptions, binary blobs and string dictionaries can be included
in your application as resource files. Various Android APIs are designed to
operate on the resource IDs instead of dealing with images, strings or binary blobs
directly.
For example, a sample Android app that contains a user interface layout (main.axml),
an internationalization string table (strings.xml) and some icons (drawable-XXX/icon.png)
would keep its resources in the "Resources" directory of the application:
Resources/
drawable/
icon.png
layout/
main.axml
values/
strings.xml
In order to get the build system to recognize Android resources, set the build action to
"AndroidResource". The native Android APIs do not operate directly with filenames, but
instead operate on resource IDs. When you compile an Android application that uses resources,
the build system will package the resources for distribution and generate a class called "R"
(this is an Android convention) that contains the tokens for each one of the resources
included. For example, for the above Resources layout, this is what the R class would expose:
public class R {
public class drawable {
public const int icon = 0x123;
}
public class layout {
public const int main = 0x456;
}
public class strings {
public const int first_string = 0xabc;
public const int second_string = 0xbcd;
}
}
You would then use R.drawable.icon to reference the drawable/icon.png file, or R.layout.main
to reference the layout/main.axml file, or R.strings.first_string to reference the first
string in the dictionary file values/strings.xml.

View File

@ -0,0 +1,66 @@
<animated-vector
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:aapt="http://schemas.android.com/aapt">
<aapt:attr name="android:drawable">
<vector
android:name="vector"
android:width="128dp"
android:height="128dp"
android:viewportWidth="128"
android:viewportHeight="128">
<group
android:name="wrapper"
android:translateX="21"
android:translateY="21">
<group android:name="group">
<path
android:name="path"
android:pathData="M 74.853 85.823 L 75.368 85.823 C 80.735 85.823 85.144 81.803 85.761 76.602 L 85.836 41.76 C 85.225 18.593 66.254 0 42.939 0 C 19.24 0 0.028 19.212 0.028 42.912 C 0.028 66.357 18.831 85.418 42.18 85.823 L 74.853 85.823 Z"
android:strokeWidth="1"/>
<path
android:name="path_1"
android:pathData="M 43.059 14.614 C 29.551 14.614 18.256 24.082 15.445 36.743 C 18.136 37.498 20.109 39.968 20.109 42.899 C 20.109 45.831 18.136 48.301 15.445 49.055 C 18.256 61.716 29.551 71.184 43.059 71.184 C 47.975 71.184 52.599 69.93 56.628 67.723 L 56.628 70.993 L 71.344 70.993 L 71.344 44.072 C 71.357 43.714 71.344 43.26 71.344 42.899 C 71.344 27.278 58.68 14.614 43.059 14.614 Z M 29.51 42.899 C 29.51 35.416 35.576 29.35 43.059 29.35 C 50.541 29.35 56.607 35.416 56.607 42.899 C 56.607 50.382 50.541 56.448 43.059 56.448 C 35.576 56.448 29.51 50.382 29.51 42.899 Z"
android:strokeWidth="1"
android:fillType="evenOdd"/>
<path
android:name="path_2"
android:pathData="M 18.105 42.88 C 18.105 45.38 16.078 47.407 13.579 47.407 C 11.079 47.407 9.052 45.38 9.052 42.88 C 9.052 40.381 11.079 38.354 13.579 38.354 C 16.078 38.354 18.105 40.381 18.105 42.88 Z"
android:strokeWidth="1"/>
</group>
</group>
</vector>
</aapt:attr>
<target android:name="path">
<aapt:attr name="android:animation">
<objectAnimator
android:propertyName="fillColor"
android:duration="1000"
android:valueFrom="#00ffffff"
android:valueTo="#161c2d"
android:valueType="colorType"
android:interpolator="@android:interpolator/fast_out_slow_in"/>
</aapt:attr>
</target>
<target android:name="path_1">
<aapt:attr name="android:animation">
<objectAnimator
android:propertyName="fillColor"
android:duration="1000"
android:valueFrom="#00ffffff"
android:valueTo="#f9f9fb"
android:valueType="colorType"
android:interpolator="@android:interpolator/fast_out_slow_in"/>
</aapt:attr>
</target>
<target android:name="path_2">
<aapt:attr name="android:animation">
<objectAnimator
android:propertyName="fillColor"
android:duration="1000"
android:valueFrom="#00ffffff"
android:valueTo="#f9f9fb"
android:valueType="colorType"
android:interpolator="@android:interpolator/fast_out_slow_in"/>
</aapt:attr>
</target>
</animated-vector>

View File

@ -0,0 +1,71 @@
<animated-vector
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:aapt="http://schemas.android.com/aapt">
<aapt:attr name="android:drawable">
<vector
android:name="vector"
android:width="128dp"
android:height="128dp"
android:viewportWidth="128"
android:viewportHeight="128">
<group
android:name="wrapper"
android:translateX="21"
android:translateY="21">
<group android:name="group">
<path
android:name="path"
android:pathData="M 74.853 85.823 L 75.368 85.823 C 80.735 85.823 85.144 81.803 85.761 76.602 L 85.836 41.76 C 85.225 18.593 66.254 0 42.939 0 C 19.24 0 0.028 19.212 0.028 42.912 C 0.028 66.357 18.831 85.418 42.18 85.823 L 74.853 85.823 Z"
android:fillColor="#00ffffff"
android:strokeWidth="1"/>
<path
android:name="path_1"
android:pathData="M 43.059 14.614 C 29.551 14.614 18.256 24.082 15.445 36.743 C 18.136 37.498 20.109 39.968 20.109 42.899 C 20.109 45.831 18.136 48.301 15.445 49.055 C 18.256 61.716 29.551 71.184 43.059 71.184 C 47.975 71.184 52.599 69.93 56.628 67.723 L 56.628 70.993 L 71.344 70.993 L 71.344 44.072 C 71.357 43.714 71.344 43.26 71.344 42.899 C 71.344 27.278 58.68 14.614 43.059 14.614 Z M 29.51 42.899 C 29.51 35.416 35.576 29.35 43.059 29.35 C 50.541 29.35 56.607 35.416 56.607 42.899 C 56.607 50.382 50.541 56.448 43.059 56.448 C 35.576 56.448 29.51 50.382 29.51 42.899 Z"
android:fillColor="#00ffffff"
android:strokeWidth="1"
android:fillType="evenOdd"/>
<path
android:name="path_2"
android:pathData="M 18.105 42.88 C 18.105 45.38 16.078 47.407 13.579 47.407 C 11.079 47.407 9.052 45.38 9.052 42.88 C 9.052 40.381 11.079 38.354 13.579 38.354 C 16.078 38.354 18.105 40.381 18.105 42.88 Z"
android:fillColor="#00ffffff"
android:strokeWidth="1"/>
</group>
</group>
</vector>
</aapt:attr>
<target android:name="path_2">
<aapt:attr name="android:animation">
<objectAnimator
android:propertyName="fillColor"
android:startOffset="100"
android:duration="900"
android:valueFrom="#00ffffff"
android:valueTo="#161c2d"
android:valueType="colorType"
android:interpolator="@android:interpolator/fast_out_slow_in"/>
</aapt:attr>
</target>
<target android:name="path">
<aapt:attr name="android:animation">
<objectAnimator
android:propertyName="fillColor"
android:duration="500"
android:valueFrom="#00ffffff"
android:valueTo="#f9f9fb"
android:valueType="colorType"
android:interpolator="@android:interpolator/fast_out_slow_in"/>
</aapt:attr>
</target>
<target android:name="path_1">
<aapt:attr name="android:animation">
<objectAnimator
android:propertyName="fillColor"
android:startOffset="100"
android:duration="900"
android:valueFrom="#00ffffff"
android:valueTo="#161c2d"
android:valueType="colorType"
android:interpolator="@android:interpolator/fast_out_slow_in"/>
</aapt:attr>
</target>
</animated-vector>

View File

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<color android:color="@color/splash_background"/>
</item>
<item android:drawable="@drawable/icon"
android:width="120dp"
android:height="120dp"
android:gravity="center" />
</layer-list>

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="splash_background">#212121</color>
</resources>

View File

@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8" ?>
<resources>
<style name="MyTheme">
</style>
<style name="MyTheme.NoActionBar" parent="@style/Theme.AppCompat.NoActionBar">
<item name="android:windowActionBar">false</item>
<item name="android:windowBackground">@null</item>
<item name="android:windowNoTitle">true</item>
<item name="android:windowSplashScreenBackground">@color/splash_background</item>
<item name="android:windowSplashScreenAnimatedIcon">@drawable/avalonia_anim</item>
<item name="android:windowSplashScreenAnimationDuration">1000</item>
<item name="postSplashScreenTheme">@style/MyTheme.Main</item>
</style>
<style name="MyTheme.Main"
parent ="MyTheme.NoActionBar">
<item name="android:windowIsTranslucent">true</item>
</style>
</resources>

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="splash_background">#FFFFFF</color>
</resources>

View File

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8" ?>
<resources>
<style name="MyTheme">
</style>
<style name="MyTheme.NoActionBar" parent="@style/Theme.AppCompat.DayNight.NoActionBar">
<item name="android:windowActionBar">false</item>
<item name="android:windowBackground">@drawable/splash_screen</item>
<item name="android:windowNoTitle">true</item>
</style>
</resources>

View File

@ -0,0 +1,5 @@
<svg width="35" height="35" viewBox="0 0 35 35" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M30.4661 34.928C30.5364 34.928 30.6052 34.928 30.6754 34.928C32.8596 34.928 34.654 33.2918 34.9053 31.1752L34.9356 16.9955C34.6872 7.56697 26.9662 0 17.4777 0C7.83263 0 0.0137329 7.8189 0.0137329 17.464C0.0137329 27.0059 7.66618 34.7631 17.1687 34.928H30.4661Z" fill="white"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M17.5239 5.948C12.0268 5.948 7.42967 9.80117 6.286 14.954C7.38092 15.2609 8.18385 16.2664 8.18385 17.4593C8.18385 18.6523 7.38092 19.6577 6.286 19.9647C7.42966 25.1175 12.0268 28.9706 17.5239 28.9706C19.525 28.9706 21.4068 28.4601 23.0462 27.562V28.8927H29.0352V17.9365C29.0407 17.7908 29.0352 17.6063 29.0352 17.4593C29.0352 11.1018 23.8814 5.948 17.5239 5.948ZM12.0098 17.4593C12.0098 14.414 14.4786 11.9452 17.5239 11.9452C20.5693 11.9452 23.038 14.414 23.038 17.4593C23.038 20.5047 20.5693 22.9734 17.5239 22.9734C14.4786 22.9734 12.0098 20.5047 12.0098 17.4593Z" fill="#8B44AC"/>
<path d="M7.36841 17.4517C7.36841 18.4691 6.54368 19.2938 5.52631 19.2938C4.50894 19.2938 3.6842 18.4691 3.6842 17.4517C3.6842 16.4343 4.50894 15.6096 5.52631 15.6096C6.54368 15.6096 7.36841 16.4343 7.36841 17.4517Z" fill="#8B44AC"/>
</svg>

After

Width:  |  Height:  |  Size: 1.2 KiB

View File

@ -0,0 +1,74 @@
:root {
--sat: env(safe-area-inset-top);
--sar: env(safe-area-inset-right);
--sab: env(safe-area-inset-bottom);
--sal: env(safe-area-inset-left);
}
/* HTML styles for the splash screen */
.highlight {
color: white;
font-size: 2.5rem;
display: block;
}
.purple {
color: #8b44ac;
}
.icon {
opacity: 0.05;
height: 35%;
width: 35%;
position: absolute;
background-repeat: no-repeat;
right: 0px;
bottom: 0px;
margin-right: 3%;
margin-bottom: 5%;
z-index: 5000;
background-position: right bottom;
pointer-events: none;
}
#avalonia-splash a {
color: whitesmoke;
text-decoration: none;
}
.center {
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
}
#avalonia-splash {
position: relative;
height: 100%;
width: 100%;
color: whitesmoke;
background: #1b2a4e;
font-family: 'Nunito', sans-serif;
background-position: center;
background-size: cover;
background-repeat: no-repeat;
justify-content: center;
align-items: center;
}
.splash-close {
animation: fadeout 0.25s linear forwards;
}
@keyframes fadeout {
0% {
opacity: 100%;
}
100% {
opacity: 0;
visibility: collapse;
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 172 KiB

View File

@ -0,0 +1,30 @@
<!DOCTYPE html>
<html>
<head>
<title>BGC.Client.Browser</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<base href="/" />
<link rel="modulepreload" href="./main.js" />
<link rel="modulepreload" href="./dotnet.js" />
<link rel="modulepreload" href="./avalonia.js" />
<link rel="stylesheet" href="./app.css" />
</head>
<body style="margin: 0px; overflow: hidden">
<div id="out">
<div id="avalonia-splash">
<div class="center">
<h2 class="purple">
Powered by
<a class="highlight" href="https://www.avaloniaui.net/" target="_blank">Avalonia UI</a>
</h2>
</div>
<img class="icon" src="Logo.svg" alt="Avalonia Logo" />
</div>
</div>
<script type='module' src="./main.js"></script>
</body>
</html>

View File

@ -0,0 +1,13 @@
import { dotnet } from './dotnet.js'
const is_browser = typeof window != "undefined";
if (!is_browser) throw new Error(`Expected to be running in a browser`);
const dotnetRuntime = await dotnet
.withDiagnosticTracing(false)
.withApplicationArgumentsFromQuery()
.create();
const config = dotnetRuntime.getConfig();
await dotnetRuntime.runMain(config.mainAssemblyName, [window.location.search]);

View File

@ -0,0 +1,20 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<RuntimeIdentifier>browser-wasm</RuntimeIdentifier>
<WasmMainJSPath>AppBundle\main.js</WasmMainJSPath>
<OutputType>Exe</OutputType>
</PropertyGroup>
<ItemGroup>
<WasmExtraFilesToDeploy Include="AppBundle\**" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Avalonia.Browser" Version="$(AvaloniaVersion)" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\BGC.Client\BGC.Client.csproj" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,21 @@
FROM mcr.microsoft.com/dotnet/runtime:8.0 AS base
USER app
WORKDIR /app
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
WORKDIR /src
RUN dotnet workload install wasm-tools
RUN apt-get update
RUN apt-get install -y python3
COPY . .
RUN dotnet restore "./BGC.Client/BGC.Client.Browser/BGC.Client.Browser.csproj"
WORKDIR "/src/BGC.Client/BGC.Client.Browser"
RUN dotnet build "./BGC.Client.Browser.csproj" -c Release -o /app/build
FROM nginx
COPY --from=build /app/build/AppBundle /usr/share/nginx/html/

View File

@ -0,0 +1,19 @@
using Avalonia;
using Avalonia.Browser;
using Avalonia.ReactiveUI;
using BGC.Client;
using System.Runtime.Versioning;
using System.Threading.Tasks;
[assembly: SupportedOSPlatform("browser")]
internal sealed partial class Program
{
private static Task Main(string[] args) => BuildAvaloniaApp()
.WithInterFont()
.UseReactiveUI()
.StartBrowserAppAsync("out");
public static AppBuilder BuildAvaloniaApp()
=> AppBuilder.Configure<App>();
}

View File

@ -0,0 +1,11 @@
{
"wasmHostProperties": {
"perHostConfig": [
{
"name": "browser",
"html-path": "index.html",
"Host": "browser"
}
]
}
}

View File

@ -0,0 +1,24 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<!--If you are willing to use Windows/MacOS native APIs you will need to create 3 projects.
One for Windows with net8.0-windows TFM, one for MacOS with net8.0-macos and one with net8.0 TFM for Linux.-->
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<BuiltInComInteropSupport>true</BuiltInComInteropSupport>
</PropertyGroup>
<PropertyGroup>
<ApplicationManifest>app.manifest</ApplicationManifest>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Avalonia.Desktop" Version="$(AvaloniaVersion)" />
<!--Condition below is needed to remove Avalonia.Diagnostics package from build output in Release configuration.-->
<PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="$(AvaloniaVersion)" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\BGC.Client\BGC.Client.csproj" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,24 @@
using Avalonia;
using Avalonia.ReactiveUI;
using System;
namespace BGC.Client.Desktop
{
internal sealed class Program
{
// Initialization code. Don't use any Avalonia, third-party APIs or any
// SynchronizationContext-reliant code before AppMain is called: things aren't initialized
// yet and stuff might break.
[STAThread]
public static void Main(string[] args) => BuildAvaloniaApp()
.StartWithClassicDesktopLifetime(args);
// Avalonia configuration, don't remove; also used by visual designer.
public static AppBuilder BuildAvaloniaApp()
=> AppBuilder.Configure<App>()
.UsePlatformDetect()
.WithInterFont()
.LogToTrace()
.UseReactiveUI();
}
}

View File

@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1">
<!-- This manifest is used on Windows only.
Don't remove it as it might cause problems with window transparency and embedded controls.
For more details visit https://learn.microsoft.com/en-us/windows/win32/sbscs/application-manifests -->
<assemblyIdentity version="1.0.0.0" name="BGC.Client.Desktop"/>
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
<application>
<!-- A list of the Windows versions that this application has been tested on
and is designed to work with. Uncomment the appropriate elements
and Windows will automatically select the most compatible environment. -->
<!-- Windows 10 -->
<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}" />
</application>
</compatibility>
</assembly>

View File

@ -0,0 +1,23 @@
using Avalonia;
using Avalonia.iOS;
using Avalonia.ReactiveUI;
using Foundation;
namespace BGC.Client.iOS
{
// The UIApplicationDelegate for the application. This class is responsible for launching the
// User Interface of the application, as well as listening (and optionally responding) to
// application events from iOS.
[Register("AppDelegate")]
#pragma warning disable CA1711 // Identifiers should not have incorrect suffix
public partial class AppDelegate : AvaloniaAppDelegate<App>
#pragma warning restore CA1711 // Identifiers should not have incorrect suffix
{
protected override AppBuilder CustomizeAppBuilder(AppBuilder builder)
{
return base.CustomizeAppBuilder(builder)
.WithInterFont()
.UseReactiveUI();
}
}
}

View File

@ -0,0 +1,16 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0-ios</TargetFramework>
<SupportedOSPlatformVersion>13.0</SupportedOSPlatformVersion>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Avalonia.iOS" Version="$(AvaloniaVersion)" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\BGC.Client\BGC.Client.csproj" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict/>
</plist>

View File

@ -0,0 +1,43 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDisplayName</key>
<string>BGC.Client</string>
<key>CFBundleIdentifier</key>
<string>companyName.BGC.Client</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleVersion</key>
<string>1.0</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>MinimumOSVersion</key>
<string>13.0</string>
<key>UIDeviceFamily</key>
<array>
<integer>1</integer>
<integer>2</integer>
</array>
<key>UILaunchStoryboardName</key>
<string>LaunchScreen</string>
<key>UIRequiredDeviceCapabilities</key>
<array>
<string>armv7</string>
</array>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationPortraitUpsideDown</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>UISupportedInterfaceOrientations~ipad</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationPortraitUpsideDown</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
</dict>
</plist>

View File

@ -0,0 +1,15 @@
using UIKit;
namespace BGC.Client.iOS
{
public class Application
{
// This is the main entry point of the application.
private static void Main(string[] args)
{
// if you want to use a different Application Delegate class from "AppDelegate"
// you can specify it here.
UIApplication.Main(args, null, typeof(AppDelegate));
}
}
}

View File

@ -0,0 +1,43 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="6214" systemVersion="14A314h" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="6207" />
<capability name="Constraints with non-1.0 multipliers" minToolsVersion="5.1" />
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" />
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder" />
<view contentMode="scaleToFill" id="iN0-l3-epB">
<rect key="frame" x="0.0" y="0.0" width="480" height="480" />
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES" />
<subviews>
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text=" Copyright (c) 2022 " textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines"
minimumFontSize="9" translatesAutoresizingMaskIntoConstraints="NO" id="8ie-xW-0ye">
<rect key="frame" x="20" y="439" width="441" height="21" />
<fontDescription key="fontDescription" type="system" pointSize="17" />
<color key="textColor" cocoaTouchSystemColor="darkTextColor" />
<nil key="highlightedColor" />
</label>
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="BGC.Client" textAlignment="center" lineBreakMode="middleTruncation" baselineAdjustment="alignBaselines"
minimumFontSize="18" translatesAutoresizingMaskIntoConstraints="NO" id="kId-c2-rCX">
<rect key="frame" x="20" y="140" width="441" height="43" />
<fontDescription key="fontDescription" type="boldSystem" pointSize="36" />
<color key="textColor" cocoaTouchSystemColor="darkTextColor" />
<nil key="highlightedColor" />
</label>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite" />
<constraints>
<constraint firstItem="kId-c2-rCX" firstAttribute="centerY" secondItem="iN0-l3-epB" secondAttribute="bottom" multiplier="1/3" constant="1" id="5cJ-9S-tgC" />
<constraint firstAttribute="centerX" secondItem="kId-c2-rCX" secondAttribute="centerX" id="Koa-jz-hwk" />
<constraint firstAttribute="bottom" secondItem="8ie-xW-0ye" secondAttribute="bottom" constant="20" id="Kzo-t9-V3l" />
<constraint firstItem="8ie-xW-0ye" firstAttribute="leading" secondItem="iN0-l3-epB" secondAttribute="leading" constant="20" symbolic="YES" id="MfP-vx-nX0" />
<constraint firstAttribute="centerX" secondItem="8ie-xW-0ye" secondAttribute="centerX" id="ZEH-qu-HZ9" />
<constraint firstItem="kId-c2-rCX" firstAttribute="leading" secondItem="iN0-l3-epB" secondAttribute="leading" constant="20" symbolic="YES" id="fvb-Df-36g" />
</constraints>
<nil key="simulatedStatusBarMetrics" />
<freeformSimulatedSizeMetrics key="simulatedDestinationMetrics" />
<point key="canvasLocation" x="548" y="455" />
</view>
</objects>
</document>

54
BGC.Client/BGC.Client.sln Normal file
View File

@ -0,0 +1,54 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.3.32811.315
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BGC.Client", "BGC.Client\BGC.Client.csproj", "{EBFA8512-1EA5-4D8C-B4AC-AB5B48A6D568}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BGC.Client.Desktop", "BGC.Client.Desktop\BGC.Client.Desktop.csproj", "{ABC31E74-02FF-46EB-B3B2-4E6AE43B456C}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BGC.Client.Browser", "BGC.Client.Browser\BGC.Client.Browser.csproj", "{1C1A049E-235C-4CD0-B6FA-D53AC418F4DA}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BGC.Client.iOS", "BGC.Client.iOS\BGC.Client.iOS.csproj", "{EBD9022F-BC83-4846-9A11-6F7F3772DC64}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BGC.Client.Android", "BGC.Client.Android\BGC.Client.Android.csproj", "{7AD1DAC8-7FBE-49D5-8614-7321233DB82E}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{3DA99C4E-89E3-4049-9C22-0A7EC60D83D8}"
ProjectSection(SolutionItems) = preProject
Directory.Build.props = Directory.Build.props
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{EBFA8512-1EA5-4D8C-B4AC-AB5B48A6D568}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{EBFA8512-1EA5-4D8C-B4AC-AB5B48A6D568}.Debug|Any CPU.Build.0 = Debug|Any CPU
{EBFA8512-1EA5-4D8C-B4AC-AB5B48A6D568}.Release|Any CPU.ActiveCfg = Release|Any CPU
{EBFA8512-1EA5-4D8C-B4AC-AB5B48A6D568}.Release|Any CPU.Build.0 = Release|Any CPU
{ABC31E74-02FF-46EB-B3B2-4E6AE43B456C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{ABC31E74-02FF-46EB-B3B2-4E6AE43B456C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{ABC31E74-02FF-46EB-B3B2-4E6AE43B456C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{ABC31E74-02FF-46EB-B3B2-4E6AE43B456C}.Release|Any CPU.Build.0 = Release|Any CPU
{1C1A049E-235C-4CD0-B6FA-D53AC418F4DA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1C1A049E-235C-4CD0-B6FA-D53AC418F4DA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1C1A049E-235C-4CD0-B6FA-D53AC418F4DA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1C1A049E-235C-4CD0-B6FA-D53AC418F4DA}.Release|Any CPU.Build.0 = Release|Any CPU
{EBD9022F-BC83-4846-9A11-6F7F3772DC64}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{EBD9022F-BC83-4846-9A11-6F7F3772DC64}.Debug|Any CPU.Build.0 = Debug|Any CPU
{EBD9022F-BC83-4846-9A11-6F7F3772DC64}.Release|Any CPU.ActiveCfg = Release|Any CPU
{EBD9022F-BC83-4846-9A11-6F7F3772DC64}.Release|Any CPU.Build.0 = Release|Any CPU
{7AD1DAC8-7FBE-49D5-8614-7321233DB82E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7AD1DAC8-7FBE-49D5-8614-7321233DB82E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7AD1DAC8-7FBE-49D5-8614-7321233DB82E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7AD1DAC8-7FBE-49D5-8614-7321233DB82E}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {83CB65B8-011F-4ED7-BCD3-A6CFA935EF7E}
EndGlobalSection
EndGlobal

View File

@ -0,0 +1,16 @@
<Application xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:BGC.Client"
x:Class="BGC.Client.App"
RequestedThemeVariant="Default">
<!-- "Default" ThemeVariant follows system theme variant. "Dark" or "Light" are other available options. -->
<Application.DataTemplates>
<local:ViewLocator/>
</Application.DataTemplates>
<Application.Styles>
<FluentTheme />
<StyleInclude Source="avares://Avalonia.Controls.DataGrid/Themes/Fluent.xaml"/>
</Application.Styles>
</Application>

View File

@ -0,0 +1,36 @@
using Avalonia;
using Avalonia.Controls.ApplicationLifetimes;
using Avalonia.Markup.Xaml;
using BGC.Client.ViewModels;
using BGC.Client.Views;
namespace BGC.Client
{
public partial class App : Application
{
public override void Initialize()
{
AvaloniaXamlLoader.Load(this);
}
public override void OnFrameworkInitializationCompleted()
{
if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
{
desktop.MainWindow = new MainWindow
{
DataContext = new MainViewModel()
};
}
else if (ApplicationLifetime is ISingleViewApplicationLifetime singleViewPlatform)
{
singleViewPlatform.MainView = new MainView
{
DataContext = new MainViewModel()
};
}
base.OnFrameworkInitializationCompleted();
}
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 172 KiB

View File

@ -0,0 +1,46 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<LangVersion>latest</LangVersion>
<AvaloniaUseCompiledBindingsByDefault>true</AvaloniaUseCompiledBindingsByDefault>
</PropertyGroup>
<ItemGroup>
<AvaloniaResource Include="Assets\**" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Avalonia" Version="$(AvaloniaVersion)" />
<PackageReference Include="Avalonia.Controls.DataGrid" Version="11.0.6" />
<PackageReference Include="Avalonia.Themes.Fluent" Version="$(AvaloniaVersion)" />
<PackageReference Include="Avalonia.Fonts.Inter" Version="$(AvaloniaVersion)" />
<PackageReference Include="Avalonia.ReactiveUI" Version="$(AvaloniaVersion)" />
<!--Condition below is needed to remove Avalonia.Diagnostics package from build output in Release configuration.-->
<PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="$(AvaloniaVersion)" />
</ItemGroup>
<ItemGroup>
<Compile Update="Views\GameBrowsePage2View.axaml.cs">
<DependentUpon>GameBrowsePage2View.axaml</DependentUpon>
</Compile>
<Compile Update="Views\GameBrowsePage1View.axaml.cs">
<DependentUpon>GameBrowsePage1View.axaml</DependentUpon>
</Compile>
<Compile Update="Views\GameBrowserView.axaml.cs">
<DependentUpon>GameBrowserView.axaml</DependentUpon>
</Compile>
<Compile Update="Views\GamesTableView.axaml.cs">
<DependentUpon>GamesTableView.axaml</DependentUpon>
</Compile>
<Compile Update="Views\LoginView.axaml.cs">
<DependentUpon>LoginView.axaml</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\BGC.Common\BGC.Common.csproj" />
</ItemGroup>
<ItemGroup>
<Folder Include="Models\" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,33 @@
using Avalonia.Controls;
using Avalonia.Controls.Templates;
using BGC.Client.ViewModels;
using System;
namespace BGC.Client
{
public class ViewLocator : IDataTemplate
{
public Control? Build(object? data)
{
if (data is null)
{
return null;
}
var name = data.GetType().FullName!.Replace("ViewModel", "View", StringComparison.Ordinal);
var type = Type.GetType(name);
if (type != null)
{
return (Control)Activator.CreateInstance(type)!;
}
return new TextBlock { Text = "Not Found: " + name };
}
public bool Match(object? data)
{
return data is ViewModelBase;
}
}
}

View File

@ -0,0 +1,28 @@
using BGC.Common;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BGC.Client.ViewModels.Common
{
public class GameForTable
{
public string Name => NameRu ?? NameEng;
public string Age => DataConverter.GetAge(AgeMin, AgeMax);
public string Players => DataConverter.GetPlayers(PlayersMin, PlayersMax);
public string Duration => DataConverter.GetDuration(GameDurationMin, GameDurationMax);
public long Id { get; init; }
public string NameRu { get; init; } = string.Empty;
public string NameEng { get; init; } = string.Empty;
public int PlayersMin { get; init; } = 1;
public int? PlayersMax { get; init; }
public int AgeMin { get; init; } = 1;
public int? AgeMax { get; init; }
public TimeSpan? GameDurationMin { get; init; }
public TimeSpan? GameDurationMax { get; init; }
}
}

View File

@ -0,0 +1,18 @@
using System;
namespace BGC.Client.ViewModels.Common
{
public class GameState
{
public long Id { get; set; }
public string NameRu { get; init; } = string.Empty;
public string NameEng { get; init; } = string.Empty;
private DateTime? IssueDate { get; init; }
public int PlayersMin { get; init; } = 1;
public int? PlayersMax { get; init; }
public int AgeMin { get; init; } = 1;
public int? AgeMax { get; init; }
public TimeSpan? GameDurationMin { get; init; }
public TimeSpan? GameDurationMax { get; init; }
}
}

View File

@ -0,0 +1,12 @@
using System;
namespace BGC.Client.ViewModels.Common
{
internal class PointerEventLog
{
public DateTime Timestamp { get; init; } = DateTime.UtcNow;
public PointerEventType EventType { get; init; }
public double X { get; init; }
public double Y { get; init; }
}
}

View File

@ -0,0 +1,10 @@
namespace BGC.Client.ViewModels.Common
{
internal enum PointerEventType
{
Unknown = 0,
Move = 1,
Press = 2,
Release = 4,
}
}

View File

@ -0,0 +1,40 @@
using BGC.Client.ViewModels.Common;
using ReactiveUI;
using System.Windows.Input;
namespace BGC.Client.ViewModels
{
public class GameBrowsePage1ViewModel : GameBrowsePageBaseViewModel
{
public string? Title1 => GameState?.NameRu;
internal override string[] Fields { get; set; } = { "Title1" };
public ICommand Command { get; }
public GameBrowsePage1ViewModel()
{
UpdateState(new GameState()
{
NameRu = "Èãðà ïðåñòîëîâ",
NameEng = "Game of thrones",
Id = 2,
});
Command = ReactiveCommand.Create(Act);
}
private void Act()
{
var old = GameState;
var st = new GameState()
{
Id = old?.Id ?? 1,
NameRu = old?.NameRu + "_",
NameEng = old?.NameEng ?? string.Empty,
};
UpdateState(st);
}
}
}

View File

@ -0,0 +1,9 @@
namespace BGC.Client.ViewModels
{
public class GameBrowsePage2ViewModel : GameBrowsePage1ViewModel
{
public string? Title2 => GameState?.NameEng;
internal override string[] Fields { get; set; } = { "Title2" };
}
}

View File

@ -0,0 +1,22 @@
using BGC.Client.ViewModels.Common;
using ReactiveUI;
using System;
namespace BGC.Client.ViewModels
{
public class GameBrowsePageBaseViewModel : ViewModelBase
{
public GameState? GameState { get; private set; }
public void UpdateState(GameState gameState)
{
GameState = gameState;
foreach (var field in Fields)
{
this.RaisePropertyChanged(field);
}
}
internal virtual string[] Fields { get; set; } = Array.Empty<string>();
}
}

View File

@ -0,0 +1,110 @@
using BGC.Client.ViewModels.Common;
using ReactiveUI;
using System;
using System.Windows.Input;
namespace BGC.Client.ViewModels
{
public class GameBrowserViewModel : ViewModelBase
{
#region static pointer dispatching
private readonly static object _lock = new();
private static PointerEventLog? _pressLog = null;
internal static PointerEventLog? PressLog
{
get
{
lock (_lock)
{
return _pressLog;
}
}
set
{
lock (_lock)
{
_pressLog = value;
}
}
}
private static Action? SetPage1Action;
private static Action? SetPage2Action;
internal static void SetEventLog(PointerEventLog pointerEventLog)
{
if (pointerEventLog.EventType == PointerEventType.Press)
{
PressLog = pointerEventLog;
}
else if (pointerEventLog.EventType == PointerEventType.Release && PressLog != null)
{
var dx = pointerEventLog.X - PressLog.X;
var dt = pointerEventLog.Timestamp - PressLog.Timestamp;
if (dt > TimeSpan.FromSeconds(0.1))
{
try
{
if (dx > 30)
{
//ñâàéï âëåâî
SetPage1Action?.Invoke();
}
if (dx < -30)
{
//ñâàéï âïðàâî
SetPage2Action?.Invoke();
}
}
catch (Exception ex)
{
}
}
}
}
#endregion
private GameBrowsePageBaseViewModel _currentPage;
public ICommand SetPage1Command { get; }
public ICommand SetPage2Command { get; }
private readonly GameBrowsePageBaseViewModel[] _pages = new GameBrowsePageBaseViewModel[2];
public GameBrowserViewModel()
{
_pages[0] = new GameBrowsePage1ViewModel();
_pages[1] = new GameBrowsePage2ViewModel(); ;
_currentPage = _pages[0];
SetPage1Command = ReactiveCommand.Create(SetPage1);
SetPage2Command = ReactiveCommand.Create(SetPage2);
SetPage1Action += SetPage1;
SetPage2Action += SetPage2;
}
public GameBrowsePageBaseViewModel CurrentPage
{
get { return _currentPage; }
private set { this.RaiseAndSetIfChanged(ref _currentPage, value); }
}
private void SetPage1()
{
if (CurrentPage != _pages[0])
{
CurrentPage = _pages[0];
}
}
private void SetPage2()
{
if (CurrentPage != _pages[1])
{
CurrentPage = _pages[1];
}
}
}
}

View File

@ -0,0 +1,25 @@
using BGC.Client.ViewModels.Common;
using ReactiveUI;
using System.Collections.ObjectModel;
using System;
using Avalonia.Controls;
namespace BGC.Client.ViewModels
{
public class GamesTableViewModel : ViewModelBase
{
public ObservableCollection<GameForTable> Games { get;}
public GamesTableViewModel()
{
var gameForTables = new GameForTable[]
{
new GameForTable(){NameRu = "Game1", Id=1},
new GameForTable(){NameRu = "Game2", Id=2},
new GameForTable(){NameRu = "Game3", Id=3}
};
Games = new ObservableCollection<GameForTable>(gameForTables);
}
}
}

View File

@ -0,0 +1,9 @@
using System.Windows.Input;
namespace BGC.Client.ViewModels
{
public class LoginViewModel : ViewModelBase
{
public ICommand LoginCommand { get; init; }
}
}

View File

@ -0,0 +1,40 @@
using ReactiveUI;
using System.Windows.Input;
namespace BGC.Client.ViewModels
{
public class MainViewModel : ViewModelBase
{
private ViewModelBase _currentView;
public ICommand LoginCommand { get; }
private readonly ViewModelBase[] _views = new ViewModelBase[3];
public MainViewModel()
{
LoginCommand = ReactiveCommand.Create(Login);
var login = new LoginViewModel()
{
LoginCommand = LoginCommand,
};
_views[1] = login;
_views[0] = new GamesTableViewModel();
_views[2] = new GameBrowserViewModel();
_currentView = _views[0];
}
public ViewModelBase CurrentScreen
{
get { return _currentView; }
private set { this.RaiseAndSetIfChanged(ref _currentView, value); }
}
private void Login()
{
if (CurrentScreen != _views[1])
{
CurrentScreen = _views[1];
}
}
}
}

View File

@ -0,0 +1,8 @@
using ReactiveUI;
namespace BGC.Client.ViewModels
{
public class ViewModelBase : ReactiveObject
{
}
}

View File

@ -0,0 +1,33 @@
<UserControl xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:vm="clr-namespace:BGC.Client.ViewModels"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="BGC.Client.Views.GameBrowsePage1View"
x:DataType="vm:GameBrowsePage1ViewModel">
<Design.DataContext>
<!-- This only sets the DataContext for the previewer in an IDE,
to set the actual DataContext for runtime, set the DataContext property in code (look at App.axaml.cs) -->
<vm:GameBrowsePage1ViewModel />
</Design.DataContext>
<Grid RowDefinitions="*,Auto" Margin="10" ColumnDefinitions="*,Auto">
<StackPanel Orientation="Vertical">
<Rectangle Fill="Orange" Height="50"/>
<TextBlock VerticalAlignment="Center"
TextAlignment="Center"
FontSize="16"
FontWeight="SemiBold"
Text="{Binding Title1}"
TextWrapping="Wrap" />
<Button Command="{Binding Command}" HorizontalAlignment="Center">Button</Button>
</StackPanel>
<StackPanel Orientation="Horizontal" VerticalAlignment="Bottom" HorizontalAlignment="Center">
<Rectangle Fill="DarkCyan" Height="4" Width="25"></Rectangle>
<Rectangle Fill="LightBlue" Height="4" Width="25"></Rectangle>
</StackPanel>
</Grid>
</UserControl>

View File

@ -0,0 +1,12 @@
using Avalonia.Controls;
namespace BGC.Client.Views
{
public partial class GameBrowsePage1View : UserControl
{
public GameBrowsePage1View()
{
InitializeComponent();
}
}
}

View File

@ -0,0 +1,30 @@
<UserControl xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:vm="clr-namespace:BGC.Client.ViewModels"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="BGC.Client.Views.GameBrowsePage2View"
x:DataType="vm:GameBrowsePage2ViewModel">
<Design.DataContext>
<!-- This only sets the DataContext for the previewer in an IDE,
to set the actual DataContext for runtime, set the DataContext property in code (look at App.axaml.cs) -->
<vm:GameBrowsePage2ViewModel />
</Design.DataContext>
<Grid RowDefinitions="*,Auto" Margin="10" ColumnDefinitions="*,Auto">
<Rectangle Fill="Orange" Height="50"/>
<TextBlock VerticalAlignment="Center"
TextAlignment="Center"
FontSize="16"
FontWeight="SemiBold"
Text="{Binding Title2}"
TextWrapping="Wrap" />
<StackPanel Orientation="Horizontal" VerticalAlignment="Bottom" HorizontalAlignment="Center">
<Rectangle Fill="LightBlue" Height="4" Width="25"></Rectangle>
<Rectangle Fill="DarkCyan" Height="4" Width="25"></Rectangle>
</StackPanel>
</Grid>
</UserControl>

View File

@ -0,0 +1,12 @@
using Avalonia.Controls;
namespace BGC.Client.Views
{
public partial class GameBrowsePage2View : UserControl
{
public GameBrowsePage2View()
{
InitializeComponent();
}
}
}

View File

@ -0,0 +1,18 @@
<UserControl xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:vm="clr-namespace:BGC.Client.ViewModels"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="BGC.Client.Views.GameBrowserView"
x:DataType="vm:GameBrowserViewModel">
<Design.DataContext>
<vm:GameBrowserViewModel />
</Design.DataContext>
<Grid PointerPressed="OnPointerPressed"
PointerReleased="OnPointerReleased"
RowDefinitions="*,Auto" Margin="10" ColumnDefinitions="*,Auto">
<TransitioningContentControl Content="{Binding CurrentPage}" />
</Grid>
</UserControl>

View File

@ -0,0 +1,39 @@
using Avalonia.Controls;
using Avalonia.Input;
using BGC.Client.ViewModels;
namespace BGC.Client.Views
{
public partial class GameBrowserView : UserControl
{
public GameBrowserView()
{
InitializeComponent();
this.PointerPressed += OnPointerPressed;
this.PointerReleased += OnPointerReleased;
}
private void OnPointerPressed(object? sender, PointerPressedEventArgs e)
{
var p = e.GetPosition(null);
GameBrowserViewModel.SetEventLog(new ViewModels.Common.PointerEventLog()
{
EventType = ViewModels.Common.PointerEventType.Press,
X = p.X,
Y = p.Y,
});
}
private void OnPointerReleased(object? sender, PointerReleasedEventArgs e)
{
var p = e.GetPosition(null);
GameBrowserViewModel.SetEventLog(new ViewModels.Common.PointerEventLog()
{
EventType = ViewModels.Common.PointerEventType.Release,
X = p.X,
Y = p.Y,
});
}
}
}

View File

@ -0,0 +1,25 @@
<UserControl xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:vm="clr-namespace:BGC.Client.ViewModels"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="BGC.Client.Views.GamesTableView"
x:DataType="vm:GamesTableViewModel">
<Design.DataContext>
<!-- This only sets the DataContext for the previewer in an IDE,
to set the actual DataContext for runtime, set the DataContext property in code (look at App.axaml.cs) -->
<vm:GamesTableViewModel />
</Design.DataContext>
<DataGrid Margin="20" CellPointerPressed="DataGridCellPointerPressed" ItemsSource="{Binding Games}"
IsReadOnly="True"
GridLinesVisibility="All"
BorderThickness="1" BorderBrush="Gray">
<DataGrid.Columns>
<DataGridTextColumn Header="Название" Binding="{Binding Name}"/>
<DataGridTextColumn Header="Возраст" Binding="{Binding Age}" />
<DataGridTextColumn Header="Кол-во игроков" Binding="{Binding Players}" />
<DataGridTextColumn Header="Длительность" Binding="{Binding Duration}" />
</DataGrid.Columns>
</DataGrid>
</UserControl>

View File

@ -0,0 +1,17 @@
using Avalonia.Controls;
namespace BGC.Client.Views
{
public partial class GamesTableView : UserControl
{
public GamesTableView()
{
InitializeComponent();
}
public void DataGridCellPointerPressed(object sender, DataGridCellPointerPressedEventArgs args)
{
}
}
}

View File

@ -0,0 +1,13 @@
<UserControl xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:vm="clr-namespace:BGC.Client.ViewModels"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="BGC.Client.Views.LoginView"
x:DataType="vm:LoginViewModel">
<Design.DataContext>
<vm:LoginViewModel />
</Design.DataContext>
<Button Command="{Binding LoginCommand}" HorizontalAlignment="Center" VerticalAlignment="Center">Login</Button>
</UserControl>

View File

@ -0,0 +1,12 @@
using Avalonia.Controls;
namespace BGC.Client.Views
{
public partial class LoginView : UserControl
{
public LoginView()
{
InitializeComponent();
}
}
}

View File

@ -0,0 +1,18 @@
<UserControl xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:vm="clr-namespace:BGC.Client.ViewModels"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="BGC.Client.Views.MainView"
x:DataType="vm:MainViewModel">
<Design.DataContext>
<!-- This only sets the DataContext for the previewer in an IDE,
to set the actual DataContext for runtime, set the DataContext property in code (look at App.axaml.cs) -->
<vm:MainViewModel />
</Design.DataContext>
<Grid RowDefinitions="*,Auto" Margin="10" ColumnDefinitions="*,Auto">
<TransitioningContentControl Content="{Binding CurrentScreen}" />
</Grid>
</UserControl>

View File

@ -0,0 +1,12 @@
using Avalonia.Controls;
namespace BGC.Client.Views
{
public partial class MainView : UserControl
{
public MainView()
{
InitializeComponent();
}
}
}

View File

@ -0,0 +1,12 @@
<Window xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:vm="using:BGC.Client.ViewModels"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:views="clr-namespace:BGC.Client.Views"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="BGC.Client.Views.MainWindow"
Icon="/Assets/avalonia-logo.ico"
Title="BGC.Client">
<views:MainView />
</Window>

View File

@ -0,0 +1,12 @@
using Avalonia.Controls;
namespace BGC.Client.Views
{
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
}
}

View File

@ -0,0 +1,6 @@
<Project>
<PropertyGroup>
<Nullable>enable</Nullable>
<AvaloniaVersion>11.0.6</AvaloniaVersion>
</PropertyGroup>
</Project>

View File

@ -0,0 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
</Project>

View File

@ -0,0 +1,90 @@
using BGC.Common.Catalog;
using BGC.Common.Catalog.Models;
using System.Text;
using System.Text.Json;
namespace BGC.Client.Services
{
public class CatalogRepositoryHttp : ICatalogRepository
{
private readonly HttpClient _httpClient;
private readonly JsonSerializerOptions jsonSerializerOptions = new()
{
PropertyNamingPolicy = JsonNamingPolicy.CamelCase,
};
public CatalogRepositoryHttp(string serverUrl)
{
_httpClient = new HttpClient//todo настройка неразрывности соединения
{
BaseAddress = new Uri(serverUrl)
};
}
public async Task<DataForSelection> GetDataForSelection()
{
var resp = await _httpClient.GetAsync($"Catalog/GetDataForSelection");
if (resp.IsSuccessStatusCode)
{
var stringContent = await resp.Content.ReadAsStringAsync();
var res = System.Text.Json.JsonSerializer.Deserialize<DataForSelection>(stringContent, jsonSerializerOptions);
if (res != null)
{
return res;
}
}
return new DataForSelection();
}
public async Task<GetFullGameRespone> GetGameFull(long id)
{
var resp = await _httpClient.GetAsync($"Catalog/GetGameFull?gameId={id}");
if (resp.IsSuccessStatusCode)
{
var stringContent = await resp.Content.ReadAsStringAsync();
var res = System.Text.Json.JsonSerializer.Deserialize<GetFullGameRespone>(stringContent, jsonSerializerOptions);
if (res != null)
{
return res;
}
}
return new GetFullGameRespone();
}
public async Task<GetGamesByFilterResponse> GetGamesByFilter(GamesFilter filter)
{
var content = new StringContent(System.Text.Json.JsonSerializer.Serialize(filter), Encoding.UTF8, "application/json");
var resp = await _httpClient.PostAsync($"Catalog/GetGamesByFilter", content);
if (resp.IsSuccessStatusCode)
{
var stringContent = await resp.Content.ReadAsStringAsync();
var res = System.Text.Json.JsonSerializer.Deserialize<GetGamesByFilterResponse>(stringContent, jsonSerializerOptions);
if (res != null)
{
return res;
}
}
return new GetGamesByFilterResponse();
}
public async Task<GetFullGameRespone> UpsertGame(GameUpsertingRequest gameFull)
{
var content = new StringContent(System.Text.Json.JsonSerializer.Serialize(gameFull), Encoding.UTF8, "application/json");
var resp = await _httpClient.PostAsync($"Catalog/UpsertGame", content);
if (resp.IsSuccessStatusCode)
{
var stringContent = await resp.Content.ReadAsStringAsync();
var res = System.Text.Json.JsonSerializer.Deserialize<GetFullGameRespone>(stringContent, jsonSerializerOptions);
if (res != null)
{
return res;
}
}
return new GetFullGameRespone();
}
}
}

View File

@ -0,0 +1,12 @@
using BGC.Common.Catalog.Models;
namespace BGC.Common.Catalog
{
public interface ICatalogRepository
{
public Task<GetGamesByFilterResponse> GetGamesByFilter(GamesFilter filter);
public Task<GetFullGameRespone> GetGameFull(long ig);
public Task<DataForSelection> GetDataForSelection();
public Task<GetFullGameRespone> UpsertGame(GameUpsertingRequest gameFull);
}
}

View File

@ -0,0 +1,9 @@
namespace BGC.Common.Catalog.Models
{
public class Author
{
public long Id { get; set; }
public string? FirstName { get; set; }
public string? LastName { get; set; }
}
}

View File

@ -0,0 +1,12 @@
namespace BGC.Common.Catalog.Models
{
public class DataForSelection
{
public GameReduced[] Games { get; set; } = Array.Empty<GameReduced>();
public Genre[] Genres { get; set; } = Array.Empty<Genre>();
public Theme[] Themes { get; set; } = Array.Empty<Theme>();
public Owner[] Owners { get; set; } = Array.Empty<Owner>();
public Author[] Authors { get; set; } = Array.Empty<Author>();
public Rating[] Ratings { get; set; } = Array.Empty<Rating>();
}
}

View File

@ -0,0 +1,11 @@
namespace BGC.Common.Catalog.Models
{
public class GameFull : GameReduced
{
public Genre[] Genres { get; set; } = Array.Empty<Genre>();
public Theme[] Themes { get; set; } = Array.Empty<Theme>();
public Owner[] Owners { get; set; } = Array.Empty<Owner>();
public Author[] Authors { get; set; } = Array.Empty<Author>();
public Rating[] Ratings { get; set; } = Array.Empty<Rating>();
}
}

View File

@ -0,0 +1,16 @@
namespace BGC.Common.Catalog.Models
{
public class GameReduced
{
public long Id { get; set; }
public string NameRu { get; set; } = string.Empty;
public string NameEng { get; set; } = string.Empty;
private DateTime? IssueDate { get; set; }
public int PlayersMin { get; set; } = 1;
public int? PlayersMax { get; set; }
public int AgeMin { get; set; } = 1;
public int? AgeMax { get; set; }
public TimeSpan? GameDurationMin { get; set; }
public TimeSpan? GameDurationMax { get; set; }
}
}

View File

@ -0,0 +1,11 @@
namespace BGC.Common.Catalog.Models
{
public class GameUpsertingRequest : GameReduced
{
public long[] GenresIds { get; set; } = Array.Empty<long>();
public long[] ThemesIds { get; set; } = Array.Empty<long>();
public long[] OwnersIds { get; set; } = Array.Empty<long>();
public long[] AuthorsIds { get; set; } = Array.Empty<long>();
public Rating[] Ratings { get; set; } = Array.Empty<Rating>();
}
}

View File

@ -0,0 +1,7 @@
namespace BGC.Common.Catalog.Models
{
public class GamesFilter
{
public long? OwnerId { get; set; }
}
}

View File

@ -0,0 +1,8 @@
namespace BGC.Common.Catalog.Models
{
public class Genre
{
public long Id { get; set; }
public string? Name { get; set; }
}
}

View File

@ -0,0 +1,7 @@
namespace BGC.Common.Catalog.Models
{
public class GetFullGameRespone
{
public GameFull? Game { get; set; }
}
}

View File

@ -0,0 +1,7 @@
namespace BGC.Common.Catalog.Models
{
public class GetGamesByFilterResponse
{
public GameReduced[] Games { get; set; } = Array.Empty<GameReduced>();
}
}

View File

@ -0,0 +1,7 @@
namespace BGC.Common.Catalog.Models
{
public class Owner
{
public long Id { get; set; }
}
}

View File

@ -0,0 +1,10 @@
namespace BGC.Common.Catalog.Models
{
public class Rating
{
public long Id { get; set; }
public string? Name { get; set; }
public string? Scale { get; set; }
public decimal Value { get; set; }
}
}

View File

@ -0,0 +1,8 @@
namespace BGC.Common.Catalog.Models
{
public class Theme
{
public long Id { get; set; }
public string? Name { get; set; }
}
}

View File

@ -0,0 +1,88 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Intrinsics.X86;
using System.Text;
using System.Threading.Tasks;
namespace BGC.Common
{
public static class DataConverter
{
public static string GetAge(int ageMin, int? ageMax)
{
if (ageMin >= 18)
{
return "18+";
}
else if (ageMax.HasValue)
{
return ageMin.ToString() + "-" + ageMax.ToString();
}
else
{
return ageMin.ToString() + "+";
}
}
public static string GetPlayers(int minPlayers, int? maxPlayers)
{
return GetAge(minPlayers, maxPlayers);
}
public static string GetLength(int minPlayers, int? maxPlayers)
{
return GetAge(minPlayers, maxPlayers);
}
public static string GetDuration(TimeSpan? min, TimeSpan? max)
{
if (!min.HasValue && !max.HasValue)
{
return string.Empty;
}
else if (min.HasValue && !max.HasValue)
{
return "от " + GetTime(min);
}
else if (!min.HasValue && max.HasValue)
{
return "до " + GetTime(max);
}
else
{
return "от " + GetTime(min) + " до " + GetTime(max);
}
}
private static string GetTime(TimeSpan? timeSpan)
{
if (!timeSpan.HasValue)
{
return string.Empty;
}
else if (timeSpan < TimeSpan.FromMinutes(5))
{
return "5 мин";
}
else if (timeSpan >= TimeSpan.FromMinutes(5) && timeSpan < TimeSpan.FromMinutes(60))
{
return timeSpan.Value.Minutes.ToString() + " мин";
}
else if (timeSpan.Value.Minutes == 60)
{
return "1 час";
}
else if (timeSpan >= TimeSpan.FromMinutes(60) && timeSpan < TimeSpan.FromMinutes(120))
{
var delta = timeSpan.Value - TimeSpan.FromMinutes(60);
return "1 час " + delta.Minutes.ToString() + " мин";
}
else
{
return "более 2 часов";
}
}
}
}

View File

@ -0,0 +1,19 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\BGC.Common\BGC.Common.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Abstractions" Version="8.0.2" />
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="8.0.2" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,230 @@
using BGC.Common.Catalog;
using BGC.Common.Catalog.Models;
using BGC.Server.DataLayer;
using BGC.Server.DataLayer.Entities;
using Microsoft.EntityFrameworkCore;
namespace BGC.Server.Catalog
{
public class CatalogRepository : ICatalogRepository
{
private readonly IDbContextFactory<BgcDbContext> _dbContextFactory;
public CatalogRepository(IDbContextFactory<BgcDbContext> dbContextFactory)
{
_dbContextFactory = dbContextFactory;
}
#region public
public async Task<DataForSelection> GetDataForSelection()
{
using var context = await _dbContextFactory.CreateDbContextAsync();
context.ChangeTracker.QueryTrackingBehavior = QueryTrackingBehavior.NoTracking;
var authors = await context.Authors.ToArrayAsync();
var themes = await context.Themes.ToArrayAsync();
var genres = await context.Genres.ToArrayAsync();
var ratings = await context.Ratings.ToArrayAsync();
return new DataForSelection()
{
Authors = authors.Select(Map).ToArray(),
Themes = themes.Select(Map).ToArray(),
Genres = genres.Select(Map).ToArray(),
Ratings = ratings.Select(Map).ToArray(),
};
}
public async Task<GetFullGameRespone> GetGameFull(long id)
{
using var context = await _dbContextFactory.CreateDbContextAsync();
context.ChangeTracker.QueryTrackingBehavior = QueryTrackingBehavior.NoTracking;
var g = await context.Games.Where(g => g.Id == id)
.Include(g => g.Themes)
.Include(g => g.Genres)
.Include(g => g.Authors)
.Include(g => g.Owners)
.Include(g => g.GameRatings)
.ThenInclude(gr => gr.RatingType)
.FirstOrDefaultAsync();
return new GetFullGameRespone() { Game = Map(g) };
}
public async Task<GetFullGameRespone> UpsertGame(GameUpsertingRequest gameSavingRequest)
{
using var context = await _dbContextFactory.CreateDbContextAsync();
var oldGame = await context.Games.FirstOrDefaultAsync(g => g.Id == gameSavingRequest.Id);
if (oldGame != null)
{
oldGame.DeleteDate = DateTime.UtcNow;
}
var game = new Game()
{
AgeMax = gameSavingRequest.AgeMax,
AgeMin = gameSavingRequest.AgeMin,
GameDurationMax = gameSavingRequest.GameDurationMax,
GameDurationMin = gameSavingRequest.GameDurationMin,
NameEng = gameSavingRequest.NameEng,
NameRu = gameSavingRequest.NameRu,
PlayersMax = gameSavingRequest.PlayersMax,
PlayersMin = gameSavingRequest.PlayersMin,
};
game.Themes = await context.Themes
.Where(t => gameSavingRequest.ThemesIds.Contains(t.Id))
.ToArrayAsync();
game.Authors = await context.Authors
.Where(t => gameSavingRequest.AuthorsIds.Contains(t.Id))
.ToArrayAsync();
game.Owners = await context.Owners
.Where(t => gameSavingRequest.OwnersIds.Contains(t.Id))
.ToArrayAsync();
game.Genres = await context.Genres
.Where(t => gameSavingRequest.GenresIds.Contains(t.Id))
.ToArrayAsync();
var ratings = await context.Ratings
.Where(t => gameSavingRequest.Ratings.Select(r => r.Id).Contains(t.Id))
.ToArrayAsync();
var gameRatings = new GameRating[ratings.Length];
for (int i = 0; i < ratings.Length; i++)
{
gameRatings[i] = new GameRating()
{
RatingType = ratings[i],
Game = game,
Rating = gameSavingRequest.Ratings.FirstOrDefault(gr => gr.Id == ratings[i].Id)?.Value ?? 0
};
}
game.GameRatings = gameRatings;
await context.Games.AddAsync(game);
await context.SaveChangesAsync();
return new GetFullGameRespone() { Game = Map(game) };
}
public async Task<GetGamesByFilterResponse> GetGamesByFilter(GamesFilter filter)
{
using var context = await _dbContextFactory.CreateDbContextAsync();
context.ChangeTracker.QueryTrackingBehavior = QueryTrackingBehavior.NoTracking;
var result = new GetGamesByFilterResponse();
if (filter.OwnerId.HasValue)
{
var games = await context.GameOwners
.Where(go => go.OwnerId == filter.OwnerId.Value)
.Include(go => go.Game)
.Select(go => go.Game)
.Where(g => g.DeleteDate == null)
.ToArrayAsync();
result.Games = games.Select(MapToReducedGame).ToArray();
}
else
{
var games = await context.Games
.Where(g => g.DeleteDate == null)
.ToArrayAsync();
result.Games = games.Select(MapToReducedGame).ToArray();
}
return result;
}
#endregion
#region private mappings
private static GameReduced MapToReducedGame(Game game)
{
return new GameReduced()
{
AgeMax = game.AgeMax,
AgeMin = game.AgeMin,
GameDurationMax = game.GameDurationMax,
GameDurationMin = game.GameDurationMin,
Id = game.Id,
NameEng = game.NameEng,
NameRu = game.NameRu,
PlayersMax = game.PlayersMax,
PlayersMin = game.PlayersMin,
};
}
private static GameFull? Map(Game? game)
{
return game == null ? null : new GameFull()
{
AgeMax = game.AgeMax,
AgeMin = game.AgeMin,
GameDurationMax = game.GameDurationMax,
GameDurationMin = game.GameDurationMin,
Id = game.Id,
NameEng = game.NameEng,
NameRu = game.NameRu,
PlayersMax = game.PlayersMax,
PlayersMin = game.PlayersMin,
Authors = game.Authors.Select(Map).ToArray(),
Genres = game.Genres.Select(Map).ToArray(),
Ratings = game.GameRatings.Select(Map).ToArray(),
Themes = game.Themes.Select(Map).ToArray(),
};
}
private static BGC.Common.Catalog.Models.Genre Map(BGC.Server.DataLayer.Entities.Genre genre)
{
return new Common.Catalog.Models.Genre()
{
Id = genre.Id,
Name = genre.Name,
};
}
private static BGC.Common.Catalog.Models.Theme Map(BGC.Server.DataLayer.Entities.Theme theme)
{
return new Common.Catalog.Models.Theme()
{
Id = theme.Id,
Name = theme.Name,
};
}
private static BGC.Common.Catalog.Models.Author Map(BGC.Server.DataLayer.Entities.Author author)
{
return new Common.Catalog.Models.Author()
{
Id = author.Id,
FirstName = author.FirstName,
LastName = author.LastName,
};
}
private static BGC.Common.Catalog.Models.Rating Map(BGC.Server.DataLayer.Entities.RatingType ratingType)
{
return new Common.Catalog.Models.Rating()
{
Id = ratingType.Id,
Name = ratingType.Name,
Scale = ratingType.Scale,
};
}
private static BGC.Common.Catalog.Models.Rating Map(BGC.Server.DataLayer.Entities.GameRating gameRating)
{
return new Common.Catalog.Models.Rating()
{
Id = gameRating.RatingTypeId,
Name = gameRating.RatingType?.Name,
Value = gameRating.Rating,
};
}
#endregion
}
}

View File

@ -0,0 +1,109 @@
using BGC.Server.DataLayer.Entities;
using Microsoft.EntityFrameworkCore;
namespace BGC.Server.DataLayer
{
public class BgcDbContext : DbContext
{
public DbSet<Game> Games { get; set; }
public DbSet<Genre> Genres { get; set; }
public DbSet<Author> Authors { get; set; }
public DbSet<Owner> Owners { get; set; }
public DbSet<RatingType> Ratings { get; set; }
public DbSet<Theme> Themes { get; set; }
public DbSet<GameOwner> GameOwners { get; set; }
public BgcDbContext(DbContextOptions<BgcDbContext> options)
: base(options)
{
}
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.Entity<Game>(entity =>
{
entity.HasKey(e1 => e1.Id);
entity
.HasMany(e => e.Themes)
.WithMany(e => e.Games)
.UsingEntity<GameTheme>();
entity
.HasMany(e => e.Genres)
.WithMany(e => e.Games)
.UsingEntity<GameGenre>();
entity
.HasMany(e => e.Authors)
.WithMany(e => e.Games)
.UsingEntity<GameAuthor>();
entity
.HasMany(e => e.Owners)
.WithMany(e => e.Games)
.UsingEntity<GameOwner>();
});
modelBuilder.Entity<GameOwner>(entity =>
{
entity.HasKey(e1 => new { e1.GameId, e1.OwnerId });
entity.HasOne(e => e.Game).WithMany(e => e.GameOwners);
entity.HasOne(e => e.Owner).WithMany(e => e.GameOwners);
});
modelBuilder.Entity<GameAuthor>(entity =>
{
entity.HasKey(e1 => new { e1.GameId, e1.AuthorId });
entity.HasOne(e => e.Game).WithMany(e => e.GameAuthors);
entity.HasOne(e => e.Author).WithMany(e => e.GameAuthors);
});
modelBuilder.Entity<GameTheme>(entity =>
{
entity.HasKey(e1 => new { e1.GameId, e1.ThemeId });
entity.HasOne(e => e.Game).WithMany(e => e.GameThemes);
entity.HasOne(e => e.Theme).WithMany(e => e.GameThemes);
});
modelBuilder.Entity<GameGenre>(entity =>
{
entity.HasKey(e1 => new { e1.GameId, e1.GenreId });
entity.HasOne(e => e.Game).WithMany(e => e.GameGenres);
entity.HasOne(e => e.Genre).WithMany(e => e.GameGenres);
});
modelBuilder.Entity<GameRating>(entity =>
{
entity.HasKey(e1 => new { e1.GameId, e1.RatingTypeId });
entity.HasOne(e => e.Game).WithMany(e => e.GameRatings);
entity.HasOne(e => e.RatingType).WithMany(e => e.GameRatings);
});
modelBuilder.Entity<Genre>(entity =>
{
entity.HasKey(e1 => e1.Id);
});
modelBuilder.Entity<Author>(entity =>
{
entity.HasKey(e1 => e1.Id);
});
modelBuilder.Entity<Owner>(entity =>
{
entity.HasKey(e1 => e1.Id);
entity
.HasMany(e => e.Games)
.WithMany(e => e.Owners)
.UsingEntity<GameOwner>();
});
modelBuilder.Entity<RatingType>(entity =>
{
entity.HasKey(e1 => e1.Id);
});
modelBuilder.Entity<Theme>(entity =>
{
entity.HasKey(e1 => e1.Id);
});
}
}
}

View File

@ -0,0 +1,20 @@
using System.ComponentModel.DataAnnotations.Schema;
namespace BGC.Server.DataLayer.Entities
{
[Table("authors")]
public class Author
{
[Column("id")]
public long Id { get; set; }
[Column("first_name")]
public string? FirstName { get; set; }
[Column("last_name")]
public string? LastName { get; set; }
public ICollection<Game> Games { get; set; } = new List<Game>();
public ICollection<GameAuthor> GameAuthors { get; set; } = new List<GameAuthor>();
}
}

View File

@ -0,0 +1,50 @@
using System.ComponentModel.DataAnnotations.Schema;
namespace BGC.Server.DataLayer.Entities
{
[Table("games")]
public class Game
{
[Column("id")]
public long Id { get; set; }
[Column("name_ru")]
public string NameRu { get; set; } = string.Empty;
[Column("name_eng")]
public string NameEng { get; set; } = string.Empty;
[Column("issue_date")]
public DateTime? IssueDate { get; set; }
[Column("delete_date")]
public DateTime? DeleteDate { get; set; }
[Column("players_min")]
public int PlayersMin { get; set; } = 1;
[Column("players_max")]
public int? PlayersMax { get; set; }
[Column("age_min")]
public int AgeMin { get; set; } = 1;
[Column("age_max")]
public int? AgeMax { get; set; }
[Column("game_time_min")]
public TimeSpan? GameDurationMin { get; set; }
[Column("game_time_max")]
public TimeSpan? GameDurationMax { get; set; }
public virtual ICollection<Theme> Themes { get; set; } = new List<Theme>();
public virtual ICollection<GameTheme> GameThemes { get; set; } = new List<GameTheme>();
public virtual ICollection<GameRating> GameRatings { get; set; } = new List<GameRating>();
public virtual ICollection<GameGenre> GameGenres { get; set; } = new List<GameGenre>();
public virtual ICollection<Genre> Genres { get; set; } = new List<Genre>();
public ICollection<Author> Authors { get; set; } = new List<Author>();
public ICollection<GameAuthor> GameAuthors { get; set; } = new List<GameAuthor>();
public ICollection<Owner> Owners { get; set; } = new List<Owner>();
public ICollection<GameOwner> GameOwners { get; set; } = new List<GameOwner>();
}
}

View File

@ -0,0 +1,15 @@
using System.ComponentModel.DataAnnotations.Schema;
namespace BGC.Server.DataLayer.Entities
{
[Table("game_authors")]
public class GameAuthor
{
[Column("id_game")]
public long GameId { get; set; }
[Column("id_author")]
public long AuthorId { get; set; }
public required Game Game { get; set; }
public required Author Author { get; set; }
}
}

View File

@ -0,0 +1,15 @@
using System.ComponentModel.DataAnnotations.Schema;
namespace BGC.Server.DataLayer.Entities
{
[Table("game_genres")]
public class GameGenre
{
[Column("id_game")]
public long GameId { get; set; }
[Column("id_genre")]
public long GenreId { get; set; }
public required Game Game { get; set; }
public required Genre Genre { get; set; }
}
}

View File

@ -0,0 +1,15 @@
using System.ComponentModel.DataAnnotations.Schema;
namespace BGC.Server.DataLayer.Entities
{
[Table("game_collection")]
public class GameOwner
{
[Column("id_game")]
public long GameId { get; set; }
[Column("id_owner")]
public long OwnerId { get; set; }
public required Game Game { get; set; }
public required Owner Owner { get; set; }
}
}

View File

@ -0,0 +1,19 @@
using System.ComponentModel.DataAnnotations.Schema;
namespace BGC.Server.DataLayer.Entities
{
[Table("game_ratings")]
public class GameRating
{
[Column("id_game")]
public long GameId { get; set; }
[Column("id_rating_type")]
public long RatingTypeId { get; set; }
[Column("rating")]
public decimal Rating { get; set; }
public Game? Game { get; set; }
public RatingType? RatingType { get; set; }
}
}

View File

@ -0,0 +1,16 @@
using System.ComponentModel.DataAnnotations.Schema;
namespace BGC.Server.DataLayer.Entities
{
[Table("game_themes")]
public class GameTheme
{
[Column("id_game")]
public long GameId { get; set; }
[Column("id_theme")]
public long ThemeId { get; set; }
public required Game Game { get; set; }
public required Theme Theme { get; set; }
}
}

View File

@ -0,0 +1,17 @@
using System.ComponentModel.DataAnnotations.Schema;
namespace BGC.Server.DataLayer.Entities
{
[Table("genres")]
public class Genre
{
[Column("id")]
public long Id { get; set; }
[Column("name")]
public required string Name { get; set; }
public virtual ICollection<GameGenre> GameGenres { get; set; } = new List<GameGenre>();
public virtual ICollection<Game> Games { get; set; } = new List<Game>();
}
}

View File

@ -0,0 +1,19 @@
using System.ComponentModel.DataAnnotations.Schema;
namespace BGC.Server.DataLayer.Entities
{
[Table("owners")]
public class Owner
{
[Column("id")]
public long Id { get; set; }
[Column("first_name")]
public string? FirstName { get; set; }
[Column("last_name")]
public string? LastName { get; set; }
public ICollection<Game> Games { get; set; } = new List<Game>();
public ICollection<GameOwner> GameOwners { get; set; } = new List<GameOwner>();
}
}

View File

@ -0,0 +1,18 @@
using System.ComponentModel.DataAnnotations.Schema;
namespace BGC.Server.DataLayer.Entities
{
[Table("rating_types")]
public class RatingType
{
[Column("id")]
public long Id { get; set; }
[Column("name")]
public string? Name { get; set; }
[Column("scale")]
public string? Scale { get; set; }
public virtual ICollection<GameRating>? GameRatings { get; set; }
}
}

View File

@ -0,0 +1,17 @@
using System.ComponentModel.DataAnnotations.Schema;
namespace BGC.Server.DataLayer.Entities
{
[Table("themes")]
public class Theme
{
[Column("id")]
public long Id { get; set; }
[Column("name")]
public string? Name { get; set; }
public virtual ICollection<Game> Games { get; set; } = new List<Game>();
public virtual ICollection<GameTheme> GameThemes { get; set; } = new List<GameTheme>();
}
}

View File

@ -0,0 +1,20 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
<DockerComposeProjectPath>..\docker-compose.dcproj</DockerComposeProjectPath>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.20.1" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.4.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\BGC.Common\BGC.Common.csproj" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,41 @@
using BGC.Common.Catalog;
using BGC.Common.Catalog.Models;
using Microsoft.AspNetCore.Mvc;
namespace BGC.TestApi.Controllers
{
[ApiController]
[Route("[controller]/[action]")]
public class TestController : ControllerBase
{
private readonly ICatalogRepository _catalogRepository;
public TestController(ICatalogRepository catalogRepository)
{
_catalogRepository = catalogRepository;
}
[HttpGet]
public async Task<DataForSelection> GetDataForSelection()
{
return await _catalogRepository.GetDataForSelection();
}
[HttpGet]
public async Task<GetFullGameRespone> GetGameFull([FromQuery] long gameId)
{
return await _catalogRepository.GetGameFull(gameId);
}
[HttpPost]
public async Task<GetFullGameRespone> UpsertGame([FromBody] GameUpsertingRequest game)
{
return await _catalogRepository.UpsertGame(game);
}
[HttpPost]
public async Task<GetGamesByFilterResponse> GetGamesByFilter([FromBody] GamesFilter game)
{
return await _catalogRepository.GetGamesByFilter(game);
}
}
}

26
BGC.TestApi/Dockerfile Normal file
View File

@ -0,0 +1,26 @@
#See https://aka.ms/customizecontainer to learn how to customize your debug container and how Visual Studio uses this Dockerfile to build your images for faster debugging.
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base
USER app
WORKDIR /app
EXPOSE 8080
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
ARG BUILD_CONFIGURATION=Release
WORKDIR /src
COPY ["Directory.Build.props", "."]
COPY ["BGC.TestApi/BGC.TestApi.csproj", "BGC.TestApi/"]
COPY ["BGC.Common/BGC.Common.csproj", "BGC.Common/"]
RUN dotnet restore "./BGC.TestApi/BGC.TestApi.csproj"
COPY . .
WORKDIR "/src/BGC.TestApi"
RUN dotnet build "./BGC.TestApi.csproj" -c $BUILD_CONFIGURATION -o /app/build
FROM build AS publish
ARG BUILD_CONFIGURATION=Release
RUN dotnet publish "./BGC.TestApi.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "BGC.TestApi.dll"]

18
BGC.TestApi/Program.cs Normal file
View File

@ -0,0 +1,18 @@
using BGC.Client.Services;
using BGC.Common.Catalog;
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddControllers();
builder.Services.AddSingleton<ICatalogRepository>(new CatalogRepositoryHttp("http://webapi:8080/Catalog"));
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();
var app = builder.Build();
app.UseSwagger();
app.UseSwaggerUI();
app.MapControllers();
app.Run();

View File

@ -0,0 +1,8 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
}
}

Some files were not shown because too many files have changed in this diff Show More