barhen
2 years ago
7 changed files with 1672 additions and 100 deletions
File diff suppressed because it is too large
@ -0,0 +1,278 @@ |
|||||
|
using Biskilog_Cloud.Shared.ClientContractModels; |
||||
|
using Microsoft.EntityFrameworkCore; |
||||
|
|
||||
|
namespace ServerManager; |
||||
|
/// <summary>
|
||||
|
/// This is the main EF DbContext for the Biskilog Accounting
|
||||
|
/// </summary>
|
||||
|
public partial class BiskilogContext : DbContext |
||||
|
{ |
||||
|
public BiskilogContext() |
||||
|
{ |
||||
|
} |
||||
|
public BiskilogContext(DbContextOptions<BiskilogContext> options) |
||||
|
: base(options) |
||||
|
{ |
||||
|
} |
||||
|
|
||||
|
public virtual DbSet<Authtype> Authtypes { get; set; } |
||||
|
|
||||
|
public virtual DbSet<Clientbusiness> Clientbusinesses { get; set; } |
||||
|
|
||||
|
public virtual DbSet<Clientinfo> Clientinfos { get; set; } |
||||
|
|
||||
|
public virtual DbSet<Contract> Contracts { get; set; } |
||||
|
|
||||
|
public virtual DbSet<Databasemap> Databasemaps { get; set; } |
||||
|
|
||||
|
public virtual DbSet<Siteaccesspermission> Siteaccesspermissions { get; set; } |
||||
|
|
||||
|
public virtual DbSet<Userauth> Userauths { get; set; } |
||||
|
|
||||
|
protected override void OnModelCreating(ModelBuilder modelBuilder) |
||||
|
{ |
||||
|
modelBuilder |
||||
|
.UseCollation("utf8mb4_general_ci") |
||||
|
.HasCharSet("utf8mb4"); |
||||
|
|
||||
|
modelBuilder.Entity<Authtype>(entity => |
||||
|
{ |
||||
|
entity.HasKey(e => e.Id).HasName("PRIMARY"); |
||||
|
|
||||
|
entity |
||||
|
.ToTable("authtypes") |
||||
|
.HasCharSet("utf8") |
||||
|
.UseCollation("utf8_general_ci"); |
||||
|
|
||||
|
entity.Property(e => e.Id) |
||||
|
.HasColumnType("int(11)") |
||||
|
.HasColumnName("id"); |
||||
|
entity.Property(e => e.Type) |
||||
|
.HasMaxLength(50) |
||||
|
.HasColumnName("type") |
||||
|
.UseCollation("utf8mb4_general_ci") |
||||
|
.HasCharSet("utf8mb4"); |
||||
|
}); |
||||
|
|
||||
|
modelBuilder.Entity<Clientbusiness>(entity => |
||||
|
{ |
||||
|
entity.HasKey(e => new { e.BusinessId, e.ClientId }) |
||||
|
.HasName("PRIMARY") |
||||
|
.HasAnnotation("MySql:IndexPrefixLength", new[] { 0, 0 }); |
||||
|
|
||||
|
entity |
||||
|
.ToTable("clientbusiness") |
||||
|
.HasCharSet("utf8") |
||||
|
.UseCollation("utf8_general_ci"); |
||||
|
|
||||
|
entity.Property(e => e.BusinessId) |
||||
|
.HasComment("there could be multiple branches of the same business") |
||||
|
.HasColumnType("int(11)") |
||||
|
.HasColumnName("businessId"); |
||||
|
entity.Property(e => e.ClientId) |
||||
|
.HasColumnType("int(11)") |
||||
|
.HasColumnName("clientID"); |
||||
|
entity.Property(e => e.BiskilogVersion) |
||||
|
.HasMaxLength(50) |
||||
|
.HasDefaultValueSql("''") |
||||
|
.HasColumnName("biskilog_version") |
||||
|
.UseCollation("utf8mb4_general_ci") |
||||
|
.HasCharSet("utf8mb4"); |
||||
|
entity.Property(e => e.BusinessName) |
||||
|
.HasMaxLength(50) |
||||
|
.HasDefaultValueSql("''") |
||||
|
.HasColumnName("business_name") |
||||
|
.UseCollation("utf8mb4_general_ci") |
||||
|
.HasCharSet("utf8mb4"); |
||||
|
entity.Property(e => e.DateJoined) |
||||
|
.HasDefaultValueSql("current_timestamp()") |
||||
|
.HasColumnType("datetime") |
||||
|
.HasColumnName("date_joined"); |
||||
|
entity.Property(e => e.BusinessExternalId) |
||||
|
.HasMaxLength(50) |
||||
|
.HasDefaultValueSql("''") |
||||
|
.HasColumnName("businessExternalId") |
||||
|
.UseCollation("utf8mb4_general_ci") |
||||
|
.HasCharSet("utf8mb4"); |
||||
|
|
||||
|
}); |
||||
|
|
||||
|
modelBuilder.Entity<Clientinfo>(entity => |
||||
|
{ |
||||
|
entity.HasKey(e => e.ClientId).HasName("PRIMARY"); |
||||
|
|
||||
|
entity |
||||
|
.ToTable("clientinfo") |
||||
|
.HasCharSet("utf8") |
||||
|
.UseCollation("utf8_general_ci"); |
||||
|
|
||||
|
entity.Property(e => e.ClientId) |
||||
|
.HasColumnType("int(11)") |
||||
|
.HasColumnName("clientID"); |
||||
|
entity.Property(e => e.Email) |
||||
|
.HasMaxLength(200) |
||||
|
.HasColumnName("email") |
||||
|
.UseCollation("utf8mb4_general_ci") |
||||
|
.HasCharSet("utf8mb4"); |
||||
|
entity.Property(e => e.Fullname) |
||||
|
.HasMaxLength(200) |
||||
|
.UseCollation("utf8mb4_general_ci") |
||||
|
.HasCharSet("utf8mb4"); |
||||
|
entity.Property(e => e.PhoneNumber) |
||||
|
.HasMaxLength(200) |
||||
|
.HasColumnName("phoneNumber") |
||||
|
.UseCollation("utf8mb4_general_ci") |
||||
|
.HasCharSet("utf8mb4"); |
||||
|
}); |
||||
|
|
||||
|
modelBuilder.Entity<Contract>(entity => |
||||
|
{ |
||||
|
entity.HasKey(e => e.ContractId).HasName("PRIMARY"); |
||||
|
|
||||
|
entity |
||||
|
.ToTable("contracts") |
||||
|
.HasCharSet("utf8") |
||||
|
.UseCollation("utf8_general_ci"); |
||||
|
|
||||
|
entity.HasIndex(e => new { e.ClientId, e.BusinessId }, "clientId_businessId").IsUnique(); |
||||
|
|
||||
|
entity.Property(e => e.ContractId) |
||||
|
.HasColumnType("int(11)") |
||||
|
.HasColumnName("contractId"); |
||||
|
entity.Property(e => e.Bill) |
||||
|
.HasPrecision(18, 2) |
||||
|
.HasColumnName("bill"); |
||||
|
entity.Property(e => e.BusinessId) |
||||
|
.HasColumnType("int(11)") |
||||
|
.HasColumnName("businessId"); |
||||
|
entity.Property(e => e.ClientId) |
||||
|
.HasColumnType("int(11)") |
||||
|
.HasColumnName("clientId"); |
||||
|
entity.Property(e => e.Comments) |
||||
|
.HasColumnType("text") |
||||
|
.HasColumnName("comments") |
||||
|
.UseCollation("utf8mb4_general_ci") |
||||
|
.HasCharSet("utf8mb4"); |
||||
|
entity.Property(e => e.EndDate) |
||||
|
.HasColumnType("datetime") |
||||
|
.HasColumnName("end_date"); |
||||
|
entity.Property(e => e.StartDate) |
||||
|
.HasColumnType("datetime") |
||||
|
.HasColumnName("start_date"); |
||||
|
}); |
||||
|
|
||||
|
modelBuilder.Entity<Databasemap>(entity => |
||||
|
{ |
||||
|
entity.HasKey(e => e.DbNo).HasName("PRIMARY"); |
||||
|
|
||||
|
entity |
||||
|
.ToTable("databasemap") |
||||
|
.HasCharSet("utf8") |
||||
|
.UseCollation("utf8_general_ci"); |
||||
|
|
||||
|
entity.HasIndex(e => e.ClientId, "businessId").IsUnique(); |
||||
|
|
||||
|
entity.Property(e => e.DbNo) |
||||
|
.HasColumnType("int(11)") |
||||
|
.HasColumnName("db_no"); |
||||
|
entity.Property(e => e.ClientId) |
||||
|
.HasColumnType("int(11)") |
||||
|
.HasColumnName("clientID"); |
||||
|
entity.Property(e => e.DbName) |
||||
|
.HasMaxLength(50) |
||||
|
.HasDefaultValueSql("''") |
||||
|
.HasColumnName("db_name") |
||||
|
.UseCollation("utf8mb4_general_ci") |
||||
|
.HasCharSet("utf8mb4"); |
||||
|
entity.Property(e => e.Domain) |
||||
|
.HasMaxLength(50) |
||||
|
.HasDefaultValueSql("''") |
||||
|
.HasColumnName("domain") |
||||
|
.UseCollation("utf8mb4_general_ci") |
||||
|
.HasCharSet("utf8mb4"); |
||||
|
entity.Property(e => e.LastSyncDate) |
||||
|
.HasColumnType("datetime") |
||||
|
.HasColumnName("last_sync_date"); |
||||
|
}); |
||||
|
|
||||
|
modelBuilder.Entity<Siteaccesspermission>(entity => |
||||
|
{ |
||||
|
entity.HasKey(e => new { e.UserId, e.BusinessId, e.ClientId }) |
||||
|
.HasName("PRIMARY") |
||||
|
.HasAnnotation("MySql:IndexPrefixLength", new[] { 0, 0, 0 }); |
||||
|
|
||||
|
entity |
||||
|
.ToTable("siteaccesspermission") |
||||
|
.HasCharSet("utf8") |
||||
|
.UseCollation("utf8_general_ci"); |
||||
|
|
||||
|
entity.Property(e => e.UserId) |
||||
|
.HasColumnType("int(11)") |
||||
|
.HasColumnName("userID"); |
||||
|
entity.Property(e => e.BusinessId) |
||||
|
.HasComment("businessIds could also been seen as branchID") |
||||
|
.HasColumnType("int(11)") |
||||
|
.HasColumnName("businessId"); |
||||
|
entity.Property(e => e.ClientId) |
||||
|
.HasColumnType("int(11)") |
||||
|
.HasColumnName("clientId"); |
||||
|
}); |
||||
|
|
||||
|
modelBuilder.Entity<Userauth>(entity => |
||||
|
{ |
||||
|
entity.HasKey(e => e.UserId).HasName("PRIMARY"); |
||||
|
|
||||
|
entity |
||||
|
.ToTable("userauth") |
||||
|
.HasCharSet("utf8") |
||||
|
.UseCollation("utf8_general_ci"); |
||||
|
|
||||
|
entity.HasIndex(e => e.AuthType, "authType"); |
||||
|
|
||||
|
entity.HasIndex(e => new { e.ClientId, e.Username, e.Email }, "clientId_username_email").IsUnique(); |
||||
|
|
||||
|
entity.Property(e => e.UserId) |
||||
|
.HasColumnType("int(11)") |
||||
|
.HasColumnName("userId"); |
||||
|
entity.Property(e => e.AuthType) |
||||
|
.HasColumnType("int(11)") |
||||
|
.HasColumnName("authType"); |
||||
|
entity.Property(e => e.ClientId) |
||||
|
.HasColumnType("int(11)") |
||||
|
.HasColumnName("clientId"); |
||||
|
entity.Property(e => e.Email) |
||||
|
.HasMaxLength(200) |
||||
|
.HasColumnName("email") |
||||
|
.UseCollation("utf8mb4_general_ci") |
||||
|
.HasCharSet("utf8mb4"); |
||||
|
entity.Property(e => e.Isactive) |
||||
|
.HasColumnType("bit(1)") |
||||
|
.HasColumnName("isactive"); |
||||
|
entity.Property(e => e.Isowner) |
||||
|
.HasColumnType("bit(1)") |
||||
|
.HasColumnName("isowner"); |
||||
|
entity.Property(e => e.LastLogin) |
||||
|
.HasColumnType("datetime") |
||||
|
.HasColumnName("last_login"); |
||||
|
entity.Property(e => e.Passsword) |
||||
|
.HasMaxLength(200) |
||||
|
.HasColumnName("passsword") |
||||
|
.UseCollation("utf8mb4_general_ci") |
||||
|
.HasCharSet("utf8mb4"); |
||||
|
entity.Property(e => e.PhoneNumber) |
||||
|
.HasMaxLength(50) |
||||
|
.HasColumnName("phoneNumber") |
||||
|
.UseCollation("utf8mb4_general_ci") |
||||
|
.HasCharSet("utf8mb4"); |
||||
|
entity.Property(e => e.Username) |
||||
|
.HasMaxLength(30) |
||||
|
.HasColumnName("username") |
||||
|
.UseCollation("utf8mb4_general_ci") |
||||
|
.HasCharSet("utf8mb4"); |
||||
|
}); |
||||
|
|
||||
|
OnModelCreatingPartial(modelBuilder); |
||||
|
} |
||||
|
|
||||
|
partial void OnModelCreatingPartial(ModelBuilder modelBuilder); |
||||
|
} |
@ -1,63 +0,0 @@ |
|||||
using Biskilog_Cloud.Shared.Interfaces; |
|
||||
using System; |
|
||||
using System.Collections.Generic; |
|
||||
using System.Globalization; |
|
||||
using System.Linq; |
|
||||
using System.Text; |
|
||||
using System.Threading.Tasks; |
|
||||
|
|
||||
namespace Biskilog_Cloud.Shared.ServiceRepo |
|
||||
{ |
|
||||
public class CalculatorService : ICalculator |
|
||||
{ |
|
||||
public double CalculatePercentage() |
|
||||
{ |
|
||||
throw new NotImplementedException(); |
|
||||
} |
|
||||
|
|
||||
public string FormatMoneyWithCurrency(double a_amount) |
|
||||
{ |
|
||||
return string.Format(GetCurrencyCode(), " {0:C2}", a_amount); |
|
||||
} |
|
||||
public string FormatMoneyWithCurrencyKilo(double a_amount) |
|
||||
{ |
|
||||
return GetCurrencyCode().CurrencySymbol + FormatNumber(a_amount); |
|
||||
} |
|
||||
public NumberFormatInfo GetCurrencyCode() |
|
||||
{ |
|
||||
//TODO have a better implementation
|
|
||||
|
|
||||
// Specify the locale for Ghana
|
|
||||
string locale = "en-GH"; |
|
||||
|
|
||||
// Get the NumberFormatInfo for the specified locale
|
|
||||
NumberFormatInfo numberFormatInfo = new CultureInfo(locale).NumberFormat; |
|
||||
|
|
||||
// Set the currency symbol to Ghanaian cedi
|
|
||||
numberFormatInfo.CurrencySymbol = "GH₵ "; |
|
||||
|
|
||||
return numberFormatInfo; |
|
||||
} |
|
||||
private string FormatNumber(double a_amount) |
|
||||
{ |
|
||||
if (a_amount >= 100000000) |
|
||||
{ |
|
||||
return (a_amount / 1000000D).ToString("0.#M"); |
|
||||
} |
|
||||
if (a_amount >= 1000000) |
|
||||
{ |
|
||||
return (a_amount / 1000000D).ToString("0.##M"); |
|
||||
} |
|
||||
if (a_amount >= 100000) |
|
||||
{ |
|
||||
return (a_amount / 1000D).ToString("0.#k"); |
|
||||
} |
|
||||
if (a_amount >= 10000) |
|
||||
{ |
|
||||
return (a_amount / 1000D).ToString("0.##k"); |
|
||||
} |
|
||||
|
|
||||
return a_amount.ToString("#,0"); |
|
||||
} |
|
||||
} |
|
||||
} |
|
@ -1,33 +0,0 @@ |
|||||
using Biskilog_Cloud.Shared.Interfaces; |
|
||||
using System; |
|
||||
using System.Collections.Generic; |
|
||||
using System.Linq; |
|
||||
using System.Text; |
|
||||
using System.Threading.Tasks; |
|
||||
|
|
||||
namespace Biskilog_Cloud.Shared.ServiceRepo |
|
||||
{ |
|
||||
public class SearchService : ISearchService |
|
||||
{ |
|
||||
public event Action<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(); |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
} |
|
Loading…
Reference in new issue