diff --git a/ClientManager/ClientManager.csproj b/ClientManager/ClientManager.csproj index 2299ab1..cb64f7b 100644 --- a/ClientManager/ClientManager.csproj +++ b/ClientManager/ClientManager.csproj @@ -8,6 +8,11 @@ + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + diff --git a/ServerManager/BiskAcdbContext.cs b/ServerManager/BiskAcdbContext.cs new file mode 100644 index 0000000..d3a0c72 --- /dev/null +++ b/ServerManager/BiskAcdbContext.cs @@ -0,0 +1,1374 @@ +using Azure.Core; +using Biskilog_Cloud.Shared.Enums; +using Biskilog_Cloud.Shared.Interfaces; +using Biskilog_Cloud.Shared.POSModels; +using Microsoft.EntityFrameworkCore; +using Microsoft.Net.Http.Headers; + +namespace ServerManager.Server.POSModels; + +public partial class BiskAcdbContext : DbContext +{ + private readonly HttpContext m_httpContext; + private readonly IConnectionService m_connection; + private readonly ITokenService m_tokenService; + public BiskAcdbContext() + { + } + public BiskAcdbContext(DbContextOptions options, ITokenService tokenService, IConnectionService connection, IHttpContextAccessor a_httpContextAccessor = null) + : base(options) + { + m_tokenService = tokenService; + m_connection = connection; + m_httpContext = a_httpContextAccessor?.HttpContext; + } + + protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) + { + if (!optionsBuilder.IsConfigured) + { + string token = m_httpContext.Request.Headers[HeaderNames.Authorization]!; + if (AuthEnums.Valid == m_tokenService.ValidateToken(token)) + { + int? databaseId = m_tokenService.GetDatabaseIdFromToken(token); + string connectionString = m_connection.GetClientConnectionString(databaseId!.Value); + optionsBuilder.UseMySql(connectionString, new MariaDbServerVersion(new Version())); + } + else + { + m_httpContext.Abort(); + } + } + } + public virtual DbSet Creditpurchases { get; set; } + + public virtual DbSet Customeraccounts { get; set; } + + public virtual DbSet Productaltunits { get; set; } + + public virtual DbSet Restocklevels { get; set; } + + public virtual DbSet Systemuserroles { get; set; } + + public virtual DbSet Tblbranches { get; set; } + + public virtual DbSet Tblbrands { get; set; } + + public virtual DbSet Tblcancelledtransactions { get; set; } + + public virtual DbSet Tblcarts { get; set; } + + public virtual DbSet Tblcategories { get; set; } + + public virtual DbSet Tblcompanydetails { get; set; } + + public virtual DbSet Tblcustomers { get; set; } + + public virtual DbSet Tblcustomerpurchases { get; set; } + + public virtual DbSet Tbldeliverydetails { get; set; } + + public virtual DbSet Tbldeliveryheads { get; set; } + + public virtual DbSet Tbldeliveryrecipients { get; set; } + + public virtual DbSet Tbldiscountlogs { get; set; } + + public virtual DbSet Tbldrivers { get; set; } + + public virtual DbSet Tblinventories { get; set; } + + public virtual DbSet Tblinventoryentries { get; set; } + + public virtual DbSet Tblinvoices { get; set; } + + public virtual DbSet Tblpricechanges { get; set; } + + public virtual DbSet Tblproducts { get; set; } + + public virtual DbSet Tbltrucks { get; set; } + + public virtual DbSet TbltruckDrivermappings { get; set; } + + public virtual DbSet Tbltruckassignments { get; set; } + + public virtual DbSet Tbltruckinventories { get; set; } + + public virtual DbSet Tblusers { get; set; } + + public virtual DbSet Tbstocks { get; set; } + + public virtual DbSet Unitofmeasures { get; set; } + + protected override void OnModelCreating(ModelBuilder modelBuilder) + { + modelBuilder + .UseCollation("utf8mb4_general_ci") + .HasCharSet("utf8mb4"); + + modelBuilder.Entity(entity => + { + entity.HasKey(e => new { e.ReceiptId, e.BranchId }) + .HasName("PRIMARY") + .HasAnnotation("MySql:IndexPrefixLength", new[] { 0, 0 }); + + entity + .ToTable("creditpurchases") + .HasCharSet("utf8") + .UseCollation("utf8_general_ci"); + + entity.Property(e => e.ReceiptId) + .HasMaxLength(120) + .HasColumnName("receiptID") + .UseCollation("utf8mb4_general_ci") + .HasCharSet("utf8mb4"); + entity.Property(e => e.BranchId) + .HasMaxLength(10) + .HasDefaultValueSql("'0'") + .IsFixedLength() + .HasColumnName("branchID") + .UseCollation("utf8mb4_general_ci") + .HasCharSet("utf8mb4"); + entity.Property(e => e.CustomerId) + .HasMaxLength(120) + .HasDefaultValueSql("'0'") + .HasColumnName("customerID") + .UseCollation("utf8mb4_general_ci") + .HasCharSet("utf8mb4"); + entity.Property(e => e.Date) + .ValueGeneratedOnAddOrUpdate() + .HasDefaultValueSql("current_timestamp()") + .HasColumnType("timestamp") + .HasColumnName("date"); + entity.Property(e => e.Paid) + .HasPrecision(19, 2) + .HasColumnName("paid"); + entity.Property(e => e.Status) + .HasMaxLength(10) + .HasDefaultValueSql("'0'") + .IsFixedLength() + .HasColumnName("status") + .UseCollation("utf8mb4_general_ci") + .HasCharSet("utf8mb4"); + entity.Property(e => e.TotalBill) + .HasPrecision(19, 2) + .HasColumnName("totalBill"); + }); + + modelBuilder.Entity(entity => + { + entity.HasKey(e => new { e.BranchId, e.CountId }) + .HasName("PRIMARY") + .HasAnnotation("MySql:IndexPrefixLength", new[] { 0, 0 }); + + entity + .ToTable("customeraccounts") + .HasCharSet("utf8") + .UseCollation("utf8_general_ci"); + + entity.Property(e => e.BranchId) + .HasMaxLength(10) + .HasDefaultValueSql("''") + .IsFixedLength() + .HasColumnName("branchID") + .UseCollation("utf8mb4_general_ci") + .HasCharSet("utf8mb4"); + entity.Property(e => e.CountId) + .HasMaxLength(120) + .HasDefaultValueSql("''") + .HasColumnName("countID") + .UseCollation("utf8mb4_general_ci") + .HasCharSet("utf8mb4"); + entity.Property(e => e.Balance) + .HasPrecision(19, 2) + .HasColumnName("balance"); + entity.Property(e => e.Comments) + .HasColumnType("text") + .HasColumnName("comments") + .UseCollation("utf8mb4_general_ci") + .HasCharSet("utf8mb4"); + entity.Property(e => e.Credit) + .HasPrecision(19, 2) + .HasColumnName("credit"); + entity.Property(e => e.CustomerId) + .HasMaxLength(120) + .HasColumnName("customerID") + .UseCollation("utf8mb4_general_ci") + .HasCharSet("utf8mb4"); + entity.Property(e => e.Date) + .ValueGeneratedOnAddOrUpdate() + .HasDefaultValueSql("current_timestamp()") + .HasColumnType("timestamp") + .HasColumnName("date"); + entity.Property(e => e.Debit) + .HasPrecision(19, 2) + .HasColumnName("debit"); + entity.Property(e => e.TransactionId) + .HasMaxLength(120) + .HasColumnName("transactionID") + .UseCollation("utf8mb4_general_ci") + .HasCharSet("utf8mb4"); + }); + + modelBuilder.Entity(entity => + { + entity.HasKey(e => new { e.DistinctiveCode, e.BranchId }) + .HasName("PRIMARY") + .HasAnnotation("MySql:IndexPrefixLength", new[] { 0, 0 }); + + entity + .ToTable("productaltunit") + .HasCharSet("utf8") + .UseCollation("utf8_general_ci"); + + entity.Property(e => e.DistinctiveCode) + .HasMaxLength(120) + .HasColumnName("distinctiveCode") + .UseCollation("utf8mb4_general_ci") + .HasCharSet("utf8mb4"); + entity.Property(e => e.BranchId) + .HasMaxLength(120) + .HasColumnName("branchID") + .UseCollation("utf8mb4_general_ci") + .HasCharSet("utf8mb4"); + entity.Property(e => e.Pcode) + .HasMaxLength(120) + .HasColumnName("pcode") + .UseCollation("utf8mb4_general_ci") + .HasCharSet("utf8mb4"); + entity.Property(e => e.PriceUnit) + .HasPrecision(19, 2) + .HasColumnName("price/unit"); + entity.Property(e => e.QuantityUnit) + .HasColumnType("int(11)") + .HasColumnName("quantity/unit"); + entity.Property(e => e.UnitBarcode) + .HasMaxLength(20) + .HasColumnName("unitBarcode") + .UseCollation("utf8mb4_general_ci") + .HasCharSet("utf8mb4"); + entity.Property(e => e.UnitCode) + .HasMaxLength(120) + .HasColumnName("unitCode") + .UseCollation("utf8mb4_general_ci") + .HasCharSet("utf8mb4"); + }); + + modelBuilder.Entity(entity => + { + entity.HasKey(e => new { e.ProductId, e.BranchId }) + .HasName("PRIMARY") + .HasAnnotation("MySql:IndexPrefixLength", new[] { 0, 0 }); + + entity + .ToTable("restocklevels") + .HasCharSet("utf8") + .UseCollation("utf8_general_ci"); + + entity.Property(e => e.ProductId) + .HasMaxLength(150) + .HasColumnName("productID") + .UseCollation("utf8mb4_general_ci") + .HasCharSet("utf8mb4"); + entity.Property(e => e.BranchId) + .HasMaxLength(20) + .HasColumnName("branchID") + .UseCollation("utf8mb4_general_ci") + .HasCharSet("utf8mb4"); + entity.Property(e => e.Unit) + .HasMaxLength(150) + .HasColumnName("unit") + .UseCollation("utf8mb4_general_ci") + .HasCharSet("utf8mb4"); + entity.Property(e => e.WarnLevel) + .HasColumnType("int(11)") + .HasColumnName("warnLevel"); + }); + + modelBuilder.Entity(entity => + { + entity.HasKey(e => e.Id).HasName("PRIMARY"); + + entity + .ToTable("systemuserroles") + .HasCharSet("utf8") + .UseCollation("utf8_general_ci"); + + entity.Property(e => e.Id) + .ValueGeneratedNever() + .HasColumnType("int(11)") + .HasColumnName("id"); + entity.Property(e => e.Assist) + .HasColumnType("tinyint(4)") + .HasColumnName("assist"); + entity.Property(e => e.Cashier) + .HasColumnType("tinyint(4)") + .HasColumnName("cashier"); + entity.Property(e => e.Manager) + .HasColumnType("tinyint(4)") + .HasColumnName("manager"); + entity.Property(e => e.Owner) + .HasColumnType("tinyint(4)") + .HasColumnName("owner"); + entity.Property(e => e.Roles) + .HasColumnName("roles") + .UseCollation("utf8mb4_general_ci") + .HasCharSet("utf8mb4"); + }); + + modelBuilder.Entity(entity => + { + entity.HasKey(e => e.BranchId).HasName("PRIMARY"); + + entity + .ToTable("tblbranches") + .HasCharSet("utf8") + .UseCollation("utf8_general_ci"); + + entity.Property(e => e.BranchId) + .HasMaxLength(12) + .HasColumnName("branchID"); + entity.Property(e => e.Address) + .HasMaxLength(50) + .HasColumnName("address") + .UseCollation("utf8mb4_general_ci") + .HasCharSet("utf8mb4"); + entity.Property(e => e.BranchName) + .HasMaxLength(50) + .HasColumnName("branchName") + .UseCollation("utf8mb4_general_ci") + .HasCharSet("utf8mb4"); + entity.Property(e => e.BranchTelephone) + .HasMaxLength(50) + .HasColumnName("branch_telephone") + .UseCollation("utf8mb4_general_ci") + .HasCharSet("utf8mb4"); + entity.Property(e => e.City) + .HasMaxLength(50) + .HasColumnName("city") + .UseCollation("utf8mb4_general_ci") + .HasCharSet("utf8mb4"); + entity.Property(e => e.StateOrProvince) + .HasMaxLength(50) + .HasColumnName("state_or_province") + .UseCollation("utf8mb4_general_ci") + .HasCharSet("utf8mb4"); + }); + + modelBuilder.Entity(entity => + { + entity.HasKey(e => new { e.Id, e.BranchId }) + .HasName("PRIMARY") + .HasAnnotation("MySql:IndexPrefixLength", new[] { 0, 0 }); + + entity + .ToTable("tblbrand") + .HasCharSet("utf8") + .UseCollation("utf8_general_ci"); + + entity.Property(e => e.Id) + .HasMaxLength(50) + .HasColumnName("id"); + entity.Property(e => e.BranchId) + .HasMaxLength(12) + .HasColumnName("branchID"); + entity.Property(e => e.Brand) + .HasMaxLength(50) + .HasColumnName("brand") + .UseCollation("utf8mb4_general_ci") + .HasCharSet("utf8mb4"); + }); + + modelBuilder.Entity(entity => + { + entity.HasKey(e => new { e.BranchId, e.CountId }) + .HasName("PRIMARY") + .HasAnnotation("MySql:IndexPrefixLength", new[] { 0, 0 }); + + entity + .ToTable("tblcancelledtransactions") + .HasCharSet("utf8") + .UseCollation("utf8_general_ci"); + + entity.Property(e => e.BranchId) + .HasMaxLength(50) + .HasColumnName("branchID"); + entity.Property(e => e.CountId) + .HasMaxLength(50) + .HasColumnName("countID"); + entity.Property(e => e.CancelledBy) + .HasMaxLength(50) + .HasColumnName("cancelledBy") + .UseCollation("utf8mb4_general_ci") + .HasCharSet("utf8mb4"); + entity.Property(e => e.DateCancelled) + .HasColumnType("timestamp") + .HasColumnName("dateCancelled"); + entity.Property(e => e.Transno) + .HasColumnName("transno") + .UseCollation("utf8mb4_general_ci") + .HasCharSet("utf8mb4"); + }); + + modelBuilder.Entity(entity => + { + entity.HasKey(e => new { e.BranchId, e.CountId }) + .HasName("PRIMARY") + .HasAnnotation("MySql:IndexPrefixLength", new[] { 0, 0 }); + + entity + .ToTable("tblcart") + .HasCharSet("utf8") + .UseCollation("utf8_general_ci"); + + entity.Property(e => e.BranchId) + .HasMaxLength(10) + .HasDefaultValueSql("''") + .IsFixedLength() + .HasColumnName("branchID"); + entity.Property(e => e.CountId) + .HasMaxLength(200) + .HasColumnName("countID") + .UseCollation("utf8mb4_general_ci") + .HasCharSet("utf8mb4"); + entity.Property(e => e.Cashier) + .HasMaxLength(50) + .HasColumnName("cashier"); + entity.Property(e => e.Costprice) + .HasPrecision(19, 2) + .HasColumnName("costprice"); + entity.Property(e => e.Date) + .HasColumnType("timestamp") + .HasColumnName("date"); + entity.Property(e => e.Id) + .HasMaxLength(50) + .HasColumnName("id"); + entity.Property(e => e.Price) + .HasPrecision(19, 2) + .HasColumnName("price"); + entity.Property(e => e.Quantity) + .HasColumnType("int(11)") + .HasColumnName("quantity"); + entity.Property(e => e.Status) + .HasMaxLength(50) + .HasColumnName("status") + .UseCollation("utf8mb4_general_ci") + .HasCharSet("utf8mb4"); + entity.Property(e => e.Total) + .HasPrecision(19, 2) + .HasColumnName("total"); + entity.Property(e => e.Transno) + .HasColumnName("transno") + .UseCollation("utf8mb4_general_ci") + .HasCharSet("utf8mb4"); + entity.Property(e => e.Unit) + .HasMaxLength(120) + .HasColumnName("unit") + .UseCollation("utf8mb4_general_ci") + .HasCharSet("utf8mb4"); + entity.Property(e => e.Tendered) + .HasPrecision(19, 2) + .HasColumnName("tendered"); + entity.Property(e => e.Balance) + .HasPrecision(19, 2) + .HasColumnName("balance"); + entity.Property(e => e.ValueAddTax) + .HasPrecision(19, 2) + .HasColumnName("valueAddTax"); + }); + + modelBuilder.Entity(entity => + { + entity.HasKey(e => new { e.Id, e.BranchId }) + .HasName("PRIMARY") + .HasAnnotation("MySql:IndexPrefixLength", new[] { 0, 0 }); + + entity + .ToTable("tblcategory") + .HasCharSet("utf8") + .UseCollation("utf8_general_ci"); + + entity.Property(e => e.Id) + .HasMaxLength(50) + .HasColumnName("id"); + entity.Property(e => e.BranchId) + .HasMaxLength(12) + .HasColumnName("branchID"); + entity.Property(e => e.Category) + .HasMaxLength(50) + .HasColumnName("category") + .UseCollation("utf8mb4_general_ci") + .HasCharSet("utf8mb4"); + }); + + modelBuilder.Entity(entity => + { + entity.HasKey(e => e.Tin).HasName("PRIMARY"); + + entity + .ToTable("tblcompanydetails") + .HasCharSet("utf8") + .UseCollation("utf8_general_ci"); + + entity.Property(e => e.Tin) + .HasMaxLength(60) + .HasColumnName("tin"); + entity.Property(e => e.Address) + .HasMaxLength(50) + .HasColumnName("address") + .UseCollation("utf8mb4_general_ci") + .HasCharSet("utf8mb4"); + entity.Property(e => e.CompanyName) + .HasMaxLength(50) + .HasColumnName("company_name") + .UseCollation("utf8mb4_general_ci") + .HasCharSet("utf8mb4"); + entity.Property(e => e.Email) + .HasMaxLength(50) + .HasColumnName("email") + .UseCollation("utf8mb4_general_ci") + .HasCharSet("utf8mb4"); + entity.Property(e => e.MainTelephone) + .HasMaxLength(50) + .HasColumnName("main_telephone"); + entity.Property(e => e.Vatno) + .HasMaxLength(60) + .HasColumnName("vatno"); + entity.Property(e => e.Website) + .HasMaxLength(50) + .HasColumnName("website") + .UseCollation("utf8mb4_general_ci") + .HasCharSet("utf8mb4"); + }); + + modelBuilder.Entity(entity => + { + entity.HasKey(e => new { e.CustomerId, e.BranchId }) + .HasName("PRIMARY") + .HasAnnotation("MySql:IndexPrefixLength", new[] { 0, 0 }); + + entity + .ToTable("tblcustomers") + .HasCharSet("utf8") + .UseCollation("utf8_general_ci"); + + entity.Property(e => e.CustomerId) + .HasMaxLength(30) + .HasColumnName("customerID"); + entity.Property(e => e.BranchId) + .HasMaxLength(10) + .HasDefaultValueSql("''") + .IsFixedLength() + .HasColumnName("branchID"); + entity.Property(e => e.Address) + .HasMaxLength(50) + .HasColumnName("address") + .UseCollation("utf8mb4_general_ci") + .HasCharSet("utf8mb4"); + entity.Property(e => e.DateAdded) + .HasColumnType("timestamp") + .HasColumnName("dateAdded"); + entity.Property(e => e.DateExit) + .HasColumnType("timestamp") + .HasColumnName("dateExit"); + entity.Property(e => e.Email) + .HasMaxLength(50) + .HasColumnName("email"); + entity.Property(e => e.FinancialStatus) + .HasMaxLength(20) + .HasColumnName("financialStatus") + .UseCollation("utf8mb4_general_ci") + .HasCharSet("utf8mb4"); + entity.Property(e => e.Firstname) + .HasMaxLength(50) + .UseCollation("utf8mb4_general_ci") + .HasCharSet("utf8mb4"); + entity.Property(e => e.NameKey1) + .HasMaxLength(120) + .HasColumnName("name_key1") + .UseCollation("utf8mb4_general_ci") + .HasCharSet("utf8mb4"); + entity.Property(e => e.NameKey2) + .HasMaxLength(120) + .HasColumnName("name_key2") + .UseCollation("utf8mb4_general_ci") + .HasCharSet("utf8mb4"); + entity.Property(e => e.Status) + .HasMaxLength(20) + .HasColumnName("status") + .UseCollation("utf8mb4_general_ci") + .HasCharSet("utf8mb4"); + entity.Property(e => e.Surname) + .HasMaxLength(50) + .UseCollation("utf8mb4_general_ci") + .HasCharSet("utf8mb4"); + entity.Property(e => e.Telephone) + .HasMaxLength(50) + .HasColumnName("telephone") + .UseCollation("utf8mb4_general_ci") + .HasCharSet("utf8mb4"); + entity.Property(e => e.Tin) + .HasMaxLength(50) + .HasColumnName("tin"); + }); + + modelBuilder.Entity(entity => + { + entity.HasKey(e => new { e.BranchId, e.CountId }) + .HasName("PRIMARY") + .HasAnnotation("MySql:IndexPrefixLength", new[] { 0, 0 }); + + entity + .ToTable("tblcustomerpurchases") + .HasCharSet("utf8") + .UseCollation("utf8_general_ci"); + + entity.Property(e => e.BranchId) + .HasMaxLength(10) + .HasDefaultValueSql("''") + .IsFixedLength() + .HasColumnName("branchID") + .UseCollation("utf8mb4_general_ci") + .HasCharSet("utf8mb4"); + entity.Property(e => e.CountId) + .HasMaxLength(50) + .HasColumnName("countID"); + entity.Property(e => e.CustomerId) + .HasMaxLength(50) + .HasColumnName("customerID"); + entity.Property(e => e.TransactionId) + .HasMaxLength(50) + .HasColumnName("transactionID"); + }); + + modelBuilder.Entity(entity => + { + entity.HasKey(e => new { e.CountId, e.BranchId }) + .HasName("PRIMARY") + .HasAnnotation("MySql:IndexPrefixLength", new[] { 0, 0 }); + + entity + .ToTable("tbldeliverydetails") + .HasCharSet("utf8") + .UseCollation("utf8_general_ci"); + + entity.Property(e => e.CountId) + .HasMaxLength(100) + .HasColumnName("countID"); + entity.Property(e => e.BranchId) + .HasMaxLength(10) + .IsFixedLength() + .HasColumnName("branchID") + .UseCollation("utf8mb4_general_ci") + .HasCharSet("utf8mb4"); + entity.Property(e => e.Cost) + .HasPrecision(19, 2) + .HasColumnName("cost"); + entity.Property(e => e.DeliveryId) + .HasMaxLength(60) + .HasColumnName("deliveryID"); + entity.Property(e => e.Pcode) + .HasMaxLength(60) + .HasColumnName("pcode"); + entity.Property(e => e.Quantity) + .HasColumnType("int(11)") + .HasColumnName("quantity"); + entity.Property(e => e.Unit) + .HasMaxLength(120) + .HasColumnName("unit") + .UseCollation("utf8mb4_general_ci") + .HasCharSet("utf8mb4"); + }); + + modelBuilder.Entity(entity => + { + entity.HasKey(e => new { e.DeliveryId, e.BranchId }) + .HasName("PRIMARY") + .HasAnnotation("MySql:IndexPrefixLength", new[] { 0, 0 }); + + entity + .ToTable("tbldeliveryhead") + .HasCharSet("utf8") + .UseCollation("utf8_general_ci"); + + entity.Property(e => e.DeliveryId) + .HasMaxLength(60) + .HasColumnName("deliveryID"); + entity.Property(e => e.BranchId) + .HasMaxLength(10) + .IsFixedLength() + .HasColumnName("branchID"); + entity.Property(e => e.CustomerId) + .HasMaxLength(60) + .HasColumnName("customerID"); + entity.Property(e => e.DateCompleted) + .HasMaxLength(6) + .HasColumnName("dateCompleted"); + entity.Property(e => e.DateInitiated) + .HasMaxLength(6) + .HasColumnName("dateInitiated"); + entity.Property(e => e.Destination) + .HasMaxLength(60) + .HasColumnName("destination"); + entity.Property(e => e.GeneratedBy) + .HasMaxLength(50) + .HasColumnName("generatedBy") + .UseCollation("utf8mb4_general_ci") + .HasCharSet("utf8mb4"); + entity.Property(e => e.Status) + .HasMaxLength(20) + .HasColumnName("status") + .UseCollation("utf8mb4_general_ci") + .HasCharSet("utf8mb4"); + entity.Property(e => e.TotalCost) + .HasPrecision(19, 2) + .HasColumnName("totalCost"); + }); + + modelBuilder.Entity(entity => + { + entity.HasKey(e => new { e.DeliveryId, e.BranchId }) + .HasName("PRIMARY") + .HasAnnotation("MySql:IndexPrefixLength", new[] { 0, 0 }); + + entity + .ToTable("tbldeliveryrecipients") + .HasCharSet("utf8") + .UseCollation("utf8_general_ci"); + + entity.Property(e => e.DeliveryId) + .HasMaxLength(60) + .HasColumnName("deliveryID"); + entity.Property(e => e.BranchId) + .HasMaxLength(10) + .IsFixedLength() + .HasColumnName("branchID") + .UseCollation("utf8mb4_general_ci") + .HasCharSet("utf8mb4"); + entity.Property(e => e.Address) + .HasMaxLength(60) + .HasColumnName("address"); + entity.Property(e => e.CustomerId) + .HasMaxLength(60) + .HasColumnName("customerID"); + entity.Property(e => e.Email) + .HasMaxLength(60) + .HasColumnName("email"); + entity.Property(e => e.FromDate).HasColumnName("fromDate"); + entity.Property(e => e.Fullname) + .HasColumnName("fullname") + .UseCollation("utf8mb4_general_ci") + .HasCharSet("utf8mb4"); + entity.Property(e => e.Telephone) + .HasMaxLength(15) + .HasColumnName("telephone") + .UseCollation("utf8mb4_general_ci") + .HasCharSet("utf8mb4"); + entity.Property(e => e.ToDate).HasColumnName("toDate"); + }); + + modelBuilder.Entity(entity => + { + entity.HasKey(e => new { e.BranchId, e.CountId }) + .HasName("PRIMARY") + .HasAnnotation("MySql:IndexPrefixLength", new[] { 0, 0 }); + + entity + .ToTable("tbldiscountlogs") + .HasCharSet("utf8") + .UseCollation("utf8_general_ci"); + + entity.Property(e => e.BranchId) + .HasMaxLength(10) + .IsFixedLength() + .HasColumnName("branchID") + .UseCollation("utf8mb4_general_ci") + .HasCharSet("utf8mb4"); + entity.Property(e => e.CountId) + .HasMaxLength(150) + .HasDefaultValueSql("''") + .HasColumnName("countID") + .UseCollation("utf8mb4_general_ci") + .HasCharSet("utf8mb4"); + entity.Property(e => e.Cashier) + .HasMaxLength(50) + .HasColumnName("cashier") + .UseCollation("utf8mb4_general_ci") + .HasCharSet("utf8mb4"); + entity.Property(e => e.Date) + .HasMaxLength(6) + .HasColumnName("date"); + entity.Property(e => e.Discount) + .HasPrecision(19, 2) + .HasColumnName("discount"); + entity.Property(e => e.ReceiptId) + .HasMaxLength(50) + .HasColumnName("receiptID"); + }); + + modelBuilder.Entity(entity => + { + entity.HasKey(e => new { e.DriverId, e.BranchId }) + .HasName("PRIMARY") + .HasAnnotation("MySql:IndexPrefixLength", new[] { 0, 0 }); + + entity + .ToTable("tbldrivers") + .HasCharSet("utf8") + .UseCollation("utf8_general_ci"); + + entity.Property(e => e.DriverId) + .HasMaxLength(50) + .HasColumnName("driverID"); + entity.Property(e => e.BranchId) + .HasMaxLength(10) + .HasDefaultValueSql("''") + .IsFixedLength() + .HasColumnName("branchID"); + entity.Property(e => e.Address1) + .HasMaxLength(50) + .HasColumnName("address1") + .UseCollation("utf8mb4_general_ci") + .HasCharSet("utf8mb4"); + entity.Property(e => e.Address2) + .HasMaxLength(50) + .HasColumnName("address2") + .UseCollation("utf8mb4_general_ci") + .HasCharSet("utf8mb4"); + entity.Property(e => e.City) + .HasMaxLength(50) + .HasColumnName("city") + .UseCollation("utf8mb4_general_ci") + .HasCharSet("utf8mb4"); + entity.Property(e => e.DateOfBirth).HasColumnName("dateOfBirth"); + entity.Property(e => e.Email) + .HasMaxLength(120) + .HasColumnName("email") + .UseCollation("utf8mb4_general_ci") + .HasCharSet("utf8mb4"); + entity.Property(e => e.Firstname) + .HasMaxLength(50) + .HasColumnName("firstname") + .UseCollation("utf8mb4_general_ci") + .HasCharSet("utf8mb4"); + entity.Property(e => e.Middlename) + .HasMaxLength(50) + .HasColumnName("middlename") + .UseCollation("utf8mb4_general_ci") + .HasCharSet("utf8mb4"); + entity.Property(e => e.State) + .HasMaxLength(50) + .HasColumnName("state") + .UseCollation("utf8mb4_general_ci") + .HasCharSet("utf8mb4"); + entity.Property(e => e.Status) + .HasMaxLength(50) + .HasColumnName("status") + .UseCollation("utf8mb4_general_ci") + .HasCharSet("utf8mb4"); + entity.Property(e => e.Surname) + .HasMaxLength(50) + .HasColumnName("surname") + .UseCollation("utf8mb4_general_ci") + .HasCharSet("utf8mb4"); + entity.Property(e => e.Telephone) + .HasMaxLength(20) + .HasColumnName("telephone") + .UseCollation("utf8mb4_general_ci") + .HasCharSet("utf8mb4"); + }); + + modelBuilder.Entity(entity => + { + entity.HasKey(e => new { e.BranchId, e.CountId }) + .HasName("PRIMARY") + .HasAnnotation("MySql:IndexPrefixLength", new[] { 0, 0 }); + + entity + .ToTable("tblinventory") + .HasCharSet("utf8") + .UseCollation("utf8_general_ci"); + + entity.Property(e => e.BranchId) + .HasMaxLength(10) + .HasDefaultValueSql("''") + .IsFixedLength() + .HasColumnName("branchID"); + entity.Property(e => e.CountId) + .HasMaxLength(50) + .HasColumnName("countID"); + entity.Property(e => e.Pcode) + .HasMaxLength(50) + .HasColumnName("pcode"); + entity.Property(e => e.Quantity) + .HasColumnType("int(11)") + .HasColumnName("quantity"); + }); + + modelBuilder.Entity(entity => + { + entity.HasKey(e => new { e.CountId, e.BranchId }) + .HasName("PRIMARY") + .HasAnnotation("MySql:IndexPrefixLength", new[] { 0, 0 }); + + entity + .ToTable("tblinventoryentries") + .HasCharSet("utf8") + .UseCollation("utf8_general_ci"); + + entity.Property(e => e.CountId) + .HasMaxLength(120) + .HasColumnName("countID"); + entity.Property(e => e.BranchId) + .HasMaxLength(10) + .IsFixedLength() + .HasColumnName("branchID"); + entity.Property(e => e.Date) + .HasMaxLength(6) + .HasColumnName("date"); + entity.Property(e => e.Pcode) + .HasMaxLength(50) + .HasColumnName("pcode"); + entity.Property(e => e.Quantity) + .HasColumnType("int(11)") + .HasColumnName("quantity"); + }); + + modelBuilder.Entity(entity => + { + entity.HasKey(e => new { e.CountId, e.BranchId }) + .HasName("PRIMARY") + .HasAnnotation("MySql:IndexPrefixLength", new[] { 0, 0 }); + + entity + .ToTable("tblinvoice") + .HasCharSet("utf8") + .UseCollation("utf8_general_ci"); + + entity.Property(e => e.CountId) + .HasMaxLength(50) + .HasColumnName("countID"); + entity.Property(e => e.BranchId) + .HasMaxLength(10) + .HasDefaultValueSql("''") + .IsFixedLength() + .HasColumnName("branchID"); + entity.Property(e => e.DateGenerated).HasColumnName("dateGenerated"); + entity.Property(e => e.GeneratedBy) + .HasMaxLength(50) + .HasColumnName("generatedBy"); + entity.Property(e => e.InvoiceId) + .HasMaxLength(60) + .HasColumnName("invoiceID"); + entity.Property(e => e.Pcode) + .HasMaxLength(50) + .HasColumnName("pcode"); + entity.Property(e => e.Quantity) + .HasColumnType("int(11)") + .HasColumnName("quantity"); + entity.Property(e => e.Status) + .HasMaxLength(16) + .HasColumnName("status") + .UseCollation("utf8mb4_general_ci") + .HasCharSet("utf8mb4"); + entity.Property(e => e.Totalprice) + .HasPrecision(19, 2) + .HasColumnName("totalprice"); + entity.Property(e => e.Unit) + .HasMaxLength(120) + .HasColumnName("unit") + .UseCollation("utf8mb4_general_ci") + .HasCharSet("utf8mb4"); + entity.Property(e => e.Unitprice) + .HasPrecision(19, 2) + .HasColumnName("unitprice"); + }); + + modelBuilder.Entity(entity => + { + entity.HasKey(e => new { e.CountId, e.BranchId }) + .HasName("PRIMARY") + .HasAnnotation("MySql:IndexPrefixLength", new[] { 0, 0 }); + + entity + .ToTable("tblpricechanges") + .HasCharSet("utf8") + .UseCollation("utf8_general_ci"); + + entity.Property(e => e.CountId) + .HasMaxLength(70) + .HasColumnName("countID"); + entity.Property(e => e.BranchId) + .HasMaxLength(10) + .IsFixedLength() + .HasColumnName("branchID"); + entity.Property(e => e.ChangeDate) + .HasMaxLength(6) + .HasColumnName("change_date"); + entity.Property(e => e.CurrentPrice) + .HasPrecision(19, 2) + .HasColumnName("current_price"); + entity.Property(e => e.Pcode) + .HasMaxLength(120) + .HasColumnName("pcode"); + entity.Property(e => e.PreviousPrice) + .HasPrecision(19, 2) + .HasColumnName("previous_price"); + }); + + modelBuilder.Entity(entity => + { + entity.HasKey(e => new { e.CountId, e.BranchId }) + .HasName("PRIMARY") + .HasAnnotation("MySql:IndexPrefixLength", new[] { 0, 0 }); + + entity + .ToTable("tblproduct") + .HasCharSet("utf8") + .UseCollation("utf8_general_ci"); + + entity.Property(e => e.CountId) + .HasMaxLength(50) + .HasColumnName("countID"); + entity.Property(e => e.BranchId) + .HasMaxLength(10) + .IsFixedLength() + .HasColumnName("branchID"); + entity.Property(e => e.Barcode) + .HasMaxLength(50) + .HasColumnName("barcode") + .UseCollation("utf8mb4_general_ci") + .HasCharSet("utf8mb4"); + entity.Property(e => e.BaseUnit) + .HasMaxLength(120) + .HasColumnName("baseUnit") + .UseCollation("utf8mb4_general_ci") + .HasCharSet("utf8mb4"); + entity.Property(e => e.Bid) + .HasMaxLength(50) + .HasColumnName("bid"); + entity.Property(e => e.Cid) + .HasMaxLength(50) + .HasColumnName("cid"); + entity.Property(e => e.Costprice) + .HasPrecision(19, 2) + .HasColumnName("costprice"); + entity.Property(e => e.Pcode) + .HasMaxLength(50) + .HasColumnName("pcode"); + entity.Property(e => e.Pdesc) + .HasColumnName("pdesc") + .UseCollation("utf8mb4_general_ci") + .HasCharSet("utf8mb4"); + entity.Property(e => e.Price) + .HasPrecision(19, 2) + .HasColumnName("price"); + entity.Property(e => e.ProductName) + .HasColumnName("product_name") + .UseCollation("utf8mb4_general_ci") + .HasCharSet("utf8mb4"); + entity.Property(e => e.Status) + .HasMaxLength(20) + .HasColumnName("status") + .UseCollation("utf8mb4_general_ci") + .HasCharSet("utf8mb4"); + }); + + modelBuilder.Entity(entity => + { + entity.HasKey(e => new { e.TruckId, e.BranchId }) + .HasName("PRIMARY") + .HasAnnotation("MySql:IndexPrefixLength", new[] { 0, 0 }); + + entity + .ToTable("tbltrucks") + .HasCharSet("utf8") + .UseCollation("utf8_general_ci"); + + entity.Property(e => e.TruckId) + .HasMaxLength(60) + .HasColumnName("truckID"); + entity.Property(e => e.BranchId) + .HasMaxLength(10) + .IsFixedLength() + .HasColumnName("branchID"); + entity.Property(e => e.Brand) + .HasMaxLength(50) + .HasColumnName("brand") + .UseCollation("utf8mb4_general_ci") + .HasCharSet("utf8mb4"); + entity.Property(e => e.Driver) + .HasMaxLength(50) + .HasColumnName("driver"); + entity.Property(e => e.LicensePlate) + .HasMaxLength(60) + .HasColumnName("licensePlate"); + entity.Property(e => e.Weight) + .HasPrecision(19, 2) + .HasColumnName("weight"); + }); + + modelBuilder.Entity(entity => + { + entity.HasKey(e => new { e.CountId, e.BranchId }) + .HasName("PRIMARY") + .HasAnnotation("MySql:IndexPrefixLength", new[] { 0, 0 }); + + entity + .ToTable("tbltruck_drivermapping") + .HasCharSet("utf8") + .UseCollation("utf8_general_ci"); + + entity.Property(e => e.CountId) + .HasMaxLength(60) + .HasColumnName("countID"); + entity.Property(e => e.BranchId) + .HasMaxLength(10) + .IsFixedLength() + .HasColumnName("branchID") + .UseCollation("utf8mb4_general_ci") + .HasCharSet("utf8mb4"); + entity.Property(e => e.DateEntry) + .HasMaxLength(6) + .HasColumnName("dateEntry"); + entity.Property(e => e.DriverId) + .HasMaxLength(50) + .HasColumnName("driverID"); + entity.Property(e => e.Operation) + .HasMaxLength(50) + .HasColumnName("operation") + .UseCollation("utf8mb4_general_ci") + .HasCharSet("utf8mb4"); + entity.Property(e => e.TruckId) + .HasMaxLength(50) + .HasColumnName("truckID"); + }); + + modelBuilder.Entity(entity => + { + entity.HasKey(e => new { e.CountId, e.BranchId }) + .HasName("PRIMARY") + .HasAnnotation("MySql:IndexPrefixLength", new[] { 0, 0 }); + + entity + .ToTable("tbltruckassignments") + .HasCharSet("utf8") + .UseCollation("utf8_general_ci"); + + entity.Property(e => e.CountId) + .HasMaxLength(100) + .HasColumnName("countID") + .UseCollation("utf8mb4_general_ci") + .HasCharSet("utf8mb4"); + entity.Property(e => e.BranchId) + .HasMaxLength(10) + .IsFixedLength() + .HasColumnName("branchID") + .UseCollation("utf8mb4_general_ci") + .HasCharSet("utf8mb4"); + entity.Property(e => e.Cost) + .HasPrecision(19, 2) + .HasColumnName("cost"); + entity.Property(e => e.DateAssigned) + .HasMaxLength(6) + .HasColumnName("dateAssigned"); + entity.Property(e => e.OrderId) + .HasMaxLength(50) + .HasColumnName("orderID"); + entity.Property(e => e.Status) + .HasMaxLength(50) + .HasColumnName("status") + .UseCollation("utf8mb4_general_ci") + .HasCharSet("utf8mb4"); + entity.Property(e => e.TruckId) + .HasMaxLength(50) + .HasColumnName("truckID"); + }); + + modelBuilder.Entity(entity => + { + entity.HasKey(e => new { e.CountId, e.BranchId }) + .HasName("PRIMARY") + .HasAnnotation("MySql:IndexPrefixLength", new[] { 0, 0 }); + + entity + .ToTable("tbltruckinventory") + .HasCharSet("utf8") + .UseCollation("utf8_general_ci"); + + entity.Property(e => e.CountId) + .HasMaxLength(50) + .HasColumnName("countID"); + entity.Property(e => e.BranchId) + .HasMaxLength(10) + .IsFixedLength() + .HasColumnName("branchID") + .UseCollation("utf8mb4_general_ci") + .HasCharSet("utf8mb4"); + entity.Property(e => e.Pcode) + .HasMaxLength(50) + .HasColumnName("pcode"); + entity.Property(e => e.Quantity) + .HasColumnType("int(11)") + .HasColumnName("quantity"); + entity.Property(e => e.TruckId) + .HasMaxLength(50) + .HasColumnName("truckID"); + entity.Property(e => e.Unit) + .HasMaxLength(120) + .HasColumnName("unit") + .UseCollation("utf8mb4_general_ci") + .HasCharSet("utf8mb4"); + }); + + modelBuilder.Entity(entity => + { + entity.HasKey(e => new { e.Username, e.BranchId }) + .HasName("PRIMARY") + .HasAnnotation("MySql:IndexPrefixLength", new[] { 0, 0 }); + + entity + .ToTable("tblusers") + .HasCharSet("utf8") + .UseCollation("utf8_general_ci"); + + entity.Property(e => e.Username) + .HasMaxLength(50) + .HasColumnName("username"); + entity.Property(e => e.BranchId) + .HasMaxLength(10) + .HasDefaultValueSql("''") + .IsFixedLength() + .HasColumnName("branchID"); + entity.Property(e => e.AccessLevel) + .HasMaxLength(10) + .HasColumnName("access_level") + .UseCollation("utf8mb4_general_ci") + .HasCharSet("utf8mb4"); + entity.Property(e => e.City) + .HasMaxLength(50) + .HasColumnName("city") + .UseCollation("utf8mb4_general_ci") + .HasCharSet("utf8mb4"); + entity.Property(e => e.Email) + .HasMaxLength(50) + .HasColumnName("email") + .UseCollation("utf8mb4_general_ci") + .HasCharSet("utf8mb4"); + entity.Property(e => e.Firstname) + .HasMaxLength(50) + .HasColumnName("firstname") + .UseCollation("utf8mb4_general_ci") + .HasCharSet("utf8mb4"); + entity.Property(e => e.LastLogin) + .HasMaxLength(6) + .HasColumnName("last_login"); + entity.Property(e => e.Password) + .HasColumnName("password") + .UseCollation("utf8mb4_general_ci") + .HasCharSet("utf8mb4"); + entity.Property(e => e.StateOrProvince) + .HasMaxLength(50) + .HasColumnName("state_or_province") + .UseCollation("utf8mb4_general_ci") + .HasCharSet("utf8mb4"); + entity.Property(e => e.StreetAddress1) + .HasMaxLength(50) + .HasColumnName("street_address1") + .UseCollation("utf8mb4_general_ci") + .HasCharSet("utf8mb4"); + entity.Property(e => e.StreetAddress2) + .HasMaxLength(50) + .HasColumnName("street_address2") + .UseCollation("utf8mb4_general_ci") + .HasCharSet("utf8mb4"); + entity.Property(e => e.Surname) + .HasMaxLength(50) + .HasColumnName("surname") + .UseCollation("utf8mb4_general_ci") + .HasCharSet("utf8mb4"); + entity.Property(e => e.Telephone) + .HasMaxLength(15) + .HasColumnName("telephone") + .UseCollation("utf8mb4_general_ci") + .HasCharSet("utf8mb4"); + }); + + modelBuilder.Entity(entity => + { + entity.HasKey(e => new { e.CountId, e.BranchId }) + .HasName("PRIMARY") + .HasAnnotation("MySql:IndexPrefixLength", new[] { 0, 0 }); + + entity + .ToTable("tbstock") + .HasCharSet("utf8") + .UseCollation("utf8_general_ci"); + + entity.Property(e => e.CountId) + .HasMaxLength(50) + .HasColumnName("countID"); + entity.Property(e => e.BranchId) + .HasMaxLength(10) + .IsFixedLength() + .HasColumnName("branchID"); + entity.Property(e => e.Pcode) + .HasMaxLength(50) + .HasColumnName("pcode"); + entity.Property(e => e.Qty) + .HasColumnType("int(11)") + .HasColumnName("qty"); + entity.Property(e => e.Refno) + .HasMaxLength(50) + .HasColumnName("refno"); + entity.Property(e => e.Sdate).HasColumnName("sdate"); + entity.Property(e => e.Stockinby) + .HasMaxLength(50) + .HasColumnName("stockinby") + .UseCollation("utf8mb4_general_ci") + .HasCharSet("utf8mb4"); + }); + + modelBuilder.Entity(entity => + { + entity.HasKey(e => new { e.UnitCode, e.BranchId }) + .HasName("PRIMARY") + .HasAnnotation("MySql:IndexPrefixLength", new[] { 0, 0 }); + + entity + .ToTable("unitofmeasure") + .HasCharSet("utf8") + .UseCollation("utf8_general_ci"); + + entity.Property(e => e.UnitCode) + .HasMaxLength(120) + .HasColumnName("unitCode"); + entity.Property(e => e.BranchId) + .HasMaxLength(10) + .HasDefaultValueSql("''") + .IsFixedLength() + .HasColumnName("branchID") + .UseCollation("utf8mb4_general_ci") + .HasCharSet("utf8mb4"); + entity.Property(e => e.Status) + .HasMaxLength(50) + .HasColumnName("status") + .UseCollation("utf8mb4_general_ci") + .HasCharSet("utf8mb4"); + entity.Property(e => e.Unitname) + .HasMaxLength(120) + .HasColumnName("unitname") + .UseCollation("utf8mb4_general_ci") + .HasCharSet("utf8mb4"); + entity.Property(e => e.Unitshort) + .HasMaxLength(120) + .HasColumnName("unitshort") + .UseCollation("utf8mb4_general_ci") + .HasCharSet("utf8mb4"); + }); + + OnModelCreatingPartial(modelBuilder); + } + + partial void OnModelCreatingPartial(ModelBuilder modelBuilder); +} diff --git a/ServerManager/BiskilogContext.cs b/ServerManager/BiskilogContext.cs new file mode 100644 index 0000000..9e4a350 --- /dev/null +++ b/ServerManager/BiskilogContext.cs @@ -0,0 +1,278 @@ +using Biskilog_Cloud.Shared.ClientContractModels; +using Microsoft.EntityFrameworkCore; + +namespace ServerManager; +/// +/// This is the main EF DbContext for the Biskilog Accounting +/// +public partial class BiskilogContext : DbContext +{ + public BiskilogContext() + { + } + public BiskilogContext(DbContextOptions options) + : base(options) + { + } + + public virtual DbSet Authtypes { get; set; } + + public virtual DbSet Clientbusinesses { get; set; } + + public virtual DbSet Clientinfos { get; set; } + + public virtual DbSet Contracts { get; set; } + + public virtual DbSet Databasemaps { get; set; } + + public virtual DbSet Siteaccesspermissions { get; set; } + + public virtual DbSet Userauths { get; set; } + + protected override void OnModelCreating(ModelBuilder modelBuilder) + { + modelBuilder + .UseCollation("utf8mb4_general_ci") + .HasCharSet("utf8mb4"); + + modelBuilder.Entity(entity => + { + entity.HasKey(e => e.Id).HasName("PRIMARY"); + + entity + .ToTable("authtypes") + .HasCharSet("utf8") + .UseCollation("utf8_general_ci"); + + entity.Property(e => e.Id) + .HasColumnType("int(11)") + .HasColumnName("id"); + entity.Property(e => e.Type) + .HasMaxLength(50) + .HasColumnName("type") + .UseCollation("utf8mb4_general_ci") + .HasCharSet("utf8mb4"); + }); + + modelBuilder.Entity(entity => + { + entity.HasKey(e => new { e.BusinessId, e.ClientId }) + .HasName("PRIMARY") + .HasAnnotation("MySql:IndexPrefixLength", new[] { 0, 0 }); + + entity + .ToTable("clientbusiness") + .HasCharSet("utf8") + .UseCollation("utf8_general_ci"); + + entity.Property(e => e.BusinessId) + .HasComment("there could be multiple branches of the same business") + .HasColumnType("int(11)") + .HasColumnName("businessId"); + entity.Property(e => e.ClientId) + .HasColumnType("int(11)") + .HasColumnName("clientID"); + entity.Property(e => e.BiskilogVersion) + .HasMaxLength(50) + .HasDefaultValueSql("''") + .HasColumnName("biskilog_version") + .UseCollation("utf8mb4_general_ci") + .HasCharSet("utf8mb4"); + entity.Property(e => e.BusinessName) + .HasMaxLength(50) + .HasDefaultValueSql("''") + .HasColumnName("business_name") + .UseCollation("utf8mb4_general_ci") + .HasCharSet("utf8mb4"); + entity.Property(e => e.DateJoined) + .HasDefaultValueSql("current_timestamp()") + .HasColumnType("datetime") + .HasColumnName("date_joined"); + entity.Property(e => e.BusinessExternalId) + .HasMaxLength(50) + .HasDefaultValueSql("''") + .HasColumnName("businessExternalId") + .UseCollation("utf8mb4_general_ci") + .HasCharSet("utf8mb4"); + + }); + + modelBuilder.Entity(entity => + { + entity.HasKey(e => e.ClientId).HasName("PRIMARY"); + + entity + .ToTable("clientinfo") + .HasCharSet("utf8") + .UseCollation("utf8_general_ci"); + + entity.Property(e => e.ClientId) + .HasColumnType("int(11)") + .HasColumnName("clientID"); + entity.Property(e => e.Email) + .HasMaxLength(200) + .HasColumnName("email") + .UseCollation("utf8mb4_general_ci") + .HasCharSet("utf8mb4"); + entity.Property(e => e.Fullname) + .HasMaxLength(200) + .UseCollation("utf8mb4_general_ci") + .HasCharSet("utf8mb4"); + entity.Property(e => e.PhoneNumber) + .HasMaxLength(200) + .HasColumnName("phoneNumber") + .UseCollation("utf8mb4_general_ci") + .HasCharSet("utf8mb4"); + }); + + modelBuilder.Entity(entity => + { + entity.HasKey(e => e.ContractId).HasName("PRIMARY"); + + entity + .ToTable("contracts") + .HasCharSet("utf8") + .UseCollation("utf8_general_ci"); + + entity.HasIndex(e => new { e.ClientId, e.BusinessId }, "clientId_businessId").IsUnique(); + + entity.Property(e => e.ContractId) + .HasColumnType("int(11)") + .HasColumnName("contractId"); + entity.Property(e => e.Bill) + .HasPrecision(18, 2) + .HasColumnName("bill"); + entity.Property(e => e.BusinessId) + .HasColumnType("int(11)") + .HasColumnName("businessId"); + entity.Property(e => e.ClientId) + .HasColumnType("int(11)") + .HasColumnName("clientId"); + entity.Property(e => e.Comments) + .HasColumnType("text") + .HasColumnName("comments") + .UseCollation("utf8mb4_general_ci") + .HasCharSet("utf8mb4"); + entity.Property(e => e.EndDate) + .HasColumnType("datetime") + .HasColumnName("end_date"); + entity.Property(e => e.StartDate) + .HasColumnType("datetime") + .HasColumnName("start_date"); + }); + + modelBuilder.Entity(entity => + { + entity.HasKey(e => e.DbNo).HasName("PRIMARY"); + + entity + .ToTable("databasemap") + .HasCharSet("utf8") + .UseCollation("utf8_general_ci"); + + entity.HasIndex(e => e.ClientId, "businessId").IsUnique(); + + entity.Property(e => e.DbNo) + .HasColumnType("int(11)") + .HasColumnName("db_no"); + entity.Property(e => e.ClientId) + .HasColumnType("int(11)") + .HasColumnName("clientID"); + entity.Property(e => e.DbName) + .HasMaxLength(50) + .HasDefaultValueSql("''") + .HasColumnName("db_name") + .UseCollation("utf8mb4_general_ci") + .HasCharSet("utf8mb4"); + entity.Property(e => e.Domain) + .HasMaxLength(50) + .HasDefaultValueSql("''") + .HasColumnName("domain") + .UseCollation("utf8mb4_general_ci") + .HasCharSet("utf8mb4"); + entity.Property(e => e.LastSyncDate) + .HasColumnType("datetime") + .HasColumnName("last_sync_date"); + }); + + modelBuilder.Entity(entity => + { + entity.HasKey(e => new { e.UserId, e.BusinessId, e.ClientId }) + .HasName("PRIMARY") + .HasAnnotation("MySql:IndexPrefixLength", new[] { 0, 0, 0 }); + + entity + .ToTable("siteaccesspermission") + .HasCharSet("utf8") + .UseCollation("utf8_general_ci"); + + entity.Property(e => e.UserId) + .HasColumnType("int(11)") + .HasColumnName("userID"); + entity.Property(e => e.BusinessId) + .HasComment("businessIds could also been seen as branchID") + .HasColumnType("int(11)") + .HasColumnName("businessId"); + entity.Property(e => e.ClientId) + .HasColumnType("int(11)") + .HasColumnName("clientId"); + }); + + modelBuilder.Entity(entity => + { + entity.HasKey(e => e.UserId).HasName("PRIMARY"); + + entity + .ToTable("userauth") + .HasCharSet("utf8") + .UseCollation("utf8_general_ci"); + + entity.HasIndex(e => e.AuthType, "authType"); + + entity.HasIndex(e => new { e.ClientId, e.Username, e.Email }, "clientId_username_email").IsUnique(); + + entity.Property(e => e.UserId) + .HasColumnType("int(11)") + .HasColumnName("userId"); + entity.Property(e => e.AuthType) + .HasColumnType("int(11)") + .HasColumnName("authType"); + entity.Property(e => e.ClientId) + .HasColumnType("int(11)") + .HasColumnName("clientId"); + entity.Property(e => e.Email) + .HasMaxLength(200) + .HasColumnName("email") + .UseCollation("utf8mb4_general_ci") + .HasCharSet("utf8mb4"); + entity.Property(e => e.Isactive) + .HasColumnType("bit(1)") + .HasColumnName("isactive"); + entity.Property(e => e.Isowner) + .HasColumnType("bit(1)") + .HasColumnName("isowner"); + entity.Property(e => e.LastLogin) + .HasColumnType("datetime") + .HasColumnName("last_login"); + entity.Property(e => e.Passsword) + .HasMaxLength(200) + .HasColumnName("passsword") + .UseCollation("utf8mb4_general_ci") + .HasCharSet("utf8mb4"); + entity.Property(e => e.PhoneNumber) + .HasMaxLength(50) + .HasColumnName("phoneNumber") + .UseCollation("utf8mb4_general_ci") + .HasCharSet("utf8mb4"); + entity.Property(e => e.Username) + .HasMaxLength(30) + .HasColumnName("username") + .UseCollation("utf8mb4_general_ci") + .HasCharSet("utf8mb4"); + }); + + OnModelCreatingPartial(modelBuilder); + } + + partial void OnModelCreatingPartial(ModelBuilder modelBuilder); +} diff --git a/ServerManager/ServerManager.csproj b/ServerManager/ServerManager.csproj index f4f1c1b..c991855 100644 --- a/ServerManager/ServerManager.csproj +++ b/ServerManager/ServerManager.csproj @@ -1,4 +1,4 @@ - + net7.0 @@ -27,5 +27,7 @@ - + + + diff --git a/ServerManager/appsettings.json b/ServerManager/appsettings.json index 10f68b8..984fb06 100644 --- a/ServerManager/appsettings.json +++ b/ServerManager/appsettings.json @@ -5,5 +5,14 @@ "Microsoft.AspNetCore": "Warning" } }, - "AllowedHosts": "*" -} + "ConnectionStrings": { + "Connection": "server=54.37.19.162;database=dev_biskilogclients;user=biskilog;password=mefbuk-6niFsu-fytrew", + "PrivateConnection": "server={0};database={1};user=biskilog;password=mefbuk-6niFsu-fytrew;default command timeout=0;" + }, + "AllowedHosts": "*", + "JWT": { + "Key": "@@BISKILOGACCOUNTING2023DEV??//##$", + "Issuer": "AUTH SERVER", + "Audience": "BISKILOG" + } +} \ No newline at end of file diff --git a/Shared/ServiceRepo/CalculatorService.cs b/Shared/ServiceRepo/CalculatorService.cs deleted file mode 100644 index 2bf104d..0000000 --- a/Shared/ServiceRepo/CalculatorService.cs +++ /dev/null @@ -1,63 +0,0 @@ -using Biskilog_Cloud.Shared.Interfaces; -using System; -using System.Collections.Generic; -using System.Globalization; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Biskilog_Cloud.Shared.ServiceRepo -{ - public class CalculatorService : ICalculator - { - public double CalculatePercentage() - { - throw new NotImplementedException(); - } - - public string FormatMoneyWithCurrency(double a_amount) - { - return string.Format(GetCurrencyCode(), " {0:C2}", a_amount); - } - public string FormatMoneyWithCurrencyKilo(double a_amount) - { - return GetCurrencyCode().CurrencySymbol + FormatNumber(a_amount); - } - public NumberFormatInfo GetCurrencyCode() - { - //TODO have a better implementation - - // Specify the locale for Ghana - string locale = "en-GH"; - - // Get the NumberFormatInfo for the specified locale - NumberFormatInfo numberFormatInfo = new CultureInfo(locale).NumberFormat; - - // Set the currency symbol to Ghanaian cedi - numberFormatInfo.CurrencySymbol = "GH₵ "; - - return numberFormatInfo; - } - private string FormatNumber(double a_amount) - { - if (a_amount >= 100000000) - { - return (a_amount / 1000000D).ToString("0.#M"); - } - if (a_amount >= 1000000) - { - return (a_amount / 1000000D).ToString("0.##M"); - } - if (a_amount >= 100000) - { - return (a_amount / 1000D).ToString("0.#k"); - } - if (a_amount >= 10000) - { - return (a_amount / 1000D).ToString("0.##k"); - } - - return a_amount.ToString("#,0"); - } - } -} diff --git a/Shared/ServiceRepo/SearchService.cs b/Shared/ServiceRepo/SearchService.cs deleted file mode 100644 index 0af6ab3..0000000 --- a/Shared/ServiceRepo/SearchService.cs +++ /dev/null @@ -1,33 +0,0 @@ -using Biskilog_Cloud.Shared.Interfaces; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Biskilog_Cloud.Shared.ServiceRepo -{ - public class SearchService : ISearchService - { - public event Action SearchValueChanged; - public event Action ClearTextBox; - - // Method that raises the event - protected virtual void OnSearchValueChanged(string a_searchKey) - { - SearchValueChanged?.Invoke(a_searchKey); - } - - // Method that triggers the event - public void PerformSearch(string a_searchKey) - { - OnSearchValueChanged(a_searchKey); - } - - public void Clear() - { - ClearTextBox?.Invoke(); - } - } - -}