/// <summary> /// Mark the message as read by the user /// </summary> /// <param name="msgId"></param> /// <param name="username"></param> public bool SetMessageRead(int msgId, string username) { MessageRead isSet = MessageReads .Where(mr => mr.MessgeId == msgId && mr.UserId == username).FirstOrDefault(); if (isSet == null) { MessageReads.Add(new MessageRead() { MessgeId = msgId, UserId = username }); } return(isSet == null); }
/// <summary> /// Test if the user has already read the message /// </summary> /// <param name="username"></param> /// <returns></returns> public bool IsRead(string username) => MessageReads.Select(u => u.UserId).Contains(username);