commit b4e977948b1408542c4943becde8cc3c53491559 Author: Yaël Perret Date: Thu Apr 2 19:19:12 2026 +0200 first commit diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..1ff0c42 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,63 @@ +############################################################################### +# Set default behavior to automatically normalize line endings. +############################################################################### +* text=auto + +############################################################################### +# Set default behavior for command prompt diff. +# +# This is need for earlier builds of msysgit that does not have it on by +# default for csharp files. +# Note: This is only used by command line +############################################################################### +#*.cs diff=csharp + +############################################################################### +# Set the merge driver for project and solution files +# +# Merging from the command prompt will add diff markers to the files if there +# are conflicts (Merging from VS is not affected by the settings below, in VS +# the diff markers are never inserted). Diff markers may cause the following +# file extensions to fail to load in VS. An alternative would be to treat +# these files as binary and thus will always conflict and require user +# intervention with every merge. To do so, just uncomment the entries below +############################################################################### +#*.sln merge=binary +#*.csproj merge=binary +#*.vbproj merge=binary +#*.vcxproj merge=binary +#*.vcproj merge=binary +#*.dbproj merge=binary +#*.fsproj merge=binary +#*.lsproj merge=binary +#*.wixproj merge=binary +#*.modelproj merge=binary +#*.sqlproj merge=binary +#*.wwaproj merge=binary + +############################################################################### +# behavior for image files +# +# image files are treated as binary by default. +############################################################################### +#*.jpg binary +#*.png binary +#*.gif binary + +############################################################################### +# diff behavior for common document formats +# +# Convert binary document formats to text before diffing them. This feature +# is only available from the command line. Turn it on by uncommenting the +# entries below. +############################################################################### +#*.doc diff=astextplain +#*.DOC diff=astextplain +#*.docx diff=astextplain +#*.DOCX diff=astextplain +#*.dot diff=astextplain +#*.DOT diff=astextplain +#*.pdf diff=astextplain +#*.PDF diff=astextplain +#*.rtf diff=astextplain +#*.RTF diff=astextplain diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..9491a2f --- /dev/null +++ b/.gitignore @@ -0,0 +1,363 @@ +## 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/ +[Oo]ut/ +[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/ + +# 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 \ No newline at end of file diff --git a/ServiceManager.API/AppDbContext.cs b/ServiceManager.API/AppDbContext.cs new file mode 100644 index 0000000..2e42dcc --- /dev/null +++ b/ServiceManager.API/AppDbContext.cs @@ -0,0 +1,11 @@ +using Microsoft.EntityFrameworkCore; +using ServiceManager.API.Models; + +namespace ServiceManager.API +{ + public class AppDbContext : DbContext + { + public AppDbContext(DbContextOptions options) : base(options) { } + public DbSet
Articles { get; set; } + } +} diff --git a/ServiceManager.API/Controllers/ArticlesController.cs b/ServiceManager.API/Controllers/ArticlesController.cs new file mode 100644 index 0000000..8382885 --- /dev/null +++ b/ServiceManager.API/Controllers/ArticlesController.cs @@ -0,0 +1,26 @@ +using Microsoft.AspNetCore.Http.HttpResults; +using Microsoft.AspNetCore.Mvc; +using ServiceManager.API.Models; +using ServiceManager.API.Services; + +namespace ServiceManager.API.Controllers +{ + [Route("api/[controller]")] + [ApiController] + public class ArticlesController : ControllerBase + { + private readonly IArticlesService _articlesService; + + public ArticlesController(IArticlesService articlesService) + { + _articlesService = articlesService; + } + + [HttpGet] + public async Task>> GetArticles() + { + var articles = await _articlesService.GetArticlesAsync(); + return Ok(articles); + } + } +} diff --git a/ServiceManager.API/Migrations/20260328154238_InitialCreate.Designer.cs b/ServiceManager.API/Migrations/20260328154238_InitialCreate.Designer.cs new file mode 100644 index 0000000..5a22e98 --- /dev/null +++ b/ServiceManager.API/Migrations/20260328154238_InitialCreate.Designer.cs @@ -0,0 +1,53 @@ +// +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; +using ServiceManager.API; + +#nullable disable + +namespace ServiceManager.API.Migrations +{ + [DbContext(typeof(AppDbContext))] + [Migration("20260328154238_InitialCreate")] + partial class InitialCreate + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "10.0.5") + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + + modelBuilder.Entity("ServiceManager.API.Models.Article", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ImageLink") + .IsRequired() + .HasColumnType("text"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("Price") + .HasColumnType("numeric"); + + b.HasKey("Id"); + + b.ToTable("Articles"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/ServiceManager.API/Migrations/20260328154238_InitialCreate.cs b/ServiceManager.API/Migrations/20260328154238_InitialCreate.cs new file mode 100644 index 0000000..50ae348 --- /dev/null +++ b/ServiceManager.API/Migrations/20260328154238_InitialCreate.cs @@ -0,0 +1,37 @@ +using Microsoft.EntityFrameworkCore.Migrations; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; + +#nullable disable + +namespace ServiceManager.API.Migrations +{ + /// + public partial class InitialCreate : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "Articles", + columns: table => new + { + Id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + Name = table.Column(type: "text", nullable: false), + ImageLink = table.Column(type: "text", nullable: false), + Price = table.Column(type: "numeric", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Articles", x => x.Id); + }); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "Articles"); + } + } +} diff --git a/ServiceManager.API/Migrations/AppDbContextModelSnapshot.cs b/ServiceManager.API/Migrations/AppDbContextModelSnapshot.cs new file mode 100644 index 0000000..49b7400 --- /dev/null +++ b/ServiceManager.API/Migrations/AppDbContextModelSnapshot.cs @@ -0,0 +1,50 @@ +// +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; +using ServiceManager.API; + +#nullable disable + +namespace ServiceManager.API.Migrations +{ + [DbContext(typeof(AppDbContext))] + partial class AppDbContextModelSnapshot : ModelSnapshot + { + protected override void BuildModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "10.0.5") + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + + modelBuilder.Entity("ServiceManager.API.Models.Article", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ImageLink") + .IsRequired() + .HasColumnType("text"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("Price") + .HasColumnType("numeric"); + + b.HasKey("Id"); + + b.ToTable("Articles"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/ServiceManager.API/Models/Article.cs b/ServiceManager.API/Models/Article.cs new file mode 100644 index 0000000..e81daf7 --- /dev/null +++ b/ServiceManager.API/Models/Article.cs @@ -0,0 +1,10 @@ +namespace ServiceManager.API.Models +{ + public class Article + { + public int Id { get; set; } + public string Name { get; set; } = string.Empty; + public string ImageLink { get; set; } = string.Empty; + public decimal Price { get; set; } + } +} diff --git a/ServiceManager.API/Program.cs b/ServiceManager.API/Program.cs new file mode 100644 index 0000000..fab2141 --- /dev/null +++ b/ServiceManager.API/Program.cs @@ -0,0 +1,32 @@ +using Microsoft.EntityFrameworkCore; +using ServiceManager.API; +using ServiceManager.API.Services; + +var builder = WebApplication.CreateBuilder(args); + +// DbContext +builder.Services.AddDbContext(options => + options.UseNpgsql(builder.Configuration.GetConnectionString("DefaultConnection"))); + +// Add services to the container. +builder.Services.AddTransient(); + +builder.Services.AddControllers(); +// Learn more about configuring OpenAPI at https://aka.ms/aspnet/openapi +builder.Services.AddOpenApi(); + +var app = builder.Build(); + +// Configure the HTTP request pipeline. +if (app.Environment.IsDevelopment()) +{ + app.MapOpenApi(); +} + +app.UseHttpsRedirection(); + +app.UseAuthorization(); + +app.MapControllers(); + +app.Run(); diff --git a/ServiceManager.API/Properties/launchSettings.json b/ServiceManager.API/Properties/launchSettings.json new file mode 100644 index 0000000..87e49b5 --- /dev/null +++ b/ServiceManager.API/Properties/launchSettings.json @@ -0,0 +1,23 @@ +{ + "$schema": "https://json.schemastore.org/launchsettings.json", + "profiles": { + "http": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": false, + "applicationUrl": "http://localhost:5116", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "https": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": false, + "applicationUrl": "https://localhost:7044;http://localhost:5116", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + } + } +} diff --git a/ServiceManager.API/ServiceManager.API.csproj b/ServiceManager.API/ServiceManager.API.csproj new file mode 100644 index 0000000..e16969a --- /dev/null +++ b/ServiceManager.API/ServiceManager.API.csproj @@ -0,0 +1,20 @@ + + + + net10.0 + enable + enable + 63abca21-fb1f-45d5-b738-317f9a5b1223 + + + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + diff --git a/ServiceManager.API/ServiceManager.API.http b/ServiceManager.API/ServiceManager.API.http new file mode 100644 index 0000000..1a7ee3b --- /dev/null +++ b/ServiceManager.API/ServiceManager.API.http @@ -0,0 +1,6 @@ +@ServiceManager.API_HostAddress = http://localhost:5116 + +GET {{ServiceManager.API_HostAddress}}/weatherforecast/ +Accept: application/json + +### diff --git a/ServiceManager.API/Services/ArticlesService.cs b/ServiceManager.API/Services/ArticlesService.cs new file mode 100644 index 0000000..40d142b --- /dev/null +++ b/ServiceManager.API/Services/ArticlesService.cs @@ -0,0 +1,25 @@ +using Microsoft.EntityFrameworkCore; +using ServiceManager.API.Models; + +namespace ServiceManager.API.Services +{ + public interface IArticlesService + { + Task> GetArticlesAsync(); + } + + public class ArticlesService : IArticlesService + { + private readonly AppDbContext _context; + + public ArticlesService(AppDbContext context) + { + _context = context; + } + + public async Task> GetArticlesAsync() + { + return await _context.Articles.ToListAsync(); + } + } +} diff --git a/ServiceManager.API/appsettings.Development.json b/ServiceManager.API/appsettings.Development.json new file mode 100644 index 0000000..0c208ae --- /dev/null +++ b/ServiceManager.API/appsettings.Development.json @@ -0,0 +1,8 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + } +} diff --git a/ServiceManager.API/appsettings.json b/ServiceManager.API/appsettings.json new file mode 100644 index 0000000..6c811a4 --- /dev/null +++ b/ServiceManager.API/appsettings.json @@ -0,0 +1,12 @@ +{ + "ConnectionStrings": { + "DefaultConnection": "Server=localhost;Database=ServiceManager;Trusted_Connection=True;MultipleActiveResultSets=true" + }, + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + }, + "AllowedHosts": "*" +} diff --git a/ServiceManager.slnx b/ServiceManager.slnx new file mode 100644 index 0000000..32f7986 --- /dev/null +++ b/ServiceManager.slnx @@ -0,0 +1,4 @@ + + + + diff --git a/ServiceManager/App.xaml b/ServiceManager/App.xaml new file mode 100644 index 0000000..a2ac939 --- /dev/null +++ b/ServiceManager/App.xaml @@ -0,0 +1,14 @@ + + + + + + + + + + + diff --git a/ServiceManager/App.xaml.cs b/ServiceManager/App.xaml.cs new file mode 100644 index 0000000..0c548a7 --- /dev/null +++ b/ServiceManager/App.xaml.cs @@ -0,0 +1,14 @@ +namespace ServiceManager; + +public partial class App : Application +{ + public App() + { + InitializeComponent(); + } + + protected override Window CreateWindow(IActivationState? activationState) + { + return new Window(Handler!.MauiContext!.Services.GetRequiredService()) { Title = "ServiceManager" }; + } +} diff --git a/ServiceManager/GlobalUsings.cs b/ServiceManager/GlobalUsings.cs new file mode 100644 index 0000000..52f7f64 --- /dev/null +++ b/ServiceManager/GlobalUsings.cs @@ -0,0 +1,13 @@ +global using CommunityToolkit.Maui; +global using CommunityToolkit.Mvvm.ComponentModel; +global using CommunityToolkit.Mvvm.Input; +global using ServiceManager.ViewModels; +global using ServiceManager.Views; +global using System.Collections.ObjectModel; +global using System.ComponentModel; +global using System.Diagnostics; +global using System.Globalization; +global using System.Runtime.CompilerServices; +global using System.Text.Json; +global using System.Threading.Tasks; +global using Microsoft.Extensions.Logging; diff --git a/ServiceManager/MauiProgram.cs b/ServiceManager/MauiProgram.cs new file mode 100644 index 0000000..7ae4fd2 --- /dev/null +++ b/ServiceManager/MauiProgram.cs @@ -0,0 +1,33 @@ +using ServiceManager.Services; + +namespace ServiceManager; + +public static class MauiProgram +{ + // TODO: mettre à jour cette URL selon l'environnement (dev/prod) + private const string ApiBaseUrl = "https://localhost:7044/"; + + public static MauiApp CreateMauiApp() + { + var builder = MauiApp.CreateBuilder(); + builder + .UseMauiApp() + .UseMauiCommunityToolkit() + .ConfigureFonts(fonts => + { + fonts.AddFont("MaterialIcons-Regular.ttf", "MaterialSymbol"); + fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular"); + fonts.AddFont("OpenSans-Semibold.ttf", "OpenSansSemibold"); + }); +#if DEBUG + builder.Logging.AddDebug(); +#endif + builder.Services.AddHttpClient(client => + client.BaseAddress = new Uri(ApiBaseUrl)); + + builder.Services.AddTransient(); + builder.Services.AddTransient(); + + return builder.Build(); + } +} diff --git a/ServiceManager/Models/Article.cs b/ServiceManager/Models/Article.cs new file mode 100644 index 0000000..57741c0 --- /dev/null +++ b/ServiceManager/Models/Article.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ServiceManager.Models +{ + public class Article + { + public int Id { get; set; } + public string Name { get; set; } = string.Empty; + public string ImageLink { get; set; } = string.Empty; + public decimal Price { get; set; } + } +} diff --git a/ServiceManager/Models/CartItem.cs b/ServiceManager/Models/CartItem.cs new file mode 100644 index 0000000..64229a1 --- /dev/null +++ b/ServiceManager/Models/CartItem.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ServiceManager.Models +{ + public class CartItem + { + public Article Article { get; init; } = null!; + public int Quantity { get; set; } + public decimal Total => Article.Price * Quantity; + } +} diff --git a/ServiceManager/Platforms/Android/AndroidManifest.xml b/ServiceManager/Platforms/Android/AndroidManifest.xml new file mode 100644 index 0000000..e9937ad --- /dev/null +++ b/ServiceManager/Platforms/Android/AndroidManifest.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/ServiceManager/Platforms/Android/MainActivity.cs b/ServiceManager/Platforms/Android/MainActivity.cs new file mode 100644 index 0000000..6466203 --- /dev/null +++ b/ServiceManager/Platforms/Android/MainActivity.cs @@ -0,0 +1,10 @@ +using Android.App; +using Android.Content.PM; +using Android.OS; + +namespace ServiceManager; + +[Activity(Theme = "@style/Maui.SplashTheme", MainLauncher = true, LaunchMode = LaunchMode.SingleTop, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation | ConfigChanges.UiMode | ConfigChanges.ScreenLayout | ConfigChanges.SmallestScreenSize | ConfigChanges.Density)] +public class MainActivity : MauiAppCompatActivity +{ +} diff --git a/ServiceManager/Platforms/Android/MainApplication.cs b/ServiceManager/Platforms/Android/MainApplication.cs new file mode 100644 index 0000000..bad8103 --- /dev/null +++ b/ServiceManager/Platforms/Android/MainApplication.cs @@ -0,0 +1,15 @@ +using Android.App; +using Android.Runtime; + +namespace ServiceManager; + +[Application] +public class MainApplication : MauiApplication +{ + public MainApplication(IntPtr handle, JniHandleOwnership ownership) + : base(handle, ownership) + { + } + + protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp(); +} diff --git a/ServiceManager/Platforms/Android/Resources/values/colors.xml b/ServiceManager/Platforms/Android/Resources/values/colors.xml new file mode 100644 index 0000000..28740a6 --- /dev/null +++ b/ServiceManager/Platforms/Android/Resources/values/colors.xml @@ -0,0 +1,6 @@ + + + #512BD4 + #2B0B98 + #2B0B98 + diff --git a/ServiceManager/Platforms/MacCatalyst/AppDelegate.cs b/ServiceManager/Platforms/MacCatalyst/AppDelegate.cs new file mode 100644 index 0000000..30f869e --- /dev/null +++ b/ServiceManager/Platforms/MacCatalyst/AppDelegate.cs @@ -0,0 +1,9 @@ +using Foundation; + +namespace ServiceManager; + +[Register("AppDelegate")] +public class AppDelegate : MauiUIApplicationDelegate +{ + protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp(); +} diff --git a/ServiceManager/Platforms/MacCatalyst/Info.plist b/ServiceManager/Platforms/MacCatalyst/Info.plist new file mode 100644 index 0000000..000ad0a --- /dev/null +++ b/ServiceManager/Platforms/MacCatalyst/Info.plist @@ -0,0 +1,30 @@ + + + + + UIDeviceFamily + + 1 + 2 + + UIRequiredDeviceCapabilities + + arm64 + + UISupportedInterfaceOrientations + + UIInterfaceOrientationPortrait + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + UISupportedInterfaceOrientations~ipad + + UIInterfaceOrientationPortrait + UIInterfaceOrientationPortraitUpsideDown + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + XSAppIconAssets + Assets.xcassets/appicon.appiconset + + diff --git a/ServiceManager/Platforms/MacCatalyst/Program.cs b/ServiceManager/Platforms/MacCatalyst/Program.cs new file mode 100644 index 0000000..9610284 --- /dev/null +++ b/ServiceManager/Platforms/MacCatalyst/Program.cs @@ -0,0 +1,16 @@ +using ObjCRuntime; + +using UIKit; + +namespace ServiceManager; + +public class Program +{ + // This is the main entry point of the application. + 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)); + } +} diff --git a/ServiceManager/Platforms/Windows/App.xaml b/ServiceManager/Platforms/Windows/App.xaml new file mode 100644 index 0000000..74f1f32 --- /dev/null +++ b/ServiceManager/Platforms/Windows/App.xaml @@ -0,0 +1,8 @@ + + + diff --git a/ServiceManager/Platforms/Windows/App.xaml.cs b/ServiceManager/Platforms/Windows/App.xaml.cs new file mode 100644 index 0000000..e14c36e --- /dev/null +++ b/ServiceManager/Platforms/Windows/App.xaml.cs @@ -0,0 +1,24 @@ +using Microsoft.UI.Xaml; + +// To learn more about WinUI, the WinUI project structure, +// and more about our project templates, see: http://aka.ms/winui-project-info. + +namespace ServiceManager.WinUI; + +/// +/// Provides application-specific behavior to supplement the default Application class. +/// +public partial class App : MauiWinUIApplication +{ + /// + /// Initializes the singleton application object. This is the first line of authored code + /// executed, and as such is the logical equivalent of main() or WinMain(). + /// + public App() + { + this.InitializeComponent(); + } + + protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp(); +} + diff --git a/ServiceManager/Platforms/Windows/Package.appxmanifest b/ServiceManager/Platforms/Windows/Package.appxmanifest new file mode 100644 index 0000000..36adbc5 --- /dev/null +++ b/ServiceManager/Platforms/Windows/Package.appxmanifest @@ -0,0 +1,43 @@ + + + + + + + $placeholder$ + User Name + $placeholder$.png + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ServiceManager/Platforms/Windows/app.manifest b/ServiceManager/Platforms/Windows/app.manifest new file mode 100644 index 0000000..0433aa1 --- /dev/null +++ b/ServiceManager/Platforms/Windows/app.manifest @@ -0,0 +1,15 @@ + + + + + + + + true/PM + PerMonitorV2, PerMonitor + + + diff --git a/ServiceManager/Platforms/iOS/AppDelegate.cs b/ServiceManager/Platforms/iOS/AppDelegate.cs new file mode 100644 index 0000000..30f869e --- /dev/null +++ b/ServiceManager/Platforms/iOS/AppDelegate.cs @@ -0,0 +1,9 @@ +using Foundation; + +namespace ServiceManager; + +[Register("AppDelegate")] +public class AppDelegate : MauiUIApplicationDelegate +{ + protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp(); +} diff --git a/ServiceManager/Platforms/iOS/Entitlements.plist b/ServiceManager/Platforms/iOS/Entitlements.plist new file mode 100644 index 0000000..284f807 --- /dev/null +++ b/ServiceManager/Platforms/iOS/Entitlements.plist @@ -0,0 +1,14 @@ + + + + + + + com.apple.security.app-sandbox + + + com.apple.security.network.client + + + + diff --git a/ServiceManager/Platforms/iOS/Info.plist b/ServiceManager/Platforms/iOS/Info.plist new file mode 100644 index 0000000..622f1e5 --- /dev/null +++ b/ServiceManager/Platforms/iOS/Info.plist @@ -0,0 +1,40 @@ + + + + + + + + + + + + + + LSRequiresIPhoneOS + + UIDeviceFamily + + 2 + + UIRequiredDeviceCapabilities + + arm64 + + UISupportedInterfaceOrientations + + UIInterfaceOrientationPortrait + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + UISupportedInterfaceOrientations~ipad + + UIInterfaceOrientationPortrait + UIInterfaceOrientationPortraitUpsideDown + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + XSAppIconAssets + Assets.xcassets/appicon.appiconset + + diff --git a/ServiceManager/Platforms/iOS/PrivacyInfo.xcprivacy b/ServiceManager/Platforms/iOS/PrivacyInfo.xcprivacy new file mode 100644 index 0000000..ffc756f --- /dev/null +++ b/ServiceManager/Platforms/iOS/PrivacyInfo.xcprivacy @@ -0,0 +1,43 @@ + + + + + NSPrivacyAccessedAPITypes + + + NSPrivacyAccessedAPIType + NSPrivacyAccessedAPICategoryFileTimestamp + NSPrivacyAccessedAPITypeReasons + + C617.1 + + + + NSPrivacyAccessedAPIType + NSPrivacyAccessedAPICategorySystemBootTime + NSPrivacyAccessedAPITypeReasons + + 35F9.1 + + + + NSPrivacyAccessedAPIType + NSPrivacyAccessedAPICategoryDiskSpace + NSPrivacyAccessedAPITypeReasons + + E174.1 + + + + + + diff --git a/ServiceManager/Platforms/iOS/Program.cs b/ServiceManager/Platforms/iOS/Program.cs new file mode 100644 index 0000000..9610284 --- /dev/null +++ b/ServiceManager/Platforms/iOS/Program.cs @@ -0,0 +1,16 @@ +using ObjCRuntime; + +using UIKit; + +namespace ServiceManager; + +public class Program +{ + // This is the main entry point of the application. + 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)); + } +} diff --git a/ServiceManager/Properties/launchSettings.json b/ServiceManager/Properties/launchSettings.json new file mode 100644 index 0000000..c7dc8fc --- /dev/null +++ b/ServiceManager/Properties/launchSettings.json @@ -0,0 +1,8 @@ +{ + "profiles": { + "Windows Machine": { + "commandName": "Project", + "nativeDebugging": false + } + } +} diff --git a/ServiceManager/Resources/AppIcon/appicon.svg b/ServiceManager/Resources/AppIcon/appicon.svg new file mode 100644 index 0000000..fe8bec1 --- /dev/null +++ b/ServiceManager/Resources/AppIcon/appicon.svg @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/ServiceManager/Resources/AppIcon/appiconfg.svg b/ServiceManager/Resources/AppIcon/appiconfg.svg new file mode 100644 index 0000000..f0389fc --- /dev/null +++ b/ServiceManager/Resources/AppIcon/appiconfg.svg @@ -0,0 +1,10 @@ + + + + diff --git a/ServiceManager/Resources/Fonts/MaterialIcons-Regular.ttf b/ServiceManager/Resources/Fonts/MaterialIcons-Regular.ttf new file mode 100644 index 0000000..9d09b0f Binary files /dev/null and b/ServiceManager/Resources/Fonts/MaterialIcons-Regular.ttf differ diff --git a/ServiceManager/Resources/Fonts/OpenSans-Regular.ttf b/ServiceManager/Resources/Fonts/OpenSans-Regular.ttf new file mode 100644 index 0000000..6cbaf4b Binary files /dev/null and b/ServiceManager/Resources/Fonts/OpenSans-Regular.ttf differ diff --git a/ServiceManager/Resources/Fonts/OpenSans-Semibold.ttf b/ServiceManager/Resources/Fonts/OpenSans-Semibold.ttf new file mode 100644 index 0000000..554d68a Binary files /dev/null and b/ServiceManager/Resources/Fonts/OpenSans-Semibold.ttf differ diff --git a/ServiceManager/Resources/Images/Articles/bouteille_suze.webp b/ServiceManager/Resources/Images/Articles/bouteille_suze.webp new file mode 100644 index 0000000..3ca8616 Binary files /dev/null and b/ServiceManager/Resources/Images/Articles/bouteille_suze.webp differ diff --git a/ServiceManager/Resources/Images/Articles/peched_enfer.webp b/ServiceManager/Resources/Images/Articles/peched_enfer.webp new file mode 100644 index 0000000..c9e1dda Binary files /dev/null and b/ServiceManager/Resources/Images/Articles/peched_enfer.webp differ diff --git a/ServiceManager/Resources/Images/Articles/pichet_biere.webp b/ServiceManager/Resources/Images/Articles/pichet_biere.webp new file mode 100644 index 0000000..7e12036 Binary files /dev/null and b/ServiceManager/Resources/Images/Articles/pichet_biere.webp differ diff --git a/ServiceManager/Resources/Images/Articles/smirnoff_ice.webp b/ServiceManager/Resources/Images/Articles/smirnoff_ice.webp new file mode 100644 index 0000000..abce2fc Binary files /dev/null and b/ServiceManager/Resources/Images/Articles/smirnoff_ice.webp differ diff --git a/ServiceManager/Resources/Images/Articles/suze_verre.jpg b/ServiceManager/Resources/Images/Articles/suze_verre.jpg new file mode 100644 index 0000000..50fb96c Binary files /dev/null and b/ServiceManager/Resources/Images/Articles/suze_verre.jpg differ diff --git a/ServiceManager/Resources/Raw/AboutAssets.txt b/ServiceManager/Resources/Raw/AboutAssets.txt new file mode 100644 index 0000000..15d6244 --- /dev/null +++ b/ServiceManager/Resources/Raw/AboutAssets.txt @@ -0,0 +1,15 @@ +Any raw assets you want to be deployed with your application can be placed in +this directory (and child directories). Deployment of the asset to your application +is automatically handled by the following `MauiAsset` Build Action within your `.csproj`. + + + +These files will be deployed with you package and will be accessible using Essentials: + + async Task LoadMauiAsset() + { + using var stream = await FileSystem.OpenAppPackageFileAsync("AboutAssets.txt"); + using var reader = new StreamReader(stream); + + var contents = reader.ReadToEnd(); + } diff --git a/ServiceManager/Resources/Splash/splash.svg b/ServiceManager/Resources/Splash/splash.svg new file mode 100644 index 0000000..b3ec664 --- /dev/null +++ b/ServiceManager/Resources/Splash/splash.svg @@ -0,0 +1,29 @@ + + + + + + + \ No newline at end of file diff --git a/ServiceManager/Resources/Styles/Colors.xaml b/ServiceManager/Resources/Styles/Colors.xaml new file mode 100644 index 0000000..79f4025 --- /dev/null +++ b/ServiceManager/Resources/Styles/Colors.xaml @@ -0,0 +1,43 @@ + + + + + + + #512BD4 + #ac99ea + #242424 + #DFD8F7 + #9880e5 + #2B0B98 + + White + Black + #D600AA + #190649 + #1f1f1f + + #E1E1E1 + #C8C8C8 + #ACACAC + #919191 + #6E6E6E + #404040 + #212121 + #141414 + + + + + + + + + + + + + + + + diff --git a/ServiceManager/Resources/Styles/Styles.xaml b/ServiceManager/Resources/Styles/Styles.xaml new file mode 100644 index 0000000..eea02b4 --- /dev/null +++ b/ServiceManager/Resources/Styles/Styles.xaml @@ -0,0 +1,428 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ServiceManager/ServiceManager.csproj b/ServiceManager/ServiceManager.csproj new file mode 100644 index 0000000..796ae76 --- /dev/null +++ b/ServiceManager/ServiceManager.csproj @@ -0,0 +1,82 @@ + + + + net9.0-android;net9.0-ios;net9.0-maccatalyst + $(TargetFrameworks);net9.0-windows10.0.19041.0 + Exe + ServiceManager + true + true + enable + enable + true + true + + 9.0.50 + + + ServiceManager + + + com.companyname.ServiceManager + e6a12cbd-d479-4bf7-be85-a0324d679efd + + + 1.0 + 1 + + + None + + 15.0 + 15.0 + 26.0 + 10.0.17763.0 + 10.0.17763.0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + MSBuild:Compile + + + + + + v1.8 + MVVMToolkit + NoShell + + + diff --git a/ServiceManager/Services/ArticleService.cs b/ServiceManager/Services/ArticleService.cs new file mode 100644 index 0000000..4568023 --- /dev/null +++ b/ServiceManager/Services/ArticleService.cs @@ -0,0 +1,24 @@ +using ServiceManager.Models; +using System.Net.Http.Json; + +namespace ServiceManager.Services; + +public interface IArticleService +{ + Task> GetArticlesAsync(); +} + +public class ArticleService : IArticleService +{ + private readonly HttpClient _httpClient; + + public ArticleService(HttpClient httpClient) + { + _httpClient = httpClient; + } + + public async Task> GetArticlesAsync() + { + return await _httpClient.GetFromJsonAsync>("api/articles") ?? []; + } +} diff --git a/ServiceManager/ViewModels/ArticleCardViewModel.cs b/ServiceManager/ViewModels/ArticleCardViewModel.cs new file mode 100644 index 0000000..3fef756 --- /dev/null +++ b/ServiceManager/ViewModels/ArticleCardViewModel.cs @@ -0,0 +1,15 @@ +using ServiceManager.Models; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ServiceManager.ViewModels +{ + public class ArticleCardViewModel + { + public Article Article { get; init; } = null!; + public IRelayCommand TapCommand { get; init; } = null!; + } +} diff --git a/ServiceManager/ViewModels/BaseViewModel.cs b/ServiceManager/ViewModels/BaseViewModel.cs new file mode 100644 index 0000000..a4dbb9f --- /dev/null +++ b/ServiceManager/ViewModels/BaseViewModel.cs @@ -0,0 +1,5 @@ +namespace ServiceManager.ViewModels; + +public partial class BaseViewModel : ObservableObject +{ +} diff --git a/ServiceManager/ViewModels/MainViewModel.cs b/ServiceManager/ViewModels/MainViewModel.cs new file mode 100644 index 0000000..a47bf74 --- /dev/null +++ b/ServiceManager/ViewModels/MainViewModel.cs @@ -0,0 +1,46 @@ +using ServiceManager.Models; +using ServiceManager.Services; + +namespace ServiceManager.ViewModels; + +public partial class MainViewModel : BaseViewModel +{ + private readonly IArticleService _articleService; + private readonly List _cart = []; + + [ObservableProperty] + private decimal _totalPrice; + + [ObservableProperty] + private ObservableCollection _articleCards = []; + + public MainViewModel(IArticleService articleService) + { + _articleService = articleService; + _ = LoadArticlesAsync(); + } + + private async Task LoadArticlesAsync() + { + var articles = await _articleService.GetArticlesAsync(); + + ArticleCards = new ObservableCollection( + articles.Select(article => new ArticleCardViewModel + { + Article = article, + TapCommand = new RelayCommand(() => AddToCart(article)) + }) + ); + } + + private void AddToCart(Article article) + { + var existing = _cart.FirstOrDefault(item => item.Article.Id == article.Id); + if (existing is not null) + existing.Quantity++; + else + _cart.Add(new CartItem { Article = article, Quantity = 1 }); + + TotalPrice = _cart.Sum(item => item.Total); + } +} diff --git a/ServiceManager/Views/MainPage.xaml b/ServiceManager/Views/MainPage.xaml new file mode 100644 index 0000000..527df86 --- /dev/null +++ b/ServiceManager/Views/MainPage.xaml @@ -0,0 +1,75 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +