2018-11-25 21:00:36 -05:00
|
|
|
|
using Microsoft.EntityFrameworkCore;
|
2018-04-08 02:44:42 -04:00
|
|
|
|
using SharedLibraryCore.Database;
|
|
|
|
|
using SharedLibraryCore.Database.Models;
|
|
|
|
|
using SharedLibraryCore.Objects;
|
2018-11-25 21:00:36 -05:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Threading.Tasks;
|
2018-11-05 22:01:29 -05:00
|
|
|
|
using static SharedLibraryCore.Database.Models.EFClient;
|
2017-11-25 20:29:58 -05:00
|
|
|
|
|
2018-04-08 02:44:42 -04:00
|
|
|
|
namespace SharedLibraryCore.Services
|
2017-11-25 20:29:58 -05:00
|
|
|
|
{
|
2017-11-29 19:35:50 -05:00
|
|
|
|
|
2017-11-25 20:29:58 -05:00
|
|
|
|
public class ClientService : Interfaces.IEntityService<EFClient>
|
|
|
|
|
{
|
|
|
|
|
public async Task<EFClient> Create(EFClient entity)
|
|
|
|
|
{
|
2017-11-29 19:35:50 -05:00
|
|
|
|
using (var context = new DatabaseContext())
|
2017-11-25 20:29:58 -05:00
|
|
|
|
{
|
2018-11-25 21:00:36 -05:00
|
|
|
|
var client = new EFClient()
|
|
|
|
|
{
|
|
|
|
|
Level = Permission.User,
|
|
|
|
|
FirstConnection = DateTime.UtcNow,
|
|
|
|
|
Connections = 1,
|
|
|
|
|
LastConnection = DateTime.UtcNow,
|
|
|
|
|
Masked = false,
|
|
|
|
|
NetworkId = entity.NetworkId,
|
|
|
|
|
AliasLink = new EFAliasLink()
|
|
|
|
|
{
|
|
|
|
|
Active = false
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
client.CurrentAlias = new Alias()
|
|
|
|
|
{
|
|
|
|
|
Name = entity.Name,
|
|
|
|
|
Link = client.AliasLink,
|
|
|
|
|
DateAdded = DateTime.UtcNow,
|
|
|
|
|
// the first time a client is created, we may not have their ip,
|
|
|
|
|
// so we create a temporary alias
|
|
|
|
|
Active = false
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
context.Clients.Add(client);
|
|
|
|
|
await context.SaveChangesAsync();
|
|
|
|
|
|
|
|
|
|
return client;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public async Task UpdateAlias(EFClient entity)
|
|
|
|
|
{
|
|
|
|
|
using (var context = new DatabaseContext())
|
|
|
|
|
{
|
|
|
|
|
context.Attach(entity);
|
|
|
|
|
|
|
|
|
|
string name = entity.Name;
|
|
|
|
|
int? ip = entity.IPAddress;
|
|
|
|
|
|
2017-11-29 19:35:50 -05:00
|
|
|
|
bool hasExistingAlias = false;
|
2018-11-25 21:00:36 -05:00
|
|
|
|
|
2017-11-25 20:29:58 -05:00
|
|
|
|
// get all aliases by IP
|
2017-11-29 19:35:50 -05:00
|
|
|
|
var aliases = await context.Aliases
|
|
|
|
|
.Include(a => a.Link)
|
2018-11-25 21:00:36 -05:00
|
|
|
|
.Where(a => a.IPAddress != null && a.IPAddress == ip)
|
2017-11-29 19:35:50 -05:00
|
|
|
|
.ToListAsync();
|
2017-11-25 20:29:58 -05:00
|
|
|
|
|
2017-11-29 19:35:50 -05:00
|
|
|
|
// see if they have a matching IP + Name but new NetworkId
|
2018-11-25 21:00:36 -05:00
|
|
|
|
var existingAlias = aliases.FirstOrDefault(a => a.Name == name);
|
2017-11-29 19:35:50 -05:00
|
|
|
|
// if existing alias matches link them
|
|
|
|
|
EFAliasLink aliasLink = existingAlias?.Link;
|
|
|
|
|
// if no exact matches find the first IP that matches
|
|
|
|
|
aliasLink = aliasLink ?? aliases.FirstOrDefault()?.Link;
|
|
|
|
|
// if no exact or IP matches, create new link
|
2018-11-25 21:00:36 -05:00
|
|
|
|
aliasLink = aliasLink ?? new EFAliasLink();
|
2017-11-29 19:35:50 -05:00
|
|
|
|
|
|
|
|
|
// this has to be set here because we can't evalute it properly later
|
|
|
|
|
hasExistingAlias = existingAlias != null;
|
|
|
|
|
|
2018-11-25 21:00:36 -05:00
|
|
|
|
if (hasExistingAlias && !entity.AliasLink.Active)
|
|
|
|
|
{
|
|
|
|
|
// we want to delete the temporary alias
|
|
|
|
|
context.Entry(entity.CurrentAlias).State = EntityState.Deleted;
|
|
|
|
|
entity.CurrentAlias = null;
|
|
|
|
|
|
|
|
|
|
// we want to delete the temporary alias link
|
|
|
|
|
context.Entry(entity.AliasLink).State = EntityState.Deleted;
|
|
|
|
|
entity.AliasLink = null;
|
|
|
|
|
|
|
|
|
|
// they have an existing alias so assign it
|
|
|
|
|
entity.CurrentAlias = existingAlias;
|
|
|
|
|
entity.AliasLink = aliasLink;
|
|
|
|
|
|
|
|
|
|
await context.SaveChangesAsync();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// update the temporary alias to permanent one
|
|
|
|
|
else if (!entity.AliasLink.Active)
|
|
|
|
|
{
|
|
|
|
|
// we want to track the current alias and link
|
|
|
|
|
var alias = context.Update(entity.CurrentAlias).Entity;
|
|
|
|
|
var _aliasLink = context.Update(entity.AliasLink).Entity;
|
|
|
|
|
|
|
|
|
|
alias.Active = true;
|
|
|
|
|
alias.IPAddress = ip;
|
|
|
|
|
alias.Name = name;
|
|
|
|
|
_aliasLink.Active = true;
|
|
|
|
|
|
|
|
|
|
existingAlias = alias;
|
|
|
|
|
aliasLink = _aliasLink;
|
|
|
|
|
}
|
|
|
|
|
|
2017-11-29 19:35:50 -05:00
|
|
|
|
// if no existing alias create new alias
|
|
|
|
|
existingAlias = existingAlias ?? new EFAlias()
|
2017-11-25 20:29:58 -05:00
|
|
|
|
{
|
2017-11-29 19:35:50 -05:00
|
|
|
|
DateAdded = DateTime.UtcNow,
|
2018-11-25 21:00:36 -05:00
|
|
|
|
IPAddress = ip,
|
2017-11-29 19:35:50 -05:00
|
|
|
|
Link = aliasLink,
|
2018-11-25 21:00:36 -05:00
|
|
|
|
Name = name,
|
2017-11-29 19:35:50 -05:00
|
|
|
|
};
|
|
|
|
|
|
2018-11-25 21:00:36 -05:00
|
|
|
|
var iqExistingPermission = context.Clients.Where(c => c.AliasLinkId == existingAlias.LinkId)
|
|
|
|
|
.OrderByDescending(client => client.Level)
|
|
|
|
|
.Select(c => new EFClient() { Level = c.Level });
|
|
|
|
|
|
|
|
|
|
entity.Level = hasExistingAlias ?
|
|
|
|
|
(await iqExistingPermission.FirstOrDefaultAsync())?.Level ?? Permission.User :
|
|
|
|
|
Permission.User;
|
|
|
|
|
#if DEBUG
|
|
|
|
|
string sql = iqExistingPermission.AsQueryable().ToSql();
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
if (entity.CurrentAlias != existingAlias ||
|
|
|
|
|
entity.AliasLink != aliasLink)
|
2017-11-29 19:35:50 -05:00
|
|
|
|
{
|
2018-11-25 21:00:36 -05:00
|
|
|
|
entity.CurrentAlias = existingAlias;
|
|
|
|
|
entity.AliasLink = aliasLink;
|
2017-11-25 20:29:58 -05:00
|
|
|
|
|
2018-11-25 21:00:36 -05:00
|
|
|
|
context.Update(entity);
|
|
|
|
|
}
|
2017-11-25 20:29:58 -05:00
|
|
|
|
|
2018-11-25 21:00:36 -05:00
|
|
|
|
await context.SaveChangesAsync();
|
2017-11-25 20:29:58 -05:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public async Task<EFClient> Delete(EFClient entity)
|
|
|
|
|
{
|
2017-11-29 19:35:50 -05:00
|
|
|
|
using (var context = new DatabaseContext())
|
2017-11-25 20:29:58 -05:00
|
|
|
|
{
|
2017-11-29 19:35:50 -05:00
|
|
|
|
var client = context.Clients
|
|
|
|
|
.Single(e => e.ClientId == entity.ClientId);
|
2017-11-25 20:29:58 -05:00
|
|
|
|
entity.Active = false;
|
|
|
|
|
context.Entry(entity).State = EntityState.Modified;
|
|
|
|
|
await context.SaveChangesAsync();
|
|
|
|
|
return entity;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public async Task<IList<EFClient>> Find(Func<EFClient, bool> e)
|
|
|
|
|
{
|
2018-02-07 00:19:06 -05:00
|
|
|
|
return await Task.Run(() =>
|
|
|
|
|
{
|
2018-09-13 15:34:42 -04:00
|
|
|
|
using (var context = new DatabaseContext(true))
|
2018-02-11 20:17:20 -05:00
|
|
|
|
{
|
2018-02-07 00:19:06 -05:00
|
|
|
|
return context.Clients
|
|
|
|
|
.Include(c => c.CurrentAlias)
|
|
|
|
|
.Include(c => c.AliasLink.Children)
|
|
|
|
|
.Where(e).ToList();
|
2018-02-11 20:17:20 -05:00
|
|
|
|
}
|
2018-02-07 00:19:06 -05:00
|
|
|
|
});
|
2017-11-25 20:29:58 -05:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public async Task<EFClient> Get(int entityID)
|
|
|
|
|
{
|
2018-09-13 15:34:42 -04:00
|
|
|
|
using (var context = new DatabaseContext(true))
|
2018-02-10 23:33:42 -05:00
|
|
|
|
{
|
2018-05-14 13:55:10 -04:00
|
|
|
|
var iqClient = from client in context.Clients
|
|
|
|
|
.Include(c => c.CurrentAlias)
|
|
|
|
|
.Include(c => c.AliasLink.Children)
|
2018-06-02 00:48:10 -04:00
|
|
|
|
.Include(c => c.Meta)
|
2018-05-14 13:55:10 -04:00
|
|
|
|
where client.ClientId == entityID
|
|
|
|
|
select new
|
|
|
|
|
{
|
|
|
|
|
Client = client,
|
|
|
|
|
LinkedAccounts = (from linkedClient in context.Clients
|
2018-06-07 22:19:12 -04:00
|
|
|
|
where client.AliasLinkId == linkedClient.AliasLinkId
|
|
|
|
|
select new
|
|
|
|
|
{
|
|
|
|
|
linkedClient.ClientId,
|
|
|
|
|
linkedClient.NetworkId
|
|
|
|
|
})
|
2018-05-14 13:55:10 -04:00
|
|
|
|
};
|
2018-09-13 15:34:42 -04:00
|
|
|
|
#if DEBUG == true
|
|
|
|
|
var clientSql = iqClient.ToSql();
|
|
|
|
|
#endif
|
2018-05-14 13:55:10 -04:00
|
|
|
|
var foundClient = await iqClient.FirstOrDefaultAsync();
|
|
|
|
|
|
2018-05-24 15:48:57 -04:00
|
|
|
|
if (foundClient == null)
|
2018-11-25 21:00:36 -05:00
|
|
|
|
{
|
2018-05-24 15:48:57 -04:00
|
|
|
|
return null;
|
2018-11-25 21:00:36 -05:00
|
|
|
|
}
|
2018-05-24 15:48:57 -04:00
|
|
|
|
|
2018-05-14 13:55:10 -04:00
|
|
|
|
foundClient.Client.LinkedAccounts = new Dictionary<int, long>();
|
|
|
|
|
// todo: find out the best way to do this
|
|
|
|
|
// I'm doing this here because I don't know the best way to have multiple awaits in the query
|
|
|
|
|
foreach (var linked in foundClient.LinkedAccounts)
|
2018-11-25 21:00:36 -05:00
|
|
|
|
{
|
2018-05-14 13:55:10 -04:00
|
|
|
|
foundClient.Client.LinkedAccounts.Add(linked.ClientId, linked.NetworkId);
|
2018-11-25 21:00:36 -05:00
|
|
|
|
}
|
2018-05-14 13:55:10 -04:00
|
|
|
|
|
|
|
|
|
return foundClient.Client;
|
2018-02-10 23:33:42 -05:00
|
|
|
|
}
|
2017-11-25 20:29:58 -05:00
|
|
|
|
}
|
|
|
|
|
|
2018-09-13 15:34:42 -04:00
|
|
|
|
private static readonly Func<DatabaseContext, long, Task<EFClient>> _getUniqueQuery =
|
|
|
|
|
EF.CompileAsyncQuery((DatabaseContext context, long networkId) =>
|
|
|
|
|
context.Clients
|
|
|
|
|
.Include(c => c.CurrentAlias)
|
|
|
|
|
.Include(c => c.AliasLink.Children)
|
|
|
|
|
.FirstOrDefault(c => c.NetworkId == networkId)
|
|
|
|
|
);
|
|
|
|
|
|
2018-02-10 23:33:42 -05:00
|
|
|
|
public async Task<EFClient> GetUnique(long entityAttribute)
|
2017-11-25 20:29:58 -05:00
|
|
|
|
{
|
2018-09-13 15:34:42 -04:00
|
|
|
|
using (var context = new DatabaseContext(true))
|
2017-11-25 20:29:58 -05:00
|
|
|
|
{
|
2018-09-13 15:34:42 -04:00
|
|
|
|
return await _getUniqueQuery(context, entityAttribute);
|
2017-11-25 20:29:58 -05:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public async Task<EFClient> Update(EFClient entity)
|
|
|
|
|
{
|
2017-11-29 19:35:50 -05:00
|
|
|
|
using (var context = new DatabaseContext())
|
2017-11-25 20:29:58 -05:00
|
|
|
|
{
|
2017-11-29 19:35:50 -05:00
|
|
|
|
// grab the context version of the entity
|
|
|
|
|
var client = context.Clients
|
|
|
|
|
.Include(c => c.AliasLink)
|
2018-02-07 00:19:06 -05:00
|
|
|
|
.Include(c => c.CurrentAlias)
|
2018-11-25 21:00:36 -05:00
|
|
|
|
.First(e => e.ClientId == entity.ClientId);
|
2018-09-11 15:28:37 -04:00
|
|
|
|
|
2017-11-29 19:35:50 -05:00
|
|
|
|
// if their level has been changed
|
|
|
|
|
if (entity.Level != client.Level)
|
|
|
|
|
{
|
|
|
|
|
// get all clients that use the same aliasId
|
2018-05-24 15:48:57 -04:00
|
|
|
|
var matchingClients = context.Clients
|
2018-06-16 22:11:25 -04:00
|
|
|
|
.Where(c => c.CurrentAliasId == client.CurrentAliasId)
|
|
|
|
|
// make sure we don't select ourselves twice
|
|
|
|
|
.Where(c => c.ClientId != entity.ClientId);
|
2017-11-29 19:35:50 -05:00
|
|
|
|
|
|
|
|
|
// update all related clients level
|
2018-06-16 22:11:25 -04:00
|
|
|
|
await matchingClients.ForEachAsync(c =>
|
|
|
|
|
{
|
2018-06-26 21:17:24 -04:00
|
|
|
|
c.Level = entity.Level;
|
2018-06-16 22:11:25 -04:00
|
|
|
|
});
|
2017-11-29 19:35:50 -05:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// their alias has been updated and not yet saved
|
|
|
|
|
if (entity.CurrentAlias.AliasId == 0)
|
|
|
|
|
{
|
|
|
|
|
client.CurrentAlias = new EFAlias()
|
|
|
|
|
{
|
2018-11-25 21:00:36 -05:00
|
|
|
|
Active = entity.CurrentAlias.IPAddress.HasValue ? true : false,
|
2017-11-29 19:35:50 -05:00
|
|
|
|
DateAdded = DateTime.UtcNow,
|
|
|
|
|
IPAddress = entity.CurrentAlias.IPAddress,
|
|
|
|
|
Name = entity.CurrentAlias.Name,
|
|
|
|
|
Link = client.AliasLink
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
2018-03-06 02:22:19 -05:00
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
client.CurrentAliasId = entity.CurrentAliasId;
|
2018-11-25 21:00:36 -05:00
|
|
|
|
client.IPAddress = entity.IPAddress;
|
|
|
|
|
client.Name = entity.Name;
|
2018-03-06 02:22:19 -05:00
|
|
|
|
}
|
|
|
|
|
|
2017-11-29 19:35:50 -05:00
|
|
|
|
// set remaining non-navigation properties that may have been updated
|
|
|
|
|
client.Level = entity.Level;
|
|
|
|
|
client.LastConnection = entity.LastConnection;
|
|
|
|
|
client.Connections = entity.Connections;
|
|
|
|
|
client.FirstConnection = entity.FirstConnection;
|
|
|
|
|
client.Masked = entity.Masked;
|
2018-04-04 15:38:34 -04:00
|
|
|
|
client.TotalConnectionTime = entity.TotalConnectionTime;
|
|
|
|
|
client.Password = entity.Password;
|
|
|
|
|
client.PasswordSalt = entity.PasswordSalt;
|
2017-11-29 19:35:50 -05:00
|
|
|
|
|
|
|
|
|
// update in database
|
2017-11-25 20:29:58 -05:00
|
|
|
|
await context.SaveChangesAsync();
|
2017-11-29 19:35:50 -05:00
|
|
|
|
|
|
|
|
|
// this is set so future updates don't trigger a new alias add
|
|
|
|
|
if (entity.CurrentAlias.AliasId == 0)
|
2018-11-25 21:00:36 -05:00
|
|
|
|
{
|
2018-02-07 00:19:06 -05:00
|
|
|
|
entity.CurrentAlias.AliasId = client.CurrentAlias.AliasId;
|
2018-11-25 21:00:36 -05:00
|
|
|
|
}
|
|
|
|
|
|
2017-11-29 19:35:50 -05:00
|
|
|
|
return client;
|
2017-11-25 20:29:58 -05:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-09-16 16:34:16 -04:00
|
|
|
|
#region ServiceSpecific
|
2017-11-25 20:29:58 -05:00
|
|
|
|
public async Task<IList<EFClient>> GetOwners()
|
|
|
|
|
{
|
2017-11-29 19:35:50 -05:00
|
|
|
|
using (var context = new DatabaseContext())
|
2018-11-25 21:00:36 -05:00
|
|
|
|
{
|
2017-11-29 19:35:50 -05:00
|
|
|
|
return await context.Clients
|
2018-11-05 22:01:29 -05:00
|
|
|
|
.Where(c => c.Level == Permission.Owner)
|
2017-11-29 19:35:50 -05:00
|
|
|
|
.ToListAsync();
|
2018-11-25 21:00:36 -05:00
|
|
|
|
}
|
2017-11-25 20:29:58 -05:00
|
|
|
|
}
|
|
|
|
|
|
2018-11-25 21:00:36 -05:00
|
|
|
|
public async Task<List<EFClient>> GetPrivilegedClients()
|
2018-02-16 23:24:03 -05:00
|
|
|
|
{
|
2018-09-13 15:34:42 -04:00
|
|
|
|
using (var context = new DatabaseContext(disableTracking: true))
|
2018-02-16 23:24:03 -05:00
|
|
|
|
{
|
2018-05-14 13:55:10 -04:00
|
|
|
|
var iqClients = from client in context.Clients
|
2018-11-05 22:01:29 -05:00
|
|
|
|
where client.Level >= Permission.Trusted
|
2018-09-13 15:34:42 -04:00
|
|
|
|
where client.Active
|
2018-11-25 21:00:36 -05:00
|
|
|
|
select new EFClient()
|
2018-09-13 15:34:42 -04:00
|
|
|
|
{
|
2018-11-25 22:11:55 -05:00
|
|
|
|
AliasLinkId = client.AliasLinkId,
|
2018-11-25 21:00:36 -05:00
|
|
|
|
CurrentAlias = client.CurrentAlias,
|
2018-09-13 15:34:42 -04:00
|
|
|
|
ClientId = client.ClientId,
|
2018-11-25 21:00:36 -05:00
|
|
|
|
Level = client.Level,
|
|
|
|
|
Password = client.Password,
|
|
|
|
|
PasswordSalt = client.PasswordSalt
|
2018-09-13 15:34:42 -04:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#if DEBUG == true
|
|
|
|
|
var clientsSql = iqClients.ToSql();
|
|
|
|
|
#endif
|
2018-05-14 13:55:10 -04:00
|
|
|
|
|
|
|
|
|
return await iqClients.ToListAsync();
|
2018-02-11 20:17:20 -05:00
|
|
|
|
}
|
2017-11-25 20:29:58 -05:00
|
|
|
|
}
|
|
|
|
|
|
2018-10-15 20:51:04 -04:00
|
|
|
|
public async Task<IList<EFClient>> FindClientsByIdentifier(string identifier)
|
2018-02-11 20:17:20 -05:00
|
|
|
|
{
|
2018-10-15 20:51:04 -04:00
|
|
|
|
if (identifier.Length < 3)
|
|
|
|
|
{
|
2018-04-21 18:18:20 -04:00
|
|
|
|
return new List<EFClient>();
|
2018-10-15 20:51:04 -04:00
|
|
|
|
}
|
2018-04-21 18:18:20 -04:00
|
|
|
|
|
2018-10-15 20:51:04 -04:00
|
|
|
|
identifier = identifier.ToLower();
|
2018-06-07 22:19:12 -04:00
|
|
|
|
|
2018-09-16 16:34:16 -04:00
|
|
|
|
using (var context = new DatabaseContext(disableTracking: true))
|
2018-09-11 15:28:37 -04:00
|
|
|
|
{
|
2018-10-15 20:51:04 -04:00
|
|
|
|
long networkId = identifier.ConvertLong();
|
|
|
|
|
int ipAddress = identifier.ConvertToIP();
|
2018-06-07 22:19:12 -04:00
|
|
|
|
|
2018-09-11 15:28:37 -04:00
|
|
|
|
var iqLinkIds = (from alias in context.Aliases
|
2018-10-15 20:51:04 -04:00
|
|
|
|
where alias.IPAddress == ipAddress ||
|
|
|
|
|
alias.Name.ToLower().Contains(identifier)
|
|
|
|
|
select alias.LinkId).Distinct();
|
2018-09-11 15:28:37 -04:00
|
|
|
|
|
|
|
|
|
var linkIds = iqLinkIds.ToList();
|
|
|
|
|
|
|
|
|
|
var iqClients = context.Clients
|
2018-10-15 20:51:04 -04:00
|
|
|
|
.Where(c => linkIds.Contains(c.AliasLinkId) ||
|
|
|
|
|
networkId == c.NetworkId)
|
2018-09-11 15:28:37 -04:00
|
|
|
|
.Include(c => c.CurrentAlias)
|
|
|
|
|
.Include(c => c.AliasLink.Children);
|
|
|
|
|
|
|
|
|
|
#if DEBUG == true
|
|
|
|
|
var iqClientsSql = iqClients.ToSql();
|
|
|
|
|
#endif
|
2018-02-23 02:06:13 -05:00
|
|
|
|
|
|
|
|
|
return await iqClients.ToListAsync();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-11-25 20:29:58 -05:00
|
|
|
|
public async Task<int> GetTotalClientsAsync()
|
|
|
|
|
{
|
2018-09-16 16:34:16 -04:00
|
|
|
|
using (var context = new DatabaseContext(true))
|
2018-11-25 21:00:36 -05:00
|
|
|
|
{
|
2017-11-29 19:35:50 -05:00
|
|
|
|
return await context.Clients
|
|
|
|
|
.CountAsync();
|
2018-11-25 21:00:36 -05:00
|
|
|
|
}
|
2017-11-25 20:29:58 -05:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Task<EFClient> CreateProxy()
|
|
|
|
|
{
|
|
|
|
|
throw new NotImplementedException();
|
|
|
|
|
}
|
2018-09-16 16:34:16 -04:00
|
|
|
|
#endregion
|
2017-11-25 20:29:58 -05:00
|
|
|
|
}
|
|
|
|
|
}
|