This commit is contained in:
mmrbnjd
2024-06-09 17:23:57 +03:30
parent 11663c6e82
commit 82bcfc1ffe
11 changed files with 780 additions and 104 deletions

View File

@@ -18,38 +18,38 @@ namespace Back.Services
_repoCompany = repoCompany;
_repoRolUser = repoRolUser;
}
public async Task<bool> ExsistCompanyByComoanyIDandUserID(int ComoanyID, int UserID,bool InAdmin=false)
public async Task<bool> ExsistCompanyByComoanyIDandUserID(int ComoanyID, int UserID, bool InAdmin = false)
{
var res= _repoRolUser.Get(w => w.CompanyID == ComoanyID && w.UserID == UserID && w.Company.IsActive);
var res = _repoRolUser.Get(w => w.CompanyID == ComoanyID && w.UserID == UserID && w.Company.IsActive);
if (InAdmin)
res = res.Where( w=> w.IsAdmin);
res = res.Where(w => w.IsAdmin);
return await res.AnyAsync();
return await res.AnyAsync();
}
public async Task<CompanyDTO?> GetCompany(int ComoanyID)
{
return await _repoCompany.Get(w => w.ID == ComoanyID && w.IsActive)
.Select(s=>new CompanyDTO()
{
BranchID = s.BranchID,
EconomicCode = s.EconomicCode,
ID = s.ID,
Email = s.Email,
Logo= s.Logo==null ?null: System.Text.Encoding.UTF8.GetString(s.Logo) ,
Mobile = s.Mobile,
Name = s.Name,
Phone = s.Phone,
PrivateKey= s.PrivateKey,
UniqeMemory = s.UniqeMemory
}).FirstOrDefaultAsync();
return await _repoCompany.Get(w => w.ID == ComoanyID && w.IsActive)
.Select(s => new CompanyDTO()
{
BranchID = s.BranchID,
EconomicCode = s.EconomicCode,
ID = s.ID,
Email = s.Email,
Logo = s.Logo == null ? null : System.Text.Encoding.UTF8.GetString(s.Logo),
Mobile = s.Mobile,
Name = s.Name,
Phone = s.Phone,
PrivateKey = s.PrivateKey,
UniqeMemory = s.UniqeMemory
}).FirstOrDefaultAsync();
}
public async Task<Company?> GetCompanyOrg(int ComoanyID,bool IsActive=true)
public async Task<Company?> GetCompanyOrg(int ComoanyID, bool IsActive = true)
{
var inv = _repoCompany.Get(w => w.ID == ComoanyID);
if (IsActive)
inv= inv.Where(w=>w.IsActive);
return await inv.FirstOrDefaultAsync();
inv = inv.Where(w => w.IsActive);
return await inv.FirstOrDefaultAsync();
}
public async Task<Company?> GetCompanyOrgByMobileAndCompanynotActive(string Mobile)
{
@@ -72,16 +72,16 @@ namespace Back.Services
//};
//_contextMongodb.InsertItem(log);
if (item.ID == null || item.ID ==0)
if (item.ID == null || item.ID == 0)
{
return await _repoCompany.AddAsync(item);
return await _repoCompany.AddAsync(item);
}
else
{
return await _repoCompany.UpdateByObjAsync(item);
return await _repoCompany.UpdateByObjAsync(item);
}
}
catch (Exception ex)
@@ -144,15 +144,23 @@ namespace Back.Services
}
}
public async Task<bool> ExistMobileInCompany(string mobile,bool IsActive=true)
public async Task<bool> ExistMobileInCompany(string mobile, bool IsActive = true)
{
var resquest= _repoCompany.GetAll().Where(w => w.Mobile == mobile );
var resquest = _repoCompany.GetAll().Where(w => w.Mobile == mobile);
if (IsActive)
resquest = resquest.Where(w => w.IsActive);
return await resquest.AnyAsync();
}
public async Task<CheckAuthDTO> GetTaxAuth(int ComoanyID)
{
return await _repoCompany.Get(w => w.ID == ComoanyID && w.IsActive)
.Select(s => new CheckAuthDTO()
{
PrivateKey = s.PrivateKey,
UniqueMemory = s.UniqeMemory
}).FirstOrDefaultAsync();
}