using Biskilog_Accounting.Server.POSModels; using Biskilog_Accounting.Shared.Interfaces; using Biskilog_Accounting.Shared.POSModels; namespace Biskilog_Accounting.Server.Services { public class CompanyService : ICompanyInfo { private readonly BiskAcdbContext m_context; private readonly ITokenService m_tokenService; private readonly HttpContext m_httpContext; private Tblcompanydetail m_companyInfo { get; set; } private IEnumerable m_companyBranches { get; set; } public CompanyService(BiskAcdbContext a_context, ITokenService a_tokenService, IHttpContextAccessor a_httpContextAccessor) { m_context = a_context; m_tokenService = a_tokenService; m_httpContext = a_httpContextAccessor?.HttpContext; m_companyInfo = new Tblcompanydetail(); m_companyBranches = new List(); GetCompanyInfoAsync(); GetBranches(); } public IEnumerable FetchBranches() { return m_companyBranches; } public async Task> GetBranches() { m_companyBranches = m_context.Tblbranches; return await Task.FromResult(m_companyBranches); } public string GetBranchName(string a_branchId) { return m_companyBranches.FirstOrDefault(b => b.BranchId == a_branchId).BranchName; } public Task GetCompanyInfoAsync() { m_companyInfo = m_context.Tblcompanydetails.First(); return Task.FromResult(m_companyInfo); } public string GetCompanyName() { return m_companyInfo.CompanyName; } } }