Fix LINQ Expressions In `UpdateContactStatus
and
DeleteContact
`
This commit is contained in:
parent
52f02a6c8c
commit
acc11d536f
@ -24,7 +24,7 @@ namespace qtc_api.Hubs
|
|||||||
|
|
||||||
if (connection != null)
|
if (connection != null)
|
||||||
{
|
{
|
||||||
var user = OnlineUsers.FirstOrDefault(x => x.Id == connection!.ConnectedUser!.Id);
|
var user = OnlineUsers.FirstOrDefault(x => x.Id == connection.ConnectedUser!.Id);
|
||||||
|
|
||||||
if (user != null)
|
if (user != null)
|
||||||
{
|
{
|
||||||
@ -33,10 +33,27 @@ namespace qtc_api.Hubs
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async override Task OnConnectedAsync()
|
||||||
|
{
|
||||||
|
Log("Client Connected To Hub.");
|
||||||
|
|
||||||
|
var connection = ConnectedUsers.FirstOrDefault(x => x.ConnectionId == Context.ConnectionId);
|
||||||
|
|
||||||
|
if(connection != null)
|
||||||
|
{
|
||||||
|
var onlineUser = OnlineUsers.FirstOrDefault(x => x.Id == connection.ConnectedUser!.Id);
|
||||||
|
|
||||||
|
if (onlineUser != null)
|
||||||
|
{
|
||||||
|
// if the user is reconnecting, ensure their status is set to Online
|
||||||
|
await _userService.UpdateStatus(new UserStatusDto { Id = connection.ConnectedUser!.Id, Status = 1 });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
[HubMethodName("LoginHub")]
|
[HubMethodName("LoginHub")]
|
||||||
public async Task LoginAsync(User user)
|
public async Task LoginAsync(User user)
|
||||||
{
|
{
|
||||||
await Clients.All.SendAsync("rm", $"[SERVER] User {user.Username} Is Now Online");
|
|
||||||
Log($"User {user.Username} Has Logged In");
|
Log($"User {user.Username} Has Logged In");
|
||||||
|
|
||||||
var statusDto = new UserStatusDto { Id = user.Id, Status = 1 };
|
var statusDto = new UserStatusDto { Id = user.Id, Status = 1 };
|
||||||
|
@ -35,9 +35,10 @@
|
|||||||
public async Task<ServiceResponse<bool>> UpdateContactStatus(string ownerId, string userId, Contact.ContactStatus ownerStatus, Contact.ContactStatus userStatus)
|
public async Task<ServiceResponse<bool>> UpdateContactStatus(string ownerId, string userId, Contact.ContactStatus ownerStatus, Contact.ContactStatus userStatus)
|
||||||
{
|
{
|
||||||
var serviceResponse = new ServiceResponse<bool>();
|
var serviceResponse = new ServiceResponse<bool>();
|
||||||
var contact = await _dataContext.Contacts.FirstOrDefaultAsync(e => (e.OwnerId == ownerId || e.UserId == userId) || (e.OwnerId == userId || e.UserId == ownerId));
|
|
||||||
|
|
||||||
if(contact != null)
|
var contact = await _dataContext.Contacts.FirstOrDefaultAsync(e => (e.OwnerId == ownerId && e.UserId == userId) || (e.OwnerId == userId && e.UserId == ownerId));
|
||||||
|
|
||||||
|
if (contact != null)
|
||||||
{
|
{
|
||||||
contact.OwnerStatus = ownerStatus;
|
contact.OwnerStatus = ownerStatus;
|
||||||
contact.UserStatus = userStatus;
|
contact.UserStatus = userStatus;
|
||||||
@ -53,7 +54,7 @@
|
|||||||
public async Task<ServiceResponse<Contact>> DeleteContact(string ownerId, string userId)
|
public async Task<ServiceResponse<Contact>> DeleteContact(string ownerId, string userId)
|
||||||
{
|
{
|
||||||
var serviceResponse = new ServiceResponse<Contact>();
|
var serviceResponse = new ServiceResponse<Contact>();
|
||||||
var contact = await _dataContext.Contacts.FirstOrDefaultAsync(x => (x.OwnerId == ownerId || x.UserId == userId) || (x.OwnerId == userId || x.UserId == ownerId));
|
var contact = await _dataContext.Contacts.FirstOrDefaultAsync(e => (e.OwnerId == ownerId && e.UserId == userId) || (e.OwnerId == userId && e.UserId == ownerId));
|
||||||
|
|
||||||
if (contact != null)
|
if (contact != null)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user