public async Task <IActionResult> All() { var user = await GetKahlaUser(); var contacts = await _dbContext.MyContacts(user.Id).ToListAsync(); foreach (var contact in contacts) { contact.Online = contact.Discriminator == nameof(PrivateConversation) ? _onlineJudger.IsOnline(contact.UserId) : false; } return(Json(new AiurCollection <ContactInfo>(contacts) { Code = ErrorType.Success, Message = "Successfully get all your friends." })); }
public async Task <IActionResult> All() { var user = await GetKahlaUser(); var contacts = await _dbContext.MyContacts(user.Id).ToListAsync(); foreach (var contact in contacts) { if (contact.LatestMessage != null) { contact.LatestMessage.Sender = contact.Sender.Build(_onlineJudger); } contact.Online = contact.Discriminator == nameof(PrivateConversation) ? _onlineJudger.IsOnline(contact.UserId, !contact.EnableInvisiable) : null; } return(this.Protocol(new AiurCollection <ContactInfo>(contacts) { Code = ErrorType.Success, Message = "Successfully get all your friends." })); }
public KahlaUser Build(OnlineJudger judge) { IsOnline = judge.IsOnline(Id); return(this); }
public KahlaUser Build(OnlineJudger judge) { IsOnline = judge.IsOnline(Id, !EnableInvisiable); return(this); }