From bc14a32230258ba21d3f1b19b65a3bd83655828d Mon Sep 17 00:00:00 2001 From: barhen Date: Sun, 2 Jul 2023 10:44:02 -0500 Subject: [PATCH] Cloud setup --- Biskilog_Cloud.sln | 18 +- .../Controllers/WeatherForecastController.cs | 32 +++ ServerManager/Program.cs | 31 ++- ServerManager/Properties/launchSettings.json | 34 ++- ServerManager/ServerManager.csproj | 38 ++- ServerManager/WeatherForecast.cs | 12 + ServerManager/Worker.cs | 22 +- ServerManager/appsettings.Development.json | 2 +- ServerManager/appsettings.json | 5 +- Shared/Biskilog_Cloud.Shared.csproj | 22 ++ Shared/ClientContractModels/Authtype.cs | 11 + Shared/ClientContractModels/Clientbusiness.cs | 21 ++ Shared/ClientContractModels/Clientinfo.cs | 15 ++ Shared/ClientContractModels/Contract.cs | 21 ++ Shared/ClientContractModels/Databasemap.cs | 16 ++ .../Siteaccesspermission.cs | 16 ++ Shared/ClientContractModels/Userauth.cs | 27 ++ Shared/CustomModels/CancelledSales.cs | 16 ++ Shared/CustomModels/CustomerAccounts.cs | 15 ++ Shared/CustomModels/MostPurchaseItem.cs | 29 +++ Shared/CustomModels/ProductItem.cs | 18 ++ Shared/CustomModels/ProductPriceChange.cs | 23 ++ Shared/CustomModels/ProductUnits.cs | 26 ++ Shared/CustomModels/SaleItem.cs | 22 ++ Shared/CustomModels/TradeSummary.cs | 16 ++ Shared/CustomModels/WeeklySaleItem.cs | 21 ++ Shared/Enums/AuthEnums.cs | 17 ++ Shared/Enums/ConnectionEnums.cs | 14 + Shared/Interfaces/IAnalytics.cs | 86 +++++++ Shared/Interfaces/IAuthService.cs | 19 ++ Shared/Interfaces/ICalculator.cs | 17 ++ Shared/Interfaces/ICompanyInfo.cs | 18 ++ Shared/Interfaces/IConnectionService.cs | 24 ++ Shared/Interfaces/ICustomer.cs | 11 + Shared/Interfaces/IMainInterface.cs | 15 ++ Shared/Interfaces/IProducts.cs | 32 +++ Shared/Interfaces/ISalesInterface.cs | 24 ++ Shared/Interfaces/ISearchService.cs | 16 ++ Shared/Interfaces/ITokenService.cs | 22 ++ Shared/Interfaces/IUser.cs | 15 ++ Shared/POSModels/Creditpurchase.cs | 21 ++ Shared/POSModels/Customeraccount.cs | 25 ++ Shared/POSModels/Productaltunit.cs | 21 ++ Shared/POSModels/Restocklevel.cs | 15 ++ Shared/POSModels/Systemuserrole.cs | 19 ++ Shared/POSModels/Tblbranch.cs | 19 ++ Shared/POSModels/Tblbrand.cs | 13 + Shared/POSModels/Tblcancelledtransaction.cs | 17 ++ Shared/POSModels/Tblcart.cs | 35 +++ Shared/POSModels/Tblcategory.cs | 13 + Shared/POSModels/Tblcompanydetail.cs | 21 ++ Shared/POSModels/Tblcustomer.cs | 35 +++ Shared/POSModels/Tblcustomerpurchase.cs | 15 ++ Shared/POSModels/Tbldeliverydetail.cs | 21 ++ Shared/POSModels/Tbldeliveryhead.cs | 25 ++ Shared/POSModels/Tbldeliveryrecipient.cs | 25 ++ Shared/POSModels/Tbldiscountlog.cs | 19 ++ Shared/POSModels/Tbldriver.cs | 33 +++ Shared/POSModels/Tblinventory.cs | 15 ++ Shared/POSModels/Tblinventoryentry.cs | 17 ++ Shared/POSModels/Tblinvoice.cs | 29 +++ Shared/POSModels/Tblpricechange.cs | 19 ++ Shared/POSModels/Tblproduct.cs | 31 +++ Shared/POSModels/Tbltruck.cs | 19 ++ Shared/POSModels/TbltruckDrivermapping.cs | 19 ++ Shared/POSModels/Tbltruckassignment.cs | 21 ++ Shared/POSModels/Tbltruckinventory.cs | 19 ++ Shared/POSModels/Tbluser.cs | 33 +++ Shared/POSModels/Tbstock.cs | 21 ++ Shared/POSModels/Unitofmeasure.cs | 17 ++ Shared/ServiceRepo/CalculatorService.cs | 63 +++++ Shared/ServiceRepo/SearchService.cs | 33 +++ Shared/ServiceRepo/TokenService.cs | 239 ++++++++++++++++++ Shared/SharedClass.cs | 1 + 74 files changed, 1797 insertions(+), 50 deletions(-) create mode 100644 ServerManager/Controllers/WeatherForecastController.cs create mode 100644 ServerManager/WeatherForecast.cs create mode 100644 Shared/Biskilog_Cloud.Shared.csproj create mode 100644 Shared/ClientContractModels/Authtype.cs create mode 100644 Shared/ClientContractModels/Clientbusiness.cs create mode 100644 Shared/ClientContractModels/Clientinfo.cs create mode 100644 Shared/ClientContractModels/Contract.cs create mode 100644 Shared/ClientContractModels/Databasemap.cs create mode 100644 Shared/ClientContractModels/Siteaccesspermission.cs create mode 100644 Shared/ClientContractModels/Userauth.cs create mode 100644 Shared/CustomModels/CancelledSales.cs create mode 100644 Shared/CustomModels/CustomerAccounts.cs create mode 100644 Shared/CustomModels/MostPurchaseItem.cs create mode 100644 Shared/CustomModels/ProductItem.cs create mode 100644 Shared/CustomModels/ProductPriceChange.cs create mode 100644 Shared/CustomModels/ProductUnits.cs create mode 100644 Shared/CustomModels/SaleItem.cs create mode 100644 Shared/CustomModels/TradeSummary.cs create mode 100644 Shared/CustomModels/WeeklySaleItem.cs create mode 100644 Shared/Enums/AuthEnums.cs create mode 100644 Shared/Enums/ConnectionEnums.cs create mode 100644 Shared/Interfaces/IAnalytics.cs create mode 100644 Shared/Interfaces/IAuthService.cs create mode 100644 Shared/Interfaces/ICalculator.cs create mode 100644 Shared/Interfaces/ICompanyInfo.cs create mode 100644 Shared/Interfaces/IConnectionService.cs create mode 100644 Shared/Interfaces/ICustomer.cs create mode 100644 Shared/Interfaces/IMainInterface.cs create mode 100644 Shared/Interfaces/IProducts.cs create mode 100644 Shared/Interfaces/ISalesInterface.cs create mode 100644 Shared/Interfaces/ISearchService.cs create mode 100644 Shared/Interfaces/ITokenService.cs create mode 100644 Shared/Interfaces/IUser.cs create mode 100644 Shared/POSModels/Creditpurchase.cs create mode 100644 Shared/POSModels/Customeraccount.cs create mode 100644 Shared/POSModels/Productaltunit.cs create mode 100644 Shared/POSModels/Restocklevel.cs create mode 100644 Shared/POSModels/Systemuserrole.cs create mode 100644 Shared/POSModels/Tblbranch.cs create mode 100644 Shared/POSModels/Tblbrand.cs create mode 100644 Shared/POSModels/Tblcancelledtransaction.cs create mode 100644 Shared/POSModels/Tblcart.cs create mode 100644 Shared/POSModels/Tblcategory.cs create mode 100644 Shared/POSModels/Tblcompanydetail.cs create mode 100644 Shared/POSModels/Tblcustomer.cs create mode 100644 Shared/POSModels/Tblcustomerpurchase.cs create mode 100644 Shared/POSModels/Tbldeliverydetail.cs create mode 100644 Shared/POSModels/Tbldeliveryhead.cs create mode 100644 Shared/POSModels/Tbldeliveryrecipient.cs create mode 100644 Shared/POSModels/Tbldiscountlog.cs create mode 100644 Shared/POSModels/Tbldriver.cs create mode 100644 Shared/POSModels/Tblinventory.cs create mode 100644 Shared/POSModels/Tblinventoryentry.cs create mode 100644 Shared/POSModels/Tblinvoice.cs create mode 100644 Shared/POSModels/Tblpricechange.cs create mode 100644 Shared/POSModels/Tblproduct.cs create mode 100644 Shared/POSModels/Tbltruck.cs create mode 100644 Shared/POSModels/TbltruckDrivermapping.cs create mode 100644 Shared/POSModels/Tbltruckassignment.cs create mode 100644 Shared/POSModels/Tbltruckinventory.cs create mode 100644 Shared/POSModels/Tbluser.cs create mode 100644 Shared/POSModels/Tbstock.cs create mode 100644 Shared/POSModels/Unitofmeasure.cs create mode 100644 Shared/ServiceRepo/CalculatorService.cs create mode 100644 Shared/ServiceRepo/SearchService.cs create mode 100644 Shared/ServiceRepo/TokenService.cs create mode 100644 Shared/SharedClass.cs diff --git a/Biskilog_Cloud.sln b/Biskilog_Cloud.sln index 63b5b11..72a78cb 100644 --- a/Biskilog_Cloud.sln +++ b/Biskilog_Cloud.sln @@ -3,9 +3,11 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 17 VisualStudioVersion = 17.5.33530.505 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ClientManager", "ClientManager\ClientManager.csproj", "{AD0879FE-FBA8-4CD1-B95A-93E0277FD40F}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ClientManager", "ClientManager\ClientManager.csproj", "{AD0879FE-FBA8-4CD1-B95A-93E0277FD40F}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ServerManager", "ServerManager\ServerManager.csproj", "{7A6AAC33-5ED1-4CAD-AA67-E107245354B3}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ServerManager", "ServerManager\ServerManager.csproj", "{48786C44-14A8-4510-9DC2-167C431DDE95}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Biskilog_Cloud.Shared", "Shared\Biskilog_Cloud.Shared.csproj", "{1D368EE7-D1D3-4D50-83ED-57B0EB9CC6F4}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -17,10 +19,14 @@ Global {AD0879FE-FBA8-4CD1-B95A-93E0277FD40F}.Debug|Any CPU.Build.0 = Debug|Any CPU {AD0879FE-FBA8-4CD1-B95A-93E0277FD40F}.Release|Any CPU.ActiveCfg = Release|Any CPU {AD0879FE-FBA8-4CD1-B95A-93E0277FD40F}.Release|Any CPU.Build.0 = Release|Any CPU - {7A6AAC33-5ED1-4CAD-AA67-E107245354B3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {7A6AAC33-5ED1-4CAD-AA67-E107245354B3}.Debug|Any CPU.Build.0 = Debug|Any CPU - {7A6AAC33-5ED1-4CAD-AA67-E107245354B3}.Release|Any CPU.ActiveCfg = Release|Any CPU - {7A6AAC33-5ED1-4CAD-AA67-E107245354B3}.Release|Any CPU.Build.0 = Release|Any CPU + {48786C44-14A8-4510-9DC2-167C431DDE95}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {48786C44-14A8-4510-9DC2-167C431DDE95}.Debug|Any CPU.Build.0 = Debug|Any CPU + {48786C44-14A8-4510-9DC2-167C431DDE95}.Release|Any CPU.ActiveCfg = Release|Any CPU + {48786C44-14A8-4510-9DC2-167C431DDE95}.Release|Any CPU.Build.0 = Release|Any CPU + {1D368EE7-D1D3-4D50-83ED-57B0EB9CC6F4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {1D368EE7-D1D3-4D50-83ED-57B0EB9CC6F4}.Debug|Any CPU.Build.0 = Debug|Any CPU + {1D368EE7-D1D3-4D50-83ED-57B0EB9CC6F4}.Release|Any CPU.ActiveCfg = Release|Any CPU + {1D368EE7-D1D3-4D50-83ED-57B0EB9CC6F4}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/ServerManager/Controllers/WeatherForecastController.cs b/ServerManager/Controllers/WeatherForecastController.cs new file mode 100644 index 0000000..f720c70 --- /dev/null +++ b/ServerManager/Controllers/WeatherForecastController.cs @@ -0,0 +1,32 @@ +using Microsoft.AspNetCore.Mvc; + +namespace ServerManager.Controllers; + +[ApiController] +[Route("[controller]")] +public class WeatherForecastController : ControllerBase +{ + private static readonly string[] Summaries = new[] + { + "Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching" + }; + + private readonly ILogger _logger; + + public WeatherForecastController(ILogger logger) + { + _logger = logger; + } + + [HttpGet(Name = "GetWeatherForecast")] + public IEnumerable Get() + { + return Enumerable.Range(1, 5).Select(index => new WeatherForecast + { + Date = DateOnly.FromDateTime(DateTime.Now.AddDays(index)), + TemperatureC = Random.Shared.Next(-20, 55), + Summary = Summaries[Random.Shared.Next(Summaries.Length)] + }) + .ToArray(); + } +} diff --git a/ServerManager/Program.cs b/ServerManager/Program.cs index 15b1d11..1e614fc 100644 --- a/ServerManager/Program.cs +++ b/ServerManager/Program.cs @@ -1,10 +1,25 @@ -using ServerManager; +var builder = WebApplication.CreateBuilder(args); -IHost host = Host.CreateDefaultBuilder(args) - .ConfigureServices(services => - { - services.AddHostedService(); - }) - .Build(); +// Add services to the container. +builder.Services.AddSignalR(); +builder.Services.AddControllers(); +// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle +builder.Services.AddEndpointsApiExplorer(); +builder.Services.AddSwaggerGen(); -host.Run(); +var app = builder.Build(); + +// Configure the HTTP request pipeline. +if (app.Environment.IsDevelopment()) +{ + app.UseSwagger(); + app.UseSwaggerUI(); +} + +app.UseHttpsRedirection(); + +app.UseAuthorization(); + +app.MapControllers(); + +app.Run(); diff --git a/ServerManager/Properties/launchSettings.json b/ServerManager/Properties/launchSettings.json index 5699968..e3833aa 100644 --- a/ServerManager/Properties/launchSettings.json +++ b/ServerManager/Properties/launchSettings.json @@ -1,10 +1,40 @@ { + "$schema": "https://json.schemastore.org/launchsettings.json", + "iisSettings": { + "windowsAuthentication": false, + "anonymousAuthentication": true, + "iisExpress": { + "applicationUrl": "http://localhost:21664", + "sslPort": 44321 + } + }, "profiles": { - "ServerManager": { + "http": { "commandName": "Project", "dotnetRunMessages": true, + "launchBrowser": true, + "launchUrl": "swagger", + "applicationUrl": "http://localhost:5110", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "https": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": true, + "launchUrl": "swagger", + "applicationUrl": "https://localhost:7022;http://localhost:5110", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "IIS Express": { + "commandName": "IISExpress", + "launchBrowser": true, + "launchUrl": "swagger", "environmentVariables": { - "DOTNET_ENVIRONMENT": "Development" + "ASPNETCORE_ENVIRONMENT": "Development" } } } diff --git a/ServerManager/ServerManager.csproj b/ServerManager/ServerManager.csproj index 3095783..f4f1c1b 100644 --- a/ServerManager/ServerManager.csproj +++ b/ServerManager/ServerManager.csproj @@ -1,13 +1,31 @@ - + - - net7.0 - enable - enable - dotnet-ServerManager-52a85e73-fd4f-461a-8b7b-99494934c716 - + + net7.0 + enable + enable + + + + + + + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + + - - - diff --git a/ServerManager/WeatherForecast.cs b/ServerManager/WeatherForecast.cs new file mode 100644 index 0000000..15ad497 --- /dev/null +++ b/ServerManager/WeatherForecast.cs @@ -0,0 +1,12 @@ +namespace ServerManager; + +public class WeatherForecast +{ + public DateOnly Date { get; set; } + + public int TemperatureC { get; set; } + + public int TemperatureF => 32 + (int)(TemperatureC / 0.5556); + + public string? Summary { get; set; } +} diff --git a/ServerManager/Worker.cs b/ServerManager/Worker.cs index 846bd2d..5f28270 100644 --- a/ServerManager/Worker.cs +++ b/ServerManager/Worker.cs @@ -1,21 +1 @@ -namespace ServerManager -{ - public class Worker : BackgroundService - { - private readonly ILogger _logger; - - public Worker(ILogger logger) - { - _logger = logger; - } - - protected override async Task ExecuteAsync(CancellationToken stoppingToken) - { - while (!stoppingToken.IsCancellationRequested) - { - _logger.LogInformation("Worker running at: {time}", DateTimeOffset.Now); - await Task.Delay(1000, stoppingToken); - } - } - } -} \ No newline at end of file + \ No newline at end of file diff --git a/ServerManager/appsettings.Development.json b/ServerManager/appsettings.Development.json index b2dcdb6..0c208ae 100644 --- a/ServerManager/appsettings.Development.json +++ b/ServerManager/appsettings.Development.json @@ -2,7 +2,7 @@ "Logging": { "LogLevel": { "Default": "Information", - "Microsoft.Hosting.Lifetime": "Information" + "Microsoft.AspNetCore": "Warning" } } } diff --git a/ServerManager/appsettings.json b/ServerManager/appsettings.json index b2dcdb6..10f68b8 100644 --- a/ServerManager/appsettings.json +++ b/ServerManager/appsettings.json @@ -2,7 +2,8 @@ "Logging": { "LogLevel": { "Default": "Information", - "Microsoft.Hosting.Lifetime": "Information" + "Microsoft.AspNetCore": "Warning" } - } + }, + "AllowedHosts": "*" } diff --git a/Shared/Biskilog_Cloud.Shared.csproj b/Shared/Biskilog_Cloud.Shared.csproj new file mode 100644 index 0000000..4e8ed53 --- /dev/null +++ b/Shared/Biskilog_Cloud.Shared.csproj @@ -0,0 +1,22 @@ + + + + net7.0 + enable + enable + + + + + + + + + + + + + + + + diff --git a/Shared/ClientContractModels/Authtype.cs b/Shared/ClientContractModels/Authtype.cs new file mode 100644 index 0000000..d54bd04 --- /dev/null +++ b/Shared/ClientContractModels/Authtype.cs @@ -0,0 +1,11 @@ +using System; +using System.Collections.Generic; + +namespace Biskilog_Cloud.Shared.ClientContractModels; + +public partial class Authtype +{ + public int Id { get; set; } + + public string? Type { get; set; } +} diff --git a/Shared/ClientContractModels/Clientbusiness.cs b/Shared/ClientContractModels/Clientbusiness.cs new file mode 100644 index 0000000..6dc3766 --- /dev/null +++ b/Shared/ClientContractModels/Clientbusiness.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; + +namespace Biskilog_Cloud.Shared.ClientContractModels; + +public partial class Clientbusiness +{ + /// + /// there could be multiple branches of the same business + /// + public int BusinessId { get; set; } + + public int ClientId { get; set; } + + public string BusinessName { get; set; } = null!; + + public string BiskilogVersion { get; set; } = null!; + + public DateTime DateJoined { get; set; } + public string BusinessExternalId { get; set; } = string.Empty!; +} diff --git a/Shared/ClientContractModels/Clientinfo.cs b/Shared/ClientContractModels/Clientinfo.cs new file mode 100644 index 0000000..c08c0cf --- /dev/null +++ b/Shared/ClientContractModels/Clientinfo.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; + +namespace Biskilog_Cloud.Shared.ClientContractModels; + +public partial class Clientinfo +{ + public int ClientId { get; set; } + + public string? Fullname { get; set; } + + public string? PhoneNumber { get; set; } + + public string? Email { get; set; } +} diff --git a/Shared/ClientContractModels/Contract.cs b/Shared/ClientContractModels/Contract.cs new file mode 100644 index 0000000..049bad2 --- /dev/null +++ b/Shared/ClientContractModels/Contract.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; + +namespace Biskilog_Cloud.Shared.ClientContractModels; + +public partial class Contract +{ + public int ContractId { get; set; } + + public int ClientId { get; set; } + + public int? BusinessId { get; set; } + + public DateTime? StartDate { get; set; } + + public DateTime? EndDate { get; set; } + + public decimal? Bill { get; set; } + + public string Comments { get; set; } = null!; +} diff --git a/Shared/ClientContractModels/Databasemap.cs b/Shared/ClientContractModels/Databasemap.cs new file mode 100644 index 0000000..f0ab40f --- /dev/null +++ b/Shared/ClientContractModels/Databasemap.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; + +namespace Biskilog_Cloud.Shared.ClientContractModels; + +public partial class Databasemap +{ + public int DbNo { get; set; } + + public string DbName { get; set; } = null!; + + public int ClientId { get; set; } + public string Domain { get; set; } + + public DateTime LastSyncDate { get; set; } +} diff --git a/Shared/ClientContractModels/Siteaccesspermission.cs b/Shared/ClientContractModels/Siteaccesspermission.cs new file mode 100644 index 0000000..b09b408 --- /dev/null +++ b/Shared/ClientContractModels/Siteaccesspermission.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; + +namespace Biskilog_Cloud.Shared.ClientContractModels; + +public partial class Siteaccesspermission +{ + public int UserId { get; set; } + + /// + /// businessIds could also been seen as branchID + /// + public int BusinessId { get; set; } + + public int ClientId { get; set; } +} diff --git a/Shared/ClientContractModels/Userauth.cs b/Shared/ClientContractModels/Userauth.cs new file mode 100644 index 0000000..f8960b9 --- /dev/null +++ b/Shared/ClientContractModels/Userauth.cs @@ -0,0 +1,27 @@ +using System; +using System.Collections.Generic; + +namespace Biskilog_Cloud.Shared.ClientContractModels; + +public partial class Userauth +{ + public int UserId { get; set; } + + public int ClientId { get; set; } + + public string? Username { get; set; } + + public string? Email { get; set; } + + public string? Passsword { get; set; } + + public string? PhoneNumber { get; set; } + + public int AuthType { get; set; } + + public ulong Isactive { get; set; } + + public ulong? Isowner { get; set; } + + public DateTime? LastLogin { get; set; } +} diff --git a/Shared/CustomModels/CancelledSales.cs b/Shared/CustomModels/CancelledSales.cs new file mode 100644 index 0000000..77a2148 --- /dev/null +++ b/Shared/CustomModels/CancelledSales.cs @@ -0,0 +1,16 @@ +using Biskilog_Cloud.Shared.POSModels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Biskilog_Cloud.Shared.CustomModels +{ + public class CancelledSales + { + public Tblcancelledtransaction? CancelledTransaction { get; set; } + public string Customer { get; set; } = "WALK-IN Purchase"; + public decimal? Value { get; set; } + } +} diff --git a/Shared/CustomModels/CustomerAccounts.cs b/Shared/CustomModels/CustomerAccounts.cs new file mode 100644 index 0000000..a55e838 --- /dev/null +++ b/Shared/CustomModels/CustomerAccounts.cs @@ -0,0 +1,15 @@ +using Biskilog_Cloud.Shared.POSModels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Biskilog_Cloud.Shared.CustomModels +{ + public class CustomerAccounts + { + public Tblcustomer Customer { get; set; } + public decimal Debt { get; set; } = 0; + } +} diff --git a/Shared/CustomModels/MostPurchaseItem.cs b/Shared/CustomModels/MostPurchaseItem.cs new file mode 100644 index 0000000..2ff58ea --- /dev/null +++ b/Shared/CustomModels/MostPurchaseItem.cs @@ -0,0 +1,29 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Biskilog_Cloud.Shared.CustomModels +{ + public class MostPurchasedItem + { + /// + /// Specifies the id of the product + /// + public string ProductId { get; set; } = string.Empty; + /// + /// Specifies the name of the product + /// + public string ProductName { get; set; } = string.Empty; + /// + /// The total revenue generated from the sale + /// + public decimal? Revenue { get; set; } + /// + /// This is the number of times the item has been sold + /// + public int? NbrTimesSold { get; set; } + + } +} diff --git a/Shared/CustomModels/ProductItem.cs b/Shared/CustomModels/ProductItem.cs new file mode 100644 index 0000000..07fad59 --- /dev/null +++ b/Shared/CustomModels/ProductItem.cs @@ -0,0 +1,18 @@ +using Biskilog_Cloud.Shared.POSModels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Biskilog_Cloud.Shared.CustomModels +{ + public class ProductItem + { + public Tblproduct? Product { get; set; } + public Tblinventory? Stock { get; set; } + public Restocklevel? Restocklevel { get; set; } + public List Units { get; set; } = new List(); + public string BaseUnit { get; set; } = string.Empty; + } +} diff --git a/Shared/CustomModels/ProductPriceChange.cs b/Shared/CustomModels/ProductPriceChange.cs new file mode 100644 index 0000000..0750961 --- /dev/null +++ b/Shared/CustomModels/ProductPriceChange.cs @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Biskilog_Cloud.Shared.CustomModels +{ + public class ProductPriceChange + { + public string? Pcode { get; set; } + public string? ProductName { get; set; } + public decimal? PreviousPrice { get; set; } + + public decimal? CurrentPrice { get; set; } + + public DateTime? ChangeDate { get; set; } + + public string BranchId { get; set; } = null!; + + public string CountId { get; set; } = null!; + } +} diff --git a/Shared/CustomModels/ProductUnits.cs b/Shared/CustomModels/ProductUnits.cs new file mode 100644 index 0000000..e50ebc1 --- /dev/null +++ b/Shared/CustomModels/ProductUnits.cs @@ -0,0 +1,26 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Biskilog_Cloud.Shared.CustomModels +{ + public class ProductUnits + { + public string? Pcode { get; set; } + + public string? UnitCode { get; set; } + public string? UnitName { get; set; } + + public string? UnitBarcode { get; set; } + + public decimal? PriceUnit { get; set; } + + public int? QuantityUnit { get; set; } + + public string DistinctiveCode { get; set; } = null!; + + public string BranchId { get; set; } = null!; + } +} diff --git a/Shared/CustomModels/SaleItem.cs b/Shared/CustomModels/SaleItem.cs new file mode 100644 index 0000000..b88673a --- /dev/null +++ b/Shared/CustomModels/SaleItem.cs @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Biskilog_Cloud.Shared.CustomModels +{ + public class SaleItem + { + public string? Transno { get; set; } + + public DateTime? Date { get; set; } + + public string? Cashier { get; set; } + public string? Status { get; set; } + public decimal? Total { get; set; } + public string BranchId { get; set; } = null!; + + public string Customer { get; set; } = "Walk-In Purchase"!; + } +} diff --git a/Shared/CustomModels/TradeSummary.cs b/Shared/CustomModels/TradeSummary.cs new file mode 100644 index 0000000..895397c --- /dev/null +++ b/Shared/CustomModels/TradeSummary.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Biskilog_Cloud.Shared.CustomModels +{ + public class TradeSummary + { + public DateTime CurrentTradeDate { get; set; } = DateTime.Now; + public DateTime LastTradeDate { get; set; } = DateTime.Now.AddDays(-1); + public double CurrentTradeSales { get; set; } = 0; + public double LastTradeSales { get; set; } = 0; + } +} diff --git a/Shared/CustomModels/WeeklySaleItem.cs b/Shared/CustomModels/WeeklySaleItem.cs new file mode 100644 index 0000000..15667d9 --- /dev/null +++ b/Shared/CustomModels/WeeklySaleItem.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Biskilog_Cloud.Shared.CustomModels +{ + public class WeeklySaleItem + { + public DateTime Date { get; set; } + public decimal? Total { get; set; } + public string BranchId { get; set; } = null!; + } + + public class WeeklyCategorySummary + { + public decimal? Total { get; set; } + public string Category { get; set; } = string.Empty!; + } +} diff --git a/Shared/Enums/AuthEnums.cs b/Shared/Enums/AuthEnums.cs new file mode 100644 index 0000000..26b9726 --- /dev/null +++ b/Shared/Enums/AuthEnums.cs @@ -0,0 +1,17 @@ +namespace Biskilog_Cloud.Shared.Enums +{ + public enum AuthEnums + { + Registered, + AleadyLoggedin, + WrongPassword, + NotFound, + Found, + Expired, + Invalid, + Valid, + Successful, + Error + } +} + diff --git a/Shared/Enums/ConnectionEnums.cs b/Shared/Enums/ConnectionEnums.cs new file mode 100644 index 0000000..caf592b --- /dev/null +++ b/Shared/Enums/ConnectionEnums.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Biskilog_Cloud.Shared.Enums +{ + public enum ConnectionEnums + { + ConnectionEstablished, + ConnectionNotEstablished, + } +} diff --git a/Shared/Interfaces/IAnalytics.cs b/Shared/Interfaces/IAnalytics.cs new file mode 100644 index 0000000..9b136ea --- /dev/null +++ b/Shared/Interfaces/IAnalytics.cs @@ -0,0 +1,86 @@ +using Biskilog_Cloud.Shared.CustomModels; +using Biskilog_Cloud.Shared.POSModels; + +namespace Biskilog_Cloud.Shared.Interfaces +{ + public interface IAnalytics + { + /// + /// Fetches a collection of sales transaction made from the specified start date to the end date + /// + /// Specified Start Date + /// Specified end Date + /// + IEnumerable GetSalesTransaction(DateTime a_start, DateTime a_end); + /// + /// Fetches a collection of sales transaction made within a one week period + /// + /// + IEnumerable GetWeeklySalesTransaction(); + /// + /// Fetches a collection of in-debt customers + /// + IEnumerable GetInDebtCustomers(); + /// + /// Fetches a collection of Product Items which are currently out of stock + /// + /// + IEnumerable GetOutOfStockItems(); + /// + /// Fetches a collection of the most purchased Product Items within a specified date range + /// + /// + /// + /// + IEnumerable GetMostPurchasedItem(DateTime a_start, DateTime a_end); + /// + /// Fetches a collection of cancelled transaction within a specified date range + /// + /// + /// + /// + IEnumerable GetCancelledSales(DateTime a_start, DateTime a_end); + /// + /// Fetches a collection of transaction made by employees within a specified date range + /// + /// + /// + /// A dictionary of transactions made by employees with employee name as key + Dictionary> GetEmployeeSales(DateTime a_start, DateTime a_end); + /// + /// Fetches a collection of product price changes with a specified date range + /// + /// + /// + /// + IEnumerable GetPriceChanges(DateTime a_start, DateTime a_end); + /// + /// Fetch the trade summary which is made of the total sales made currently and previous trade + /// + /// + TradeSummary GetTradeSummary(); + /// + /// Fetches the most recent sales transactions + /// + /// The number of rows to return + /// + IEnumerable GetRecentSales(int a_limit); + /// + /// Fetches a collection of product price changes recently made + /// + /// the number of rows to return + /// + IEnumerable GetRecentPriceChanges(int a_limit); + /// + /// Fetches a collection of price change history per product + /// + /// the number of products to fetch history + /// + IEnumerable GetProductPriceChangeHistory(int a_limit); + /// + /// Fetches a collection of sales transaction grouped by category made within a one week period + /// + /// + IEnumerable GetWeeklySalesCategoryTransaction(int a_limit); + } +} diff --git a/Shared/Interfaces/IAuthService.cs b/Shared/Interfaces/IAuthService.cs new file mode 100644 index 0000000..a72f077 --- /dev/null +++ b/Shared/Interfaces/IAuthService.cs @@ -0,0 +1,19 @@ +using Biskilog_Cloud.Shared.ClientContractModels; + +namespace Biskilog_Cloud.Shared.Interfaces +{ + public interface IAuthService + { + /// + /// Authenticates user or client + /// + /// + /// + /// A tokenized string with relevant information on the authenticated user + Task AuthenticateClient(string a_username, string a_password); + Contract? GetContract(int a_clientId, List a_businessId); + Databasemap GetClientDB(int a_clientId); + List GetSiteaccesspermission(int a_clientId, int a_userId); + List GetClientbusiness(int a_clientId, int userId); + } +} diff --git a/Shared/Interfaces/ICalculator.cs b/Shared/Interfaces/ICalculator.cs new file mode 100644 index 0000000..80b2c06 --- /dev/null +++ b/Shared/Interfaces/ICalculator.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Biskilog_Cloud.Shared.Interfaces +{ + public interface ICalculator + { + double CalculatePercentage(); + string FormatMoneyWithCurrency(double a_amount); + string FormatMoneyWithCurrencyKilo(double a_amount); + NumberFormatInfo GetCurrencyCode(); + } +} diff --git a/Shared/Interfaces/ICompanyInfo.cs b/Shared/Interfaces/ICompanyInfo.cs new file mode 100644 index 0000000..124a28f --- /dev/null +++ b/Shared/Interfaces/ICompanyInfo.cs @@ -0,0 +1,18 @@ +using Biskilog_Cloud.Shared.POSModels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Biskilog_Cloud.Shared.Interfaces +{ + public interface ICompanyInfo + { + IEnumerable FetchBranches(); + Task GetCompanyInfoAsync(); + Task> GetBranches(); + string GetCompanyName(); + string GetBranchName(string a_branchId); + } +} diff --git a/Shared/Interfaces/IConnectionService.cs b/Shared/Interfaces/IConnectionService.cs new file mode 100644 index 0000000..3a80bb3 --- /dev/null +++ b/Shared/Interfaces/IConnectionService.cs @@ -0,0 +1,24 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Biskilog_Cloud.Shared.Interfaces +{ + public interface IConnectionService + { + /// + /// Prepares and returns the connection string for a client using the specified database id + /// + /// Specified database id to use + /// + string GetClientConnectionString(int a_databaseId); + /// + /// Prepare the DB context from the specified connection string + /// + /// + /// A configured BiskAcdbContext + object PrepareDBContext(string a_connectionString); + } +} diff --git a/Shared/Interfaces/ICustomer.cs b/Shared/Interfaces/ICustomer.cs new file mode 100644 index 0000000..e0870e3 --- /dev/null +++ b/Shared/Interfaces/ICustomer.cs @@ -0,0 +1,11 @@ +using Biskilog_Cloud.Shared.CustomModels; +using Biskilog_Cloud.Shared.POSModels; + +namespace Biskilog_Cloud.Shared.Interfaces +{ + public interface ICustomer + { + IEnumerable FetchCustomers(); + Task> GetCustomers(); + } +} diff --git a/Shared/Interfaces/IMainInterface.cs b/Shared/Interfaces/IMainInterface.cs new file mode 100644 index 0000000..8e565e0 --- /dev/null +++ b/Shared/Interfaces/IMainInterface.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Biskilog_Cloud.Shared.Interfaces +{ + public interface IMainInterface + { + void ShowReceipt(string a_receipt); + DateOnly CurrentTradeDate(); + DateOnly PreviousTradeDate(); + } +} diff --git a/Shared/Interfaces/IProducts.cs b/Shared/Interfaces/IProducts.cs new file mode 100644 index 0000000..3607168 --- /dev/null +++ b/Shared/Interfaces/IProducts.cs @@ -0,0 +1,32 @@ +using Biskilog_Cloud.Shared.CustomModels; +using Biskilog_Cloud.Shared.POSModels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Biskilog_Cloud.Shared.Interfaces +{ + public interface IProduct + { + IEnumerable GetUnitofmeasures(); + IEnumerable GetProducts(string a_productKey = ""); + IEnumerable GetBrands(string a_brandKey = ""); + IEnumerable GetCategories(string a_categoryKey = ""); + IEnumerable GetLowstockItems(); + Task FetchProducts(); + Task FetchLowStockProducts(); + Task FetchUnits(); + Task FetchBrands(); + Task FetchCategories(); + void RefreshList(); + ProductItem GetProductById(string a_id); + ProductItem GetProductByName(string name); + string GetUnitName(string a_unitCode); + event EventHandler ProductsChanged; + event EventHandler UnitsChanged; + event EventHandler BrandsChanged; + event EventHandler CategoriesChanged; + } +} diff --git a/Shared/Interfaces/ISalesInterface.cs b/Shared/Interfaces/ISalesInterface.cs new file mode 100644 index 0000000..17e7d9b --- /dev/null +++ b/Shared/Interfaces/ISalesInterface.cs @@ -0,0 +1,24 @@ +using Biskilog_Cloud.Shared.CustomModels; +using Biskilog_Cloud.Shared.POSModels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Biskilog_Cloud.Shared.Interfaces +{ + public interface ISalesInterface + { + Task FetchRecentTransaction(int a_limit); + Task FetchTransaction(DateTime a_start, DateTime a_end); + IEnumerable GetTransactions(DateTime a_start, DateTime a_end); + IEnumerable GetRecentTransaction(); + Task FetchReceipt(string a_receiptId); + IEnumerable GetReceipt(string a_receiptId); + Task> GetReceiptDetail(string a_receiptId); + event EventHandler TransactionsChanged; + event EventHandler FetchComplete; + event EventHandler FetchStart; + } +} diff --git a/Shared/Interfaces/ISearchService.cs b/Shared/Interfaces/ISearchService.cs new file mode 100644 index 0000000..4d96e90 --- /dev/null +++ b/Shared/Interfaces/ISearchService.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Biskilog_Cloud.Shared.Interfaces +{ + public interface ISearchService + { + public event Action SearchValueChanged; + public event Action ClearTextBox; + void PerformSearch(string a_searchKey); + void Clear(); + } +} diff --git a/Shared/Interfaces/ITokenService.cs b/Shared/Interfaces/ITokenService.cs new file mode 100644 index 0000000..d9a8076 --- /dev/null +++ b/Shared/Interfaces/ITokenService.cs @@ -0,0 +1,22 @@ +using Biskilog_Cloud.Shared.ClientContractModels; +using Biskilog_Cloud.Shared.Enums; + +namespace Biskilog_Cloud.Shared.Interfaces +{ + public interface ITokenService + { + AuthEnums ValidateToken(string a_token); + string GenerateToken(Userauth a_user, Contract a_clientContract, Databasemap a_database, List a_business, bool a_comparison); + int? GetDatabaseIdFromToken(string a_token); + int? GetUserIdFromToken(string a_token); + string? GetUserNameFromToken(string a_token); + string? GetBaseBranch(string a_token); + bool? GetComparison(string a_token); + IEnumerable BranchIds(string a_token); + string? GetAllBranch(string a_token); + Task SetToken(string a_token, bool a_remember); + Task GetToken(); + Task ClearToken(); + Task IsTokenSet(); + } +} diff --git a/Shared/Interfaces/IUser.cs b/Shared/Interfaces/IUser.cs new file mode 100644 index 0000000..d260b21 --- /dev/null +++ b/Shared/Interfaces/IUser.cs @@ -0,0 +1,15 @@ +using Biskilog_Cloud.Shared.POSModels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Biskilog_Cloud.Shared.Interfaces +{ + public interface IUser + { + IEnumerable FetchUsers(); + Task> GetUsers(); + } +} diff --git a/Shared/POSModels/Creditpurchase.cs b/Shared/POSModels/Creditpurchase.cs new file mode 100644 index 0000000..5b1672c --- /dev/null +++ b/Shared/POSModels/Creditpurchase.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; + +namespace Biskilog_Cloud.Shared.POSModels; + +public partial class Creditpurchase +{ + public string ReceiptId { get; set; } = null!; + + public string BranchId { get; set; } = null!; + + public DateTime Date { get; set; } + + public decimal TotalBill { get; set; } + + public decimal Paid { get; set; } + + public string CustomerId { get; set; } = null!; + + public string Status { get; set; } = null!; +} diff --git a/Shared/POSModels/Customeraccount.cs b/Shared/POSModels/Customeraccount.cs new file mode 100644 index 0000000..d406e51 --- /dev/null +++ b/Shared/POSModels/Customeraccount.cs @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; + +namespace Biskilog_Cloud.Shared.POSModels; + +public partial class Customeraccount +{ + public string CustomerId { get; set; } = null!; + + public string TransactionId { get; set; } = null!; + + public DateTime Date { get; set; } + + public decimal Debit { get; set; } + + public decimal Credit { get; set; } + + public decimal Balance { get; set; } + + public string Comments { get; set; } = null!; + + public string BranchId { get; set; } = null!; + + public string CountId { get; set; } = null!; +} diff --git a/Shared/POSModels/Productaltunit.cs b/Shared/POSModels/Productaltunit.cs new file mode 100644 index 0000000..0159f30 --- /dev/null +++ b/Shared/POSModels/Productaltunit.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; + +namespace Biskilog_Cloud.Shared.POSModels; + +public partial class Productaltunit +{ + public string? Pcode { get; set; } + + public string? UnitCode { get; set; } + + public string? UnitBarcode { get; set; } + + public decimal? PriceUnit { get; set; } + + public int? QuantityUnit { get; set; } + + public string DistinctiveCode { get; set; } = null!; + + public string BranchId { get; set; } = null!; +} diff --git a/Shared/POSModels/Restocklevel.cs b/Shared/POSModels/Restocklevel.cs new file mode 100644 index 0000000..54afc49 --- /dev/null +++ b/Shared/POSModels/Restocklevel.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; + +namespace Biskilog_Cloud.Shared.POSModels; + +public partial class Restocklevel +{ + public string ProductId { get; set; } = null!; + + public string BranchId { get; set; } = null!; + + public int? WarnLevel { get; set; } + + public string? Unit { get; set; } +} diff --git a/Shared/POSModels/Systemuserrole.cs b/Shared/POSModels/Systemuserrole.cs new file mode 100644 index 0000000..1137a29 --- /dev/null +++ b/Shared/POSModels/Systemuserrole.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; + +namespace Biskilog_Cloud.Shared.POSModels; + +public partial class Systemuserrole +{ + public string? Roles { get; set; } + + public sbyte? Owner { get; set; } + + public sbyte? Manager { get; set; } + + public sbyte? Assist { get; set; } + + public sbyte? Cashier { get; set; } + + public int Id { get; set; } +} diff --git a/Shared/POSModels/Tblbranch.cs b/Shared/POSModels/Tblbranch.cs new file mode 100644 index 0000000..5094f91 --- /dev/null +++ b/Shared/POSModels/Tblbranch.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; + +namespace Biskilog_Cloud.Shared.POSModels; + +public partial class Tblbranch +{ + public string? BranchName { get; set; } + + public string BranchId { get; set; } = null!; + + public string? Address { get; set; } + + public string? City { get; set; } + + public string? StateOrProvince { get; set; } + + public string? BranchTelephone { get; set; } +} diff --git a/Shared/POSModels/Tblbrand.cs b/Shared/POSModels/Tblbrand.cs new file mode 100644 index 0000000..cde00f6 --- /dev/null +++ b/Shared/POSModels/Tblbrand.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; + +namespace Biskilog_Cloud.Shared.POSModels; + +public partial class Tblbrand +{ + public string Id { get; set; } = null!; + + public string BranchId { get; set; } = null!; + + public string? Brand { get; set; } +} diff --git a/Shared/POSModels/Tblcancelledtransaction.cs b/Shared/POSModels/Tblcancelledtransaction.cs new file mode 100644 index 0000000..a017f57 --- /dev/null +++ b/Shared/POSModels/Tblcancelledtransaction.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; + +namespace Biskilog_Cloud.Shared.POSModels; + +public partial class Tblcancelledtransaction +{ + public string? Transno { get; set; } + + public DateTime? DateCancelled { get; set; } + + public string? CancelledBy { get; set; } + + public string BranchId { get; set; } = null!; + + public string CountId { get; set; } = null!; +} diff --git a/Shared/POSModels/Tblcart.cs b/Shared/POSModels/Tblcart.cs new file mode 100644 index 0000000..aab15c6 --- /dev/null +++ b/Shared/POSModels/Tblcart.cs @@ -0,0 +1,35 @@ +using System; +using System.Collections.Generic; + +namespace Biskilog_Cloud.Shared.POSModels; + +public partial class Tblcart +{ + public string? Transno { get; set; } + + public string? Id { get; set; } + + public int? Quantity { get; set; } + + public DateTime? Date { get; set; } + + public decimal? Price { get; set; } + + public string? Cashier { get; set; } + + public string? Status { get; set; } + + public decimal? Total { get; set; } + + public string? Unit { get; set; } + public decimal? Tendered { get; set; } + public decimal? Balance { get; set; } + public decimal? ValueAddTax { get; set; } + public decimal? Discount { get; set; } = 0; + + public decimal? Costprice { get; set; } + + public string BranchId { get; set; } = null!; + + public string CountId { get; set; } = null!; +} diff --git a/Shared/POSModels/Tblcategory.cs b/Shared/POSModels/Tblcategory.cs new file mode 100644 index 0000000..bdd04b1 --- /dev/null +++ b/Shared/POSModels/Tblcategory.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; + +namespace Biskilog_Cloud.Shared.POSModels; + +public partial class Tblcategory +{ + public string Id { get; set; } = null!; + + public string BranchId { get; set; } = null!; + + public string? Category { get; set; } +} diff --git a/Shared/POSModels/Tblcompanydetail.cs b/Shared/POSModels/Tblcompanydetail.cs new file mode 100644 index 0000000..ed8322c --- /dev/null +++ b/Shared/POSModels/Tblcompanydetail.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; + +namespace Biskilog_Cloud.Shared.POSModels; + +public partial class Tblcompanydetail +{ + public string? CompanyName { get; set; } + + public string? Address { get; set; } + + public string? Website { get; set; } + + public string? Email { get; set; } + + public string Tin { get; set; } = null!; + + public string? MainTelephone { get; set; } + + public string? Vatno { get; set; } +} diff --git a/Shared/POSModels/Tblcustomer.cs b/Shared/POSModels/Tblcustomer.cs new file mode 100644 index 0000000..fa2a220 --- /dev/null +++ b/Shared/POSModels/Tblcustomer.cs @@ -0,0 +1,35 @@ +using System; +using System.Collections.Generic; + +namespace Biskilog_Cloud.Shared.POSModels; + +public partial class Tblcustomer +{ + public string CustomerId { get; set; } = null!; + + public string BranchId { get; set; } = null!; + + public string? Firstname { get; set; } + + public string? Surname { get; set; } + + public string? Address { get; set; } + + public string? Telephone { get; set; } + + public DateTime? DateAdded { get; set; } + + public string? Status { get; set; } + + public string? Tin { get; set; } + + public DateTime? DateExit { get; set; } + + public string? Email { get; set; } + + public string? FinancialStatus { get; set; } + + public string? NameKey1 { get; set; } + + public string? NameKey2 { get; set; } +} diff --git a/Shared/POSModels/Tblcustomerpurchase.cs b/Shared/POSModels/Tblcustomerpurchase.cs new file mode 100644 index 0000000..fa8896e --- /dev/null +++ b/Shared/POSModels/Tblcustomerpurchase.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; + +namespace Biskilog_Cloud.Shared.POSModels; + +public partial class Tblcustomerpurchase +{ + public string? CustomerId { get; set; } + + public string? TransactionId { get; set; } + + public string BranchId { get; set; } = null!; + + public string CountId { get; set; } = null!; +} diff --git a/Shared/POSModels/Tbldeliverydetail.cs b/Shared/POSModels/Tbldeliverydetail.cs new file mode 100644 index 0000000..cab0c0c --- /dev/null +++ b/Shared/POSModels/Tbldeliverydetail.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; + +namespace Biskilog_Cloud.Shared.POSModels; + +public partial class Tbldeliverydetail +{ + public string? DeliveryId { get; set; } + + public string? Pcode { get; set; } + + public int? Quantity { get; set; } + + public string? Unit { get; set; } + + public decimal? Cost { get; set; } + + public string CountId { get; set; } = null!; + + public string BranchId { get; set; } = null!; +} diff --git a/Shared/POSModels/Tbldeliveryhead.cs b/Shared/POSModels/Tbldeliveryhead.cs new file mode 100644 index 0000000..32bf7a8 --- /dev/null +++ b/Shared/POSModels/Tbldeliveryhead.cs @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; + +namespace Biskilog_Cloud.Shared.POSModels; + +public partial class Tbldeliveryhead +{ + public string DeliveryId { get; set; } = null!; + + public string BranchId { get; set; } = null!; + + public string? GeneratedBy { get; set; } + + public DateTime? DateInitiated { get; set; } + + public DateTime? DateCompleted { get; set; } + + public string? Destination { get; set; } + + public string? CustomerId { get; set; } + + public decimal? TotalCost { get; set; } + + public string? Status { get; set; } +} diff --git a/Shared/POSModels/Tbldeliveryrecipient.cs b/Shared/POSModels/Tbldeliveryrecipient.cs new file mode 100644 index 0000000..0316678 --- /dev/null +++ b/Shared/POSModels/Tbldeliveryrecipient.cs @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; + +namespace Biskilog_Cloud.Shared.POSModels; + +public partial class Tbldeliveryrecipient +{ + public string DeliveryId { get; set; } = null!; + + public string BranchId { get; set; } = null!; + + public string? Fullname { get; set; } + + public string? Address { get; set; } + + public string? Telephone { get; set; } + + public string? Email { get; set; } + + public string? CustomerId { get; set; } + + public DateOnly? FromDate { get; set; } + + public DateOnly? ToDate { get; set; } +} diff --git a/Shared/POSModels/Tbldiscountlog.cs b/Shared/POSModels/Tbldiscountlog.cs new file mode 100644 index 0000000..ef04d2a --- /dev/null +++ b/Shared/POSModels/Tbldiscountlog.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; + +namespace Biskilog_Cloud.Shared.POSModels; + +public partial class Tbldiscountlog +{ + public string? ReceiptId { get; set; } + + public string? Cashier { get; set; } + + public DateTime? Date { get; set; } + + public decimal? Discount { get; set; } + + public string BranchId { get; set; } = null!; + + public string CountId { get; set; } = null!; +} diff --git a/Shared/POSModels/Tbldriver.cs b/Shared/POSModels/Tbldriver.cs new file mode 100644 index 0000000..90f5397 --- /dev/null +++ b/Shared/POSModels/Tbldriver.cs @@ -0,0 +1,33 @@ +using System; +using System.Collections.Generic; + +namespace Biskilog_Cloud.Shared.POSModels; + +public partial class Tbldriver +{ + public string DriverId { get; set; } = null!; + + public string BranchId { get; set; } = null!; + + public string? Firstname { get; set; } + + public string? Surname { get; set; } + + public string? Middlename { get; set; } + + public DateOnly? DateOfBirth { get; set; } + + public string? Address1 { get; set; } + + public string? Address2 { get; set; } + + public string? Telephone { get; set; } + + public string? Email { get; set; } + + public string? City { get; set; } + + public string? State { get; set; } + + public string? Status { get; set; } +} diff --git a/Shared/POSModels/Tblinventory.cs b/Shared/POSModels/Tblinventory.cs new file mode 100644 index 0000000..7805dd7 --- /dev/null +++ b/Shared/POSModels/Tblinventory.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; + +namespace Biskilog_Cloud.Shared.POSModels; + +public partial class Tblinventory +{ + public string? Pcode { get; set; } + + public int? Quantity { get; set; } + + public string BranchId { get; set; } = null!; + + public string CountId { get; set; } = null!; +} diff --git a/Shared/POSModels/Tblinventoryentry.cs b/Shared/POSModels/Tblinventoryentry.cs new file mode 100644 index 0000000..d9cebf8 --- /dev/null +++ b/Shared/POSModels/Tblinventoryentry.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; + +namespace Biskilog_Cloud.Shared.POSModels; + +public partial class Tblinventoryentry +{ + public string? Pcode { get; set; } + + public int? Quantity { get; set; } + + public DateTime? Date { get; set; } + + public string BranchId { get; set; } = null!; + + public string CountId { get; set; } = null!; +} diff --git a/Shared/POSModels/Tblinvoice.cs b/Shared/POSModels/Tblinvoice.cs new file mode 100644 index 0000000..15c5a37 --- /dev/null +++ b/Shared/POSModels/Tblinvoice.cs @@ -0,0 +1,29 @@ +using System; +using System.Collections.Generic; + +namespace Biskilog_Cloud.Shared.POSModels; + +public partial class Tblinvoice +{ + public string? InvoiceId { get; set; } + + public string? Pcode { get; set; } + + public int? Quantity { get; set; } + + public decimal? Unitprice { get; set; } + + public string? Unit { get; set; } + + public decimal? Totalprice { get; set; } + + public DateOnly? DateGenerated { get; set; } + + public string? Status { get; set; } + + public string? GeneratedBy { get; set; } + + public string BranchId { get; set; } = null!; + + public string CountId { get; set; } = null!; +} diff --git a/Shared/POSModels/Tblpricechange.cs b/Shared/POSModels/Tblpricechange.cs new file mode 100644 index 0000000..4252692 --- /dev/null +++ b/Shared/POSModels/Tblpricechange.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; + +namespace Biskilog_Cloud.Shared.POSModels; + +public partial class Tblpricechange +{ + public string? Pcode { get; set; } + + public decimal? PreviousPrice { get; set; } + + public decimal? CurrentPrice { get; set; } + + public DateTime? ChangeDate { get; set; } + + public string BranchId { get; set; } = null!; + + public string CountId { get; set; } = null!; +} diff --git a/Shared/POSModels/Tblproduct.cs b/Shared/POSModels/Tblproduct.cs new file mode 100644 index 0000000..78d1ad3 --- /dev/null +++ b/Shared/POSModels/Tblproduct.cs @@ -0,0 +1,31 @@ +using System; +using System.Collections.Generic; + +namespace Biskilog_Cloud.Shared.POSModels; + +public partial class Tblproduct +{ + public string? Pcode { get; set; } + + public string? Barcode { get; set; } + + public string? Pdesc { get; set; } + + public string? Bid { get; set; } + + public string? Cid { get; set; } + + public decimal? Price { get; set; } + + public decimal? Costprice { get; set; } + + public string? BaseUnit { get; set; } + + public string? ProductName { get; set; } + + public string? Status { get; set; } + + public string BranchId { get; set; } = null!; + + public string CountId { get; set; } = null!; +} diff --git a/Shared/POSModels/Tbltruck.cs b/Shared/POSModels/Tbltruck.cs new file mode 100644 index 0000000..330477e --- /dev/null +++ b/Shared/POSModels/Tbltruck.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; + +namespace Biskilog_Cloud.Shared.POSModels; + +public partial class Tbltruck +{ + public string TruckId { get; set; } = null!; + + public string BranchId { get; set; } = null!; + + public string? LicensePlate { get; set; } + + public string? Brand { get; set; } + + public string? Driver { get; set; } + + public decimal? Weight { get; set; } +} diff --git a/Shared/POSModels/TbltruckDrivermapping.cs b/Shared/POSModels/TbltruckDrivermapping.cs new file mode 100644 index 0000000..5bb5f5c --- /dev/null +++ b/Shared/POSModels/TbltruckDrivermapping.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; + +namespace Biskilog_Cloud.Shared.POSModels; + +public partial class TbltruckDrivermapping +{ + public string? TruckId { get; set; } + + public string? DriverId { get; set; } + + public DateTime? DateEntry { get; set; } + + public string? Operation { get; set; } + + public string CountId { get; set; } = null!; + + public string BranchId { get; set; } = null!; +} diff --git a/Shared/POSModels/Tbltruckassignment.cs b/Shared/POSModels/Tbltruckassignment.cs new file mode 100644 index 0000000..e979a48 --- /dev/null +++ b/Shared/POSModels/Tbltruckassignment.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; + +namespace Biskilog_Cloud.Shared.POSModels; + +public partial class Tbltruckassignment +{ + public string? OrderId { get; set; } + + public decimal? Cost { get; set; } + + public string? TruckId { get; set; } + + public string? Status { get; set; } + + public DateTime? DateAssigned { get; set; } + + public string CountId { get; set; } = null!; + + public string BranchId { get; set; } = null!; +} diff --git a/Shared/POSModels/Tbltruckinventory.cs b/Shared/POSModels/Tbltruckinventory.cs new file mode 100644 index 0000000..76329e0 --- /dev/null +++ b/Shared/POSModels/Tbltruckinventory.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; + +namespace Biskilog_Cloud.Shared.POSModels; + +public partial class Tbltruckinventory +{ + public string? TruckId { get; set; } + + public string? Pcode { get; set; } + + public int? Quantity { get; set; } + + public string? Unit { get; set; } + + public string CountId { get; set; } = null!; + + public string BranchId { get; set; } = null!; +} diff --git a/Shared/POSModels/Tbluser.cs b/Shared/POSModels/Tbluser.cs new file mode 100644 index 0000000..6427653 --- /dev/null +++ b/Shared/POSModels/Tbluser.cs @@ -0,0 +1,33 @@ +using System; +using System.Collections.Generic; + +namespace Biskilog_Cloud.Shared.POSModels; + +public partial class Tbluser +{ + public string Username { get; set; } = null!; + + public string BranchId { get; set; } = null!; + + public string? Password { get; set; } + + public string? Firstname { get; set; } + + public string? Surname { get; set; } + + public string? StreetAddress1 { get; set; } + + public string? StreetAddress2 { get; set; } + + public string? City { get; set; } + + public string? StateOrProvince { get; set; } + + public string? Telephone { get; set; } + + public string? Email { get; set; } + + public string? AccessLevel { get; set; } + + public DateTime? LastLogin { get; set; } +} diff --git a/Shared/POSModels/Tbstock.cs b/Shared/POSModels/Tbstock.cs new file mode 100644 index 0000000..4557323 --- /dev/null +++ b/Shared/POSModels/Tbstock.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; + +namespace Biskilog_Cloud.Shared.POSModels; + +public partial class Tbstock +{ + public string? Refno { get; set; } + + public string? Pcode { get; set; } + + public int? Qty { get; set; } + + public DateOnly? Sdate { get; set; } + + public string? Stockinby { get; set; } + + public string BranchId { get; set; } = null!; + + public string CountId { get; set; } = null!; +} diff --git a/Shared/POSModels/Unitofmeasure.cs b/Shared/POSModels/Unitofmeasure.cs new file mode 100644 index 0000000..b72f983 --- /dev/null +++ b/Shared/POSModels/Unitofmeasure.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; + +namespace Biskilog_Cloud.Shared.POSModels; + +public partial class Unitofmeasure +{ + public string UnitCode { get; set; } = null!; + + public string BranchId { get; set; } = null!; + + public string? Unitname { get; set; } + + public string? Unitshort { get; set; } + + public string? Status { get; set; } +} diff --git a/Shared/ServiceRepo/CalculatorService.cs b/Shared/ServiceRepo/CalculatorService.cs new file mode 100644 index 0000000..2bf104d --- /dev/null +++ b/Shared/ServiceRepo/CalculatorService.cs @@ -0,0 +1,63 @@ +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 new file mode 100644 index 0000000..0af6ab3 --- /dev/null +++ b/Shared/ServiceRepo/SearchService.cs @@ -0,0 +1,33 @@ +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(); + } + } + +} diff --git a/Shared/ServiceRepo/TokenService.cs b/Shared/ServiceRepo/TokenService.cs new file mode 100644 index 0000000..4ac8c7d --- /dev/null +++ b/Shared/ServiceRepo/TokenService.cs @@ -0,0 +1,239 @@ +using Biskilog_Cloud.Shared.ClientContractModels; +using Biskilog_Cloud.Shared.Enums; +using Biskilog_Cloud.Shared.Interfaces; +using Blazored.LocalStorage; +using Blazored.SessionStorage; +using Microsoft.Extensions.Configuration; +using Microsoft.IdentityModel.Tokens; +using System.IdentityModel.Tokens.Jwt; +using System.Security.Claims; +using System.Text; + +namespace Biskilog_Cloud.ServiceRepo +{ + public class TokenService : ITokenService + { + private IConfiguration m_configuration { get; } + private readonly ISessionStorageService m_sessionStorage; + private readonly ILocalStorageService m_localStorage; + public TokenService(IConfiguration a_configuration, ISessionStorageService a_sessionStorage = null, ILocalStorageService a_localStorage = null) + { + m_configuration = a_configuration; + m_sessionStorage = a_sessionStorage; + m_localStorage = a_localStorage; + } + + /// + /// Validates a user access token + /// + /// AuthEnums.Valid if token is a valid and unexpired token + public AuthEnums ValidateToken(string a_token) + { + try + { + string token = a_token.Substring(6).Trim(); + var handler = new JwtSecurityTokenHandler(); + JwtSecurityToken jwtToken = (JwtSecurityToken)handler.ReadToken(token); + + if (jwtToken.ValidFrom <= DateTime.Now && jwtToken.ValidTo > DateTime.Now) + return AuthEnums.Valid; + return AuthEnums.Expired; + } + catch (Exception ex) + { + Console.WriteLine(ex.Message); + return AuthEnums.Invalid; + } + } + /// + /// Generates an access token based on the user + /// + /// A tokenized string + public string GenerateToken(Userauth a_user, Contract a_clientContract, Databasemap a_database, List a_business, bool a_comparison) + { + try + { + //create claims details based on the user information + var claims = new[] { + new Claim(JwtRegisteredClaimNames.Jti, Guid.NewGuid().ToString()), + new Claim(JwtRegisteredClaimNames.Iat, DateTime.UtcNow.ToString()), + new Claim("ContractStart",a_clientContract.StartDate !.Value.ToString()), + new Claim("ContractEnd",a_clientContract.EndDate!.Value.ToString()), + new Claim("UserId", a_user.UserId.ToString()), + new Claim("Username", a_user.Username.ToString()), + new Claim("DbId",a_database.DbNo.ToString()), + new Claim("ComparisonMode",a_comparison.ToString()), + new Claim("BranchId",a_business[0].ToString()), + new Claim("BranchAccess",string.Join(", ", a_business.ToArray())), + new Claim("ClientId", a_user.ClientId.ToString()), + }; + + var key = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(m_configuration["Jwt:Key"]!)); + + var signIn = new SigningCredentials(key, SecurityAlgorithms.HmacSha256); + + var token = new JwtSecurityToken(m_configuration["Jwt:Issuer"], m_configuration["Jwt:Audience"], claims, expires: DateTime.UtcNow.AddDays(14), signingCredentials: signIn); + return $"{new JwtSecurityTokenHandler().WriteToken(token)}"; + } + catch (Exception ex) + { + Console.WriteLine(ex.Message); + return AuthEnums.Error.ToString(); + } + } + /// + ///Deserializes the token string if valid to return the specified user role id in the token string + /// + /// + /// RoleId + public int? GetDatabaseIdFromToken(string a_token) + { + if (ValidateToken(a_token) == AuthEnums.Valid) + { + string token = a_token.Substring(6).Trim(); + var handler = new JwtSecurityTokenHandler(); + JwtSecurityToken jwtToken = (JwtSecurityToken)handler.ReadToken(token); + return int.Parse(jwtToken.Claims.First(claim => claim.Type == "DbId").Value); + } + return null; + } + /// + ///Deserializes the token string if valid to return the specified user id in the token string + /// + /// + /// UserId + public int? GetUserIdFromToken(string a_token) + { + if (ValidateToken(a_token) == AuthEnums.Valid) + { + string token = a_token.Substring(6).Trim(); + var handler = new JwtSecurityTokenHandler(); + JwtSecurityToken jwtToken = (JwtSecurityToken)handler.ReadToken(token); + return int.Parse(jwtToken.Claims.First(claim => claim.Type == "UserId").Value); + } + return null; + } + /// + ///Deserializes the token string if valid to return the specified username in the token string + /// + /// + /// Username + public string? GetUserNameFromToken(string a_token) + { + if (ValidateToken(a_token) == AuthEnums.Valid) + { + string token = a_token.Substring(6).Trim(); + var handler = new JwtSecurityTokenHandler(); + JwtSecurityToken jwtToken = (JwtSecurityToken)handler.ReadToken(token); + return jwtToken.Claims.First(claim => claim.Type == "Username").Value; + } + return null; + } + /// + ///Deserializes the token string if valid to return the specified branchId in the token string + /// + /// + /// Username + public string? GetBaseBranch(string a_token) + { + if (ValidateToken(a_token) == AuthEnums.Valid) + { + string token = a_token.Substring(6).Trim(); + var handler = new JwtSecurityTokenHandler(); + JwtSecurityToken jwtToken = (JwtSecurityToken)handler.ReadToken(token); + return jwtToken.Claims.First(claim => claim.Type == "BranchId").Value; + } + return null; + } + + public bool? GetComparison(string a_token) + { + if (ValidateToken(a_token) == AuthEnums.Valid) + { + string token = a_token.Substring(6).Trim(); + var handler = new JwtSecurityTokenHandler(); + JwtSecurityToken jwtToken = (JwtSecurityToken)handler.ReadToken(token); + return bool.Parse(jwtToken.Claims.First(claim => claim.Type == "ComparisonMode").Value); + } + return null; + } + /// + ///Deserializes the token string if valid to return the specified list of branches a user has access to in the token string + /// + /// + /// Username + public string? GetAllBranch(string a_token) + { + if (ValidateToken(a_token) == AuthEnums.Valid) + { + string token = a_token.Substring(6).Trim(); + var handler = new JwtSecurityTokenHandler(); + JwtSecurityToken jwtToken = (JwtSecurityToken)handler.ReadToken(token); + return jwtToken.Claims.First(claim => claim.Type == "BranchAccess").Value; + } + return null; + } + /// + /// Return a specified list of branches a user has access if comparison mode is set otherwise returns only the + /// active branch on the list + /// + /// + /// + public IEnumerable BranchIds(string a_token) + { + List branchIds = new List(); + if (ValidateToken(a_token) == AuthEnums.Valid) + { + bool comparison = GetComparison(a_token)!.Value; + if (comparison) + { + string? branches = GetAllBranch(a_token); + if (branches != null) + { + string[] branchArray = branches!.Split(); + branchIds.AddRange(branchArray); + } + } + else + { + string? baseBranch = GetBaseBranch(a_token); + branchIds.Add(baseBranch!); + } + } + return branchIds.AsEnumerable(); + } + + public async Task SetToken(string a_token, bool a_remember) + { + if (a_remember) + { + await m_localStorage.SetItemAsStringAsync("token", $"Bearer {a_token}"); + } + else + { + await m_sessionStorage.SetItemAsStringAsync("token", $"Bearer {a_token}"); + } + } + + public async Task GetToken() + { + string token = await m_localStorage.GetItemAsStringAsync("token"); + if (String.IsNullOrEmpty(token)) + { + token = await m_sessionStorage.GetItemAsStringAsync("token"); + } + return token; + } + + public async Task ClearToken() + { + await m_localStorage.ClearAsync(); + await m_sessionStorage.ClearAsync(); + } + + public async Task IsTokenSet() + { + return await m_localStorage.ContainKeyAsync("token") || await m_sessionStorage.ContainKeyAsync("token"); + } + } +} diff --git a/Shared/SharedClass.cs b/Shared/SharedClass.cs new file mode 100644 index 0000000..bb016a8 --- /dev/null +++ b/Shared/SharedClass.cs @@ -0,0 +1 @@ +/* Shared classes can be referenced by both the Client and Server */