Initial commit

Initial commit til Git.
V2 er deployed
This commit is contained in:
2026-06-13 17:31:50 +02:00
parent 9fcd2b145e
commit 41e23b6184
375 changed files with 15956 additions and 0 deletions

View File

@@ -0,0 +1,7 @@
namespace Pos.Api.Database
{
public class Class1
{
}
}

View File

@@ -0,0 +1,162 @@
// <auto-generated> This file has been auto generated by EF Core Power Tools. </auto-generated>
#nullable disable
using System;
using System.Collections.Generic;
using Microsoft.EntityFrameworkCore;
using Pos.Api.Database.Models;
namespace Pos.Api.Database.Data;
public partial class PosApiContext : DbContext
{
public PosApiContext(DbContextOptions<PosApiContext> options)
: base(options)
{
}
public virtual DbSet<Employee> Employees { get; set; }
public virtual DbSet<LastUpdate> LastUpdates { get; set; }
public virtual DbSet<Payment> Payments { get; set; }
public virtual DbSet<Product> Products { get; set; }
public virtual DbSet<Productgroup> Productgroups { get; set; }
public virtual DbSet<Sale> Sales { get; set; }
public virtual DbSet<SaleLine> SaleLines { get; set; }
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder
.UseCollation("latin1_swedish_ci")
.HasCharSet("latin1");
modelBuilder.Entity<Employee>(entity =>
{
entity.HasKey(e => e.Id).HasName("PRIMARY");
entity
.ToTable("employee")
.HasCharSet("utf8mb4")
.UseCollation("utf8mb4_general_ci");
entity.Property(e => e.Id).HasColumnType("int(11)");
entity.Property(e => e.IsArchived).HasColumnType("tinyint(4)");
entity.Property(e => e.Name)
.IsRequired()
.HasMaxLength(50);
});
modelBuilder.Entity<LastUpdate>(entity =>
{
entity
.HasNoKey()
.ToTable("LastUpdate");
entity.Property(e => e.DateTime).HasColumnType("datetime");
});
modelBuilder.Entity<Payment>(entity =>
{
entity.HasKey(e => e.Id).HasName("PRIMARY");
entity
.ToTable("payment")
.HasCharSet("armscii8")
.UseCollation("armscii8_bin");
entity.Property(e => e.Id).HasColumnType("int(11)");
entity.Property(e => e.Amount).HasPrecision(20, 6);
entity.Property(e => e.SaleId).HasColumnType("int(11)");
entity.Property(e => e.Type)
.IsRequired()
.HasColumnType("tinytext");
});
modelBuilder.Entity<Product>(entity =>
{
entity.HasKey(e => e.Id).HasName("PRIMARY");
entity
.ToTable("product")
.HasCharSet("utf8mb4")
.UseCollation("utf8mb4_general_ci");
entity.HasIndex(e => e.ProductGroupId, "FK_Product_Categories");
entity.Property(e => e.Id)
.ValueGeneratedOnAdd()
.HasColumnType("int(11)");
entity.Property(e => e.Description).HasColumnType("mediumtext");
entity.Property(e => e.Index).HasColumnType("int(11)");
entity.Property(e => e.IsArchived).HasColumnType("tinyint(4)");
entity.Property(e => e.Name)
.IsRequired()
.HasColumnType("tinytext");
entity.Property(e => e.Price).HasPrecision(10, 2);
entity.Property(e => e.ProductGroupId).HasColumnType("int(11)");
entity.HasOne(d => d.IdNavigation).WithOne(p => p.Product)
.HasForeignKey<Product>(d => d.Id)
.OnDelete(DeleteBehavior.ClientSetNull)
.HasConstraintName("FK_Product_ProductGroup");
});
modelBuilder.Entity<Productgroup>(entity =>
{
entity.HasKey(e => e.Id).HasName("PRIMARY");
entity
.ToTable("productgroup")
.HasCharSet("utf8mb4")
.UseCollation("utf8mb4_general_ci");
entity.Property(e => e.Id).HasColumnType("int(11)");
entity.Property(e => e.Index).HasColumnType("int(11)");
entity.Property(e => e.IsArchived).HasColumnType("tinyint(4)");
entity.Property(e => e.Name)
.IsRequired()
.HasColumnType("tinytext");
});
modelBuilder.Entity<Sale>(entity =>
{
entity.HasKey(e => e.Id).HasName("PRIMARY");
entity
.ToTable("sale")
.HasCharSet("armscii8")
.UseCollation("armscii8_bin");
entity.Property(e => e.Id).HasColumnType("int(11)");
entity.Property(e => e.EmployeeId).HasColumnType("int(11)");
entity.Property(e => e.Time).HasColumnType("datetime");
});
modelBuilder.Entity<SaleLine>(entity =>
{
entity.HasKey(e => e.Id).HasName("PRIMARY");
entity
.ToTable("sale_line")
.HasCharSet("armscii8")
.UseCollation("armscii8_bin");
entity.Property(e => e.Id).HasColumnType("int(11)");
entity.Property(e => e.Pieces).HasColumnType("smallint(6)");
entity.Property(e => e.Price).HasPrecision(20, 6);
entity.Property(e => e.Product)
.IsRequired()
.HasColumnType("tinytext");
entity.Property(e => e.SaleId).HasColumnType("int(11)");
entity.Property(e => e.Total).HasPrecision(20, 6);
});
OnModelCreatingPartial(modelBuilder);
}
partial void OnModelCreatingPartial(ModelBuilder modelBuilder);
}

View File

@@ -0,0 +1,30 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Pos.Api.Database.Data
{
public partial class PosApiContext
{
protected override void OnConfiguring(
DbContextOptionsBuilder optionsBuilder)
{
LoadConfig l = new LoadConfig();
IConfiguration config = l.ByEnvironment();
string connectionString = config["MySQL"].ToString();
optionsBuilder
.UseMySql(connectionString, ServerVersion.AutoDetect(connectionString))
.UseLoggerFactory(LoggerFactory.Create(b => b
.AddFilter(level => level >= LogLevel.Information)))
.EnableSensitiveDataLogging()
.EnableDetailedErrors();
base.OnConfiguring(optionsBuilder);
}
}
}

View File

@@ -0,0 +1,55 @@
using Microsoft.Extensions.Configuration;
namespace Pos.Api.Database
{
public class LoadConfig
{
private string dir;
public LoadConfig()
{
dir = AppDomain.CurrentDomain.BaseDirectory;
}
public IConfiguration ByEnvironment()
{
//Console.Out.WriteLine($"Json path: {dir}");
#if DEBUG
var config = new ConfigurationBuilder()
.SetBasePath(dir)
.AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
.AddJsonFile("appsettings.Development.json", optional: true, reloadOnChange: true)
.Build();
return config;
#else
var config = new ConfigurationBuilder()
.SetBasePath(dir)
.AddJsonFile("appsettings.Production.json", optional: true, reloadOnChange: true)
.Build();
return config;
#endif
//Running in a environment that not is supported in this setup
throw new Exception("HostingEnvironment is not supported! This config setup only supports Development or Production");
}
public IConfiguration DebugConfiguration()
{
var config = new ConfigurationBuilder()
.SetBasePath(dir)
.AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
.AddJsonFile("appsettings.Development.json", optional: true, reloadOnChange: true)
.Build();
return config;
}
public IConfiguration ReleaseConfiguration()
{
var config = new ConfigurationBuilder()
.SetBasePath(dir)
.AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
.AddJsonFile("appsettings.Production.json", optional: true, reloadOnChange: true)
.Build();
return config;
}
}
}

View File

@@ -0,0 +1,15 @@
// <auto-generated> This file has been auto generated by EF Core Power Tools. </auto-generated>
#nullable disable
using System;
using System.Collections.Generic;
namespace Pos.Api.Database.Models;
public partial class Employee
{
public int Id { get; set; }
public string Name { get; set; }
public sbyte IsArchived { get; set; }
}

View File

@@ -0,0 +1,11 @@
// <auto-generated> This file has been auto generated by EF Core Power Tools. </auto-generated>
#nullable disable
using System;
using System.Collections.Generic;
namespace Pos.Api.Database.Models;
public partial class LastUpdate
{
public DateTime? DateTime { get; set; }
}

View File

@@ -0,0 +1,17 @@
// <auto-generated> This file has been auto generated by EF Core Power Tools. </auto-generated>
#nullable disable
using System;
using System.Collections.Generic;
namespace Pos.Api.Database.Models;
public partial class Payment
{
public int Id { get; set; }
public int SaleId { get; set; }
public decimal Amount { get; set; }
public string Type { get; set; }
}

View File

@@ -0,0 +1,25 @@
// <auto-generated> This file has been auto generated by EF Core Power Tools. </auto-generated>
#nullable disable
using System;
using System.Collections.Generic;
namespace Pos.Api.Database.Models;
public partial class Product
{
public int Id { get; set; }
public string Name { get; set; }
public decimal Price { get; set; }
public string Description { get; set; }
public int ProductGroupId { get; set; }
public sbyte IsArchived { get; set; }
public int Index { get; set; }
public virtual Productgroup IdNavigation { get; set; }
}

View File

@@ -0,0 +1,19 @@
// <auto-generated> This file has been auto generated by EF Core Power Tools. </auto-generated>
#nullable disable
using System;
using System.Collections.Generic;
namespace Pos.Api.Database.Models;
public partial class Productgroup
{
public int Id { get; set; }
public string Name { get; set; }
public sbyte IsArchived { get; set; }
public int Index { get; set; }
public virtual Product Product { get; set; }
}

View File

@@ -0,0 +1,15 @@
// <auto-generated> This file has been auto generated by EF Core Power Tools. </auto-generated>
#nullable disable
using System;
using System.Collections.Generic;
namespace Pos.Api.Database.Models;
public partial class Sale
{
public int Id { get; set; }
public DateTime Time { get; set; }
public int EmployeeId { get; set; }
}

View File

@@ -0,0 +1,21 @@
// <auto-generated> This file has been auto generated by EF Core Power Tools. </auto-generated>
#nullable disable
using System;
using System.Collections.Generic;
namespace Pos.Api.Database.Models;
public partial class SaleLine
{
public int Id { get; set; }
public int SaleId { get; set; }
public string Product { get; set; }
public short Pieces { get; set; }
public decimal Price { get; set; }
public decimal Total { get; set; }
}

View File

@@ -0,0 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Configuration" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="7.0.0" />
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="7.0.0" />
</ItemGroup>
</Project>

View File

@@ -0,0 +1,66 @@
{
"CodeGenerationMode": 3,
"ContextClassName": "PosApiContext",
"ContextNamespace": null,
"DefaultDacpacSchema": null,
"FilterSchemas": false,
"IncludeConnectionString": false,
"ModelNamespace": null,
"OutputContextPath": "Data",
"OutputPath": "Models",
"PreserveCasingWithRegex": true,
"ProjectRootNamespace": "Pos.Api.Database",
"Schemas": null,
"SelectedHandlebarsLanguage": 0,
"SelectedToBeGenerated": 0,
"Tables": [
{
"Name": "employee",
"ObjectType": 0
},
{
"Name": "LastUpdate",
"ObjectType": 0
},
{
"Name": "payment",
"ObjectType": 0
},
{
"Name": "product",
"ObjectType": 0
},
{
"Name": "productgroup",
"ObjectType": 0
},
{
"Name": "sale",
"ObjectType": 0
},
{
"Name": "sale_line",
"ObjectType": 0
}
],
"UiHint": "simply.com",
"UncountableWords": null,
"UseBoolPropertiesWithoutDefaultSql": false,
"UseDatabaseNames": false,
"UseDateOnlyTimeOnly": false,
"UseDbContextSplitting": false,
"UseFluentApiOnly": true,
"UseHandleBars": false,
"UseHierarchyId": false,
"UseInflector": true,
"UseLegacyPluralizer": false,
"UseManyToManyEntity": false,
"UseNoDefaultConstructor": false,
"UseNoObjectFilter": false,
"UseNodaTime": false,
"UseNullableReferences": false,
"UseSchemaFolders": false,
"UseSchemaNamespaces": false,
"UseSpatial": false,
"UseT4": false
}