barhen
2 years ago
74 changed files with 1797 additions and 50 deletions
@ -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<WeatherForecastController> _logger; |
||||
|
|
||||
|
public WeatherForecastController(ILogger<WeatherForecastController> logger) |
||||
|
{ |
||||
|
_logger = logger; |
||||
|
} |
||||
|
|
||||
|
[HttpGet(Name = "GetWeatherForecast")] |
||||
|
public IEnumerable<WeatherForecast> 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(); |
||||
|
} |
||||
|
} |
@ -1,10 +1,25 @@ |
|||||
using ServerManager; |
var builder = WebApplication.CreateBuilder(args); |
||||
|
|
||||
IHost host = Host.CreateDefaultBuilder(args) |
// Add services to the container.
|
||||
.ConfigureServices(services => |
builder.Services.AddSignalR(); |
||||
{ |
builder.Services.AddControllers(); |
||||
services.AddHostedService<Worker>(); |
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
|
||||
}) |
builder.Services.AddEndpointsApiExplorer(); |
||||
.Build(); |
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(); |
||||
|
@ -1,13 +1,31 @@ |
|||||
<Project Sdk="Microsoft.NET.Sdk.Worker"> |
<Project Sdk="Microsoft.NET.Sdk.Web"> |
||||
|
|
||||
<PropertyGroup> |
<PropertyGroup> |
||||
<TargetFramework>net7.0</TargetFramework> |
<TargetFramework>net7.0</TargetFramework> |
||||
<Nullable>enable</Nullable> |
<Nullable>enable</Nullable> |
||||
<ImplicitUsings>enable</ImplicitUsings> |
<ImplicitUsings>enable</ImplicitUsings> |
||||
<UserSecretsId>dotnet-ServerManager-52a85e73-fd4f-461a-8b7b-99494934c716</UserSecretsId> |
</PropertyGroup> |
||||
</PropertyGroup> |
|
||||
|
<ItemGroup> |
||||
|
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="7.0.5" /> |
||||
|
<PackageReference Include="BCrypt.Net" Version="0.1.0" /> |
||||
|
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="7.0.5" /> |
||||
|
<PackageReference Include="AutoMapper" Version="12.0.1" /> |
||||
|
<PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="12.0.1" /> |
||||
|
<PackageReference Include="CsvHelper" Version="30.0.1" /> |
||||
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.5"> |
||||
|
<PrivateAssets>all</PrivateAssets> |
||||
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> |
||||
|
</PackageReference> |
||||
|
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="7.0.5" /> |
||||
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="7.0.5"> |
||||
|
<PrivateAssets>all</PrivateAssets> |
||||
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> |
||||
|
</PackageReference> |
||||
|
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="7.0.6" /> |
||||
|
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="7.0.0" /> |
||||
|
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.5.0" /> |
||||
|
<PackageReference Include="Microsoft.Diagnostics.Tracing.TraceEvent" Version="3.1.3" /> |
||||
|
</ItemGroup> |
||||
|
|
||||
<ItemGroup> |
|
||||
<PackageReference Include="Microsoft.Extensions.Hosting" Version="7.0.1" /> |
|
||||
</ItemGroup> |
|
||||
</Project> |
</Project> |
||||
|
@ -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; } |
||||
|
} |
@ -1,21 +1 @@ |
|||||
namespace ServerManager |
|
||||
{ |
|
||||
public class Worker : BackgroundService |
|
||||
{ |
|
||||
private readonly ILogger<Worker> _logger; |
|
||||
|
|
||||
public Worker(ILogger<Worker> 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); |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
} |
|
@ -0,0 +1,22 @@ |
|||||
|
<Project Sdk="Microsoft.NET.Sdk"> |
||||
|
|
||||
|
<PropertyGroup> |
||||
|
<TargetFramework>net7.0</TargetFramework> |
||||
|
<Nullable>enable</Nullable> |
||||
|
<ImplicitUsings>enable</ImplicitUsings> |
||||
|
</PropertyGroup> |
||||
|
|
||||
|
<ItemGroup> |
||||
|
<PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="12.0.1" /> |
||||
|
<PackageReference Include="Blazored.LocalStorage" Version="4.3.0" /> |
||||
|
<PackageReference Include="Blazored.SessionStorage" Version="2.3.0" /> |
||||
|
<PackageReference Include="EntityFramework" Version="6.4.4" /> |
||||
|
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.5" /> |
||||
|
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="7.0.0" /> |
||||
|
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="6.30.1" /> |
||||
|
</ItemGroup> |
||||
|
|
||||
|
<ItemGroup> |
||||
|
<SupportedPlatform Include="browser" /> |
||||
|
</ItemGroup> |
||||
|
</Project> |
@ -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; } |
||||
|
} |
@ -0,0 +1,21 @@ |
|||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
|
||||
|
namespace Biskilog_Cloud.Shared.ClientContractModels; |
||||
|
|
||||
|
public partial class Clientbusiness |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// there could be multiple branches of the same business
|
||||
|
/// </summary>
|
||||
|
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!; |
||||
|
} |
@ -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; } |
||||
|
} |
@ -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!; |
||||
|
} |
@ -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; } |
||||
|
} |
@ -0,0 +1,16 @@ |
|||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
|
||||
|
namespace Biskilog_Cloud.Shared.ClientContractModels; |
||||
|
|
||||
|
public partial class Siteaccesspermission |
||||
|
{ |
||||
|
public int UserId { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// businessIds could also been seen as branchID
|
||||
|
/// </summary>
|
||||
|
public int BusinessId { get; set; } |
||||
|
|
||||
|
public int ClientId { get; set; } |
||||
|
} |
@ -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; } |
||||
|
} |
@ -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; } |
||||
|
} |
||||
|
} |
@ -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; |
||||
|
} |
||||
|
} |
@ -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 |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// Specifies the id of the product
|
||||
|
/// </summary>
|
||||
|
public string ProductId { get; set; } = string.Empty; |
||||
|
/// <summary>
|
||||
|
/// Specifies the name of the product
|
||||
|
/// </summary>
|
||||
|
public string ProductName { get; set; } = string.Empty; |
||||
|
/// <summary>
|
||||
|
/// The total revenue generated from the sale
|
||||
|
/// </summary>
|
||||
|
public decimal? Revenue { get; set; } |
||||
|
/// <summary>
|
||||
|
/// This is the number of times the item has been sold
|
||||
|
/// </summary>
|
||||
|
public int? NbrTimesSold { get; set; } |
||||
|
|
||||
|
} |
||||
|
} |
@ -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<ProductUnits> Units { get; set; } = new List<ProductUnits>(); |
||||
|
public string BaseUnit { get; set; } = string.Empty; |
||||
|
} |
||||
|
} |
@ -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!; |
||||
|
} |
||||
|
} |
@ -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!; |
||||
|
} |
||||
|
} |
@ -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"!; |
||||
|
} |
||||
|
} |
@ -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; |
||||
|
} |
||||
|
} |
@ -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!; |
||||
|
} |
||||
|
} |
@ -0,0 +1,17 @@ |
|||||
|
namespace Biskilog_Cloud.Shared.Enums |
||||
|
{ |
||||
|
public enum AuthEnums |
||||
|
{ |
||||
|
Registered, |
||||
|
AleadyLoggedin, |
||||
|
WrongPassword, |
||||
|
NotFound, |
||||
|
Found, |
||||
|
Expired, |
||||
|
Invalid, |
||||
|
Valid, |
||||
|
Successful, |
||||
|
Error |
||||
|
} |
||||
|
} |
||||
|
|
@ -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, |
||||
|
} |
||||
|
} |
@ -0,0 +1,86 @@ |
|||||
|
using Biskilog_Cloud.Shared.CustomModels; |
||||
|
using Biskilog_Cloud.Shared.POSModels; |
||||
|
|
||||
|
namespace Biskilog_Cloud.Shared.Interfaces |
||||
|
{ |
||||
|
public interface IAnalytics |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// Fetches a collection of sales transaction made from the specified start date to the end date
|
||||
|
/// </summary>
|
||||
|
/// <param name="a_start">Specified Start Date</param>
|
||||
|
/// <param name="a_end">Specified end Date</param>
|
||||
|
/// <returns></returns>
|
||||
|
IEnumerable<Tblcart> GetSalesTransaction(DateTime a_start, DateTime a_end); |
||||
|
/// <summary>
|
||||
|
/// Fetches a collection of sales transaction made within a one week period
|
||||
|
/// </summary>
|
||||
|
/// <returns></returns>
|
||||
|
IEnumerable<WeeklySaleItem> GetWeeklySalesTransaction(); |
||||
|
/// <summary>
|
||||
|
/// Fetches a collection of in-debt customers
|
||||
|
/// <returns></returns>
|
||||
|
IEnumerable<CustomerAccounts> GetInDebtCustomers(); |
||||
|
/// <summary>
|
||||
|
/// Fetches a collection of Product Items which are currently out of stock
|
||||
|
/// </summary>
|
||||
|
/// <returns></returns>
|
||||
|
IEnumerable<ProductItem> GetOutOfStockItems(); |
||||
|
/// <summary>
|
||||
|
/// Fetches a collection of the most purchased Product Items within a specified date range
|
||||
|
/// </summary>
|
||||
|
/// <param name="a_start"></param>
|
||||
|
/// <param name="a_end"></param>
|
||||
|
/// <returns></returns>
|
||||
|
IEnumerable<MostPurchasedItem> GetMostPurchasedItem(DateTime a_start, DateTime a_end); |
||||
|
/// <summary>
|
||||
|
/// Fetches a collection of cancelled transaction within a specified date range
|
||||
|
/// </summary>
|
||||
|
/// <param name="a_start"></param>
|
||||
|
/// <param name="a_end"></param>
|
||||
|
/// <returns></returns>
|
||||
|
IEnumerable<CancelledSales> GetCancelledSales(DateTime a_start, DateTime a_end); |
||||
|
/// <summary>
|
||||
|
/// Fetches a collection of transaction made by employees within a specified date range
|
||||
|
/// </summary>
|
||||
|
/// <param name="a_start"></param>
|
||||
|
/// <param name="a_end"></param>
|
||||
|
/// <returns>A dictionary of transactions made by employees with employee name as key</returns>
|
||||
|
Dictionary<string, List<SaleItem>> GetEmployeeSales(DateTime a_start, DateTime a_end); |
||||
|
/// <summary>
|
||||
|
/// Fetches a collection of product price changes with a specified date range
|
||||
|
/// </summary>
|
||||
|
/// <param name="a_start"></param>
|
||||
|
/// <param name="a_end"></param>
|
||||
|
/// <returns></returns>
|
||||
|
IEnumerable<ProductPriceChange> GetPriceChanges(DateTime a_start, DateTime a_end); |
||||
|
/// <summary>
|
||||
|
/// Fetch the trade summary which is made of the total sales made currently and previous trade
|
||||
|
/// </summary>
|
||||
|
/// <returns></returns>
|
||||
|
TradeSummary GetTradeSummary(); |
||||
|
/// <summary>
|
||||
|
/// Fetches the most recent sales transactions
|
||||
|
/// </summary>
|
||||
|
/// <param name="a_limit">The number of rows to return </param>
|
||||
|
/// <returns></returns>
|
||||
|
IEnumerable<SaleItem> GetRecentSales(int a_limit); |
||||
|
/// <summary>
|
||||
|
/// Fetches a collection of product price changes recently made
|
||||
|
/// </summary>
|
||||
|
/// <param name="a_limit">the number of rows to return</param>
|
||||
|
/// <returns></returns>
|
||||
|
IEnumerable<ProductPriceChange> GetRecentPriceChanges(int a_limit); |
||||
|
/// <summary>
|
||||
|
/// Fetches a collection of price change history per product
|
||||
|
/// </summary>
|
||||
|
/// <param name="a_limit">the number of products to fetch history</param>
|
||||
|
/// <returns></returns>
|
||||
|
IEnumerable<ProductPriceChange> GetProductPriceChangeHistory(int a_limit); |
||||
|
/// <summary>
|
||||
|
/// Fetches a collection of sales transaction grouped by category made within a one week period
|
||||
|
/// </summary>
|
||||
|
/// <returns></returns>
|
||||
|
IEnumerable<WeeklyCategorySummary> GetWeeklySalesCategoryTransaction(int a_limit); |
||||
|
} |
||||
|
} |
@ -0,0 +1,19 @@ |
|||||
|
using Biskilog_Cloud.Shared.ClientContractModels; |
||||
|
|
||||
|
namespace Biskilog_Cloud.Shared.Interfaces |
||||
|
{ |
||||
|
public interface IAuthService |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// Authenticates user or client
|
||||
|
/// </summary>
|
||||
|
/// <param name="a_username"></param>
|
||||
|
/// <param name="a_password"></param>
|
||||
|
/// <returns>A tokenized string with relevant information on the authenticated user</returns>
|
||||
|
Task<string> AuthenticateClient(string a_username, string a_password); |
||||
|
Contract? GetContract(int a_clientId, List<int> a_businessId); |
||||
|
Databasemap GetClientDB(int a_clientId); |
||||
|
List<Siteaccesspermission> GetSiteaccesspermission(int a_clientId, int a_userId); |
||||
|
List<Clientbusiness> GetClientbusiness(int a_clientId, int userId); |
||||
|
} |
||||
|
} |
@ -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(); |
||||
|
} |
||||
|
} |
@ -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<Tblbranch> FetchBranches(); |
||||
|
Task<Tblcompanydetail> GetCompanyInfoAsync(); |
||||
|
Task<IEnumerable<Tblbranch>> GetBranches(); |
||||
|
string GetCompanyName(); |
||||
|
string GetBranchName(string a_branchId); |
||||
|
} |
||||
|
} |
@ -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 |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// Prepares and returns the connection string for a client using the specified database id
|
||||
|
/// </summary>
|
||||
|
/// <param name="a_databaseId">Specified database id to use</param>
|
||||
|
/// <returns></returns>
|
||||
|
string GetClientConnectionString(int a_databaseId); |
||||
|
/// <summary>
|
||||
|
/// Prepare the DB context from the specified connection string
|
||||
|
/// </summary>
|
||||
|
/// <param name="a_connectionString"></param>
|
||||
|
/// <returns>A configured BiskAcdbContext</returns>
|
||||
|
object PrepareDBContext(string a_connectionString); |
||||
|
} |
||||
|
} |
@ -0,0 +1,11 @@ |
|||||
|
using Biskilog_Cloud.Shared.CustomModels; |
||||
|
using Biskilog_Cloud.Shared.POSModels; |
||||
|
|
||||
|
namespace Biskilog_Cloud.Shared.Interfaces |
||||
|
{ |
||||
|
public interface ICustomer |
||||
|
{ |
||||
|
IEnumerable<CustomerAccounts> FetchCustomers(); |
||||
|
Task<IEnumerable<CustomerAccounts>> GetCustomers(); |
||||
|
} |
||||
|
} |
@ -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(); |
||||
|
} |
||||
|
} |
@ -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<Unitofmeasure> GetUnitofmeasures(); |
||||
|
IEnumerable<ProductItem> GetProducts(string a_productKey = ""); |
||||
|
IEnumerable<Tblbrand> GetBrands(string a_brandKey = ""); |
||||
|
IEnumerable<Tblcategory> GetCategories(string a_categoryKey = ""); |
||||
|
IEnumerable<ProductItem> 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; |
||||
|
} |
||||
|
} |
@ -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<SaleItem> GetTransactions(DateTime a_start, DateTime a_end); |
||||
|
IEnumerable<SaleItem> GetRecentTransaction(); |
||||
|
Task FetchReceipt(string a_receiptId); |
||||
|
IEnumerable<SaleItem> GetReceipt(string a_receiptId); |
||||
|
Task<IEnumerable<Tblcart>> GetReceiptDetail(string a_receiptId); |
||||
|
event EventHandler TransactionsChanged; |
||||
|
event EventHandler FetchComplete; |
||||
|
event EventHandler FetchStart; |
||||
|
} |
||||
|
} |
@ -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<string> SearchValueChanged; |
||||
|
public event Action ClearTextBox; |
||||
|
void PerformSearch(string a_searchKey); |
||||
|
void Clear(); |
||||
|
} |
||||
|
} |
@ -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<string> 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<string> BranchIds(string a_token); |
||||
|
string? GetAllBranch(string a_token); |
||||
|
Task SetToken(string a_token, bool a_remember); |
||||
|
Task<string> GetToken(); |
||||
|
Task ClearToken(); |
||||
|
Task<bool> IsTokenSet(); |
||||
|
} |
||||
|
} |
@ -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<Tbluser> FetchUsers(); |
||||
|
Task<IEnumerable<Tbluser>> GetUsers(); |
||||
|
} |
||||
|
} |
@ -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!; |
||||
|
} |
@ -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!; |
||||
|
} |
@ -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!; |
||||
|
} |
@ -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; } |
||||
|
} |
@ -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; } |
||||
|
} |
@ -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; } |
||||
|
} |
@ -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; } |
||||
|
} |
@ -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!; |
||||
|
} |
@ -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!; |
||||
|
} |
@ -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; } |
||||
|
} |
@ -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; } |
||||
|
} |
@ -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; } |
||||
|
} |
@ -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!; |
||||
|
} |
@ -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!; |
||||
|
} |
@ -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; } |
||||
|
} |
@ -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; } |
||||
|
} |
@ -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!; |
||||
|
} |
@ -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; } |
||||
|
} |
@ -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!; |
||||
|
} |
@ -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!; |
||||
|
} |
@ -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!; |
||||
|
} |
@ -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!; |
||||
|
} |
@ -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!; |
||||
|
} |
@ -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; } |
||||
|
} |
@ -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!; |
||||
|
} |
@ -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!; |
||||
|
} |
@ -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!; |
||||
|
} |
@ -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; } |
||||
|
} |
@ -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!; |
||||
|
} |
@ -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; } |
||||
|
} |
@ -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"); |
||||
|
} |
||||
|
} |
||||
|
} |
@ -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<string> 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(); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
} |
@ -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; |
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Validates a user access token
|
||||
|
/// </summary>
|
||||
|
/// <returns>AuthEnums.Valid if token is a valid and unexpired token</returns>
|
||||
|
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; |
||||
|
} |
||||
|
} |
||||
|
/// <summary>
|
||||
|
/// Generates an access token based on the user
|
||||
|
/// </summary>
|
||||
|
/// <returns>A tokenized string</returns>
|
||||
|
public string GenerateToken(Userauth a_user, Contract a_clientContract, Databasemap a_database, List<string> 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(); |
||||
|
} |
||||
|
} |
||||
|
/// <summary>
|
||||
|
///Deserializes the token string if valid to return the specified user role id in the token string
|
||||
|
/// </summary>
|
||||
|
/// <param name="a_token"></param>
|
||||
|
/// <returns>RoleId</returns>
|
||||
|
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; |
||||
|
} |
||||
|
/// <summary>
|
||||
|
///Deserializes the token string if valid to return the specified user id in the token string
|
||||
|
/// </summary>
|
||||
|
/// <param name="a_token"></param>
|
||||
|
/// <returns>UserId</returns>
|
||||
|
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; |
||||
|
} |
||||
|
/// <summary>
|
||||
|
///Deserializes the token string if valid to return the specified username in the token string
|
||||
|
/// </summary>
|
||||
|
/// <param name="a_token"></param>
|
||||
|
/// <returns>Username</returns>
|
||||
|
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; |
||||
|
} |
||||
|
/// <summary>
|
||||
|
///Deserializes the token string if valid to return the specified branchId in the token string
|
||||
|
/// </summary>
|
||||
|
/// <param name="a_token"></param>
|
||||
|
/// <returns>Username</returns>
|
||||
|
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; |
||||
|
} |
||||
|
/// <summary>
|
||||
|
///Deserializes the token string if valid to return the specified list of branches a user has access to in the token string
|
||||
|
/// </summary>
|
||||
|
/// <param name="a_token"></param>
|
||||
|
/// <returns>Username</returns>
|
||||
|
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; |
||||
|
} |
||||
|
/// <summary>
|
||||
|
/// Return a specified list of branches a user has access if comparison mode is set otherwise returns only the
|
||||
|
/// active branch on the list
|
||||
|
/// </summary>
|
||||
|
/// <param name="a_token"></param>
|
||||
|
/// <returns></returns>
|
||||
|
public IEnumerable<string> BranchIds(string a_token) |
||||
|
{ |
||||
|
List<string> branchIds = new List<string>(); |
||||
|
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<string> 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<bool> IsTokenSet() |
||||
|
{ |
||||
|
return await m_localStorage.ContainKeyAsync("token") || await m_sessionStorage.ContainKeyAsync("token"); |
||||
|
} |
||||
|
} |
||||
|
} |
@ -0,0 +1 @@ |
|||||
|
/* Shared classes can be referenced by both the Client and Server */ |
Loading…
Reference in new issue