2018-10-30 13:07:29 +08:00
|
|
|
|
using MongoDB.Driver;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
|
|
|
|
namespace Bootstrap.DataAccess.MongoDB
|
|
|
|
|
{
|
2018-10-31 17:50:13 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
///
|
|
|
|
|
/// </summary>
|
2018-10-30 13:07:29 +08:00
|
|
|
|
public class Message : DataAccess.Message
|
|
|
|
|
{
|
2018-10-31 17:50:13 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
///
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="userName"></param>
|
|
|
|
|
/// <returns></returns>
|
2019-01-11 23:20:28 +08:00
|
|
|
|
protected override IEnumerable<DataAccess.Message> Retrieves(string userName)
|
2018-10-30 13:07:29 +08:00
|
|
|
|
{
|
2019-05-18 21:21:03 +08:00
|
|
|
|
return DbManager.Messages.Find(message => message.To.ToLowerInvariant() == userName.ToLowerInvariant() || message.From.ToLowerInvariant() == userName.ToLowerInvariant()).ToList();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
///
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="msg"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public override bool Save(DataAccess.Message msg)
|
|
|
|
|
{
|
|
|
|
|
DbManager.Messages.InsertOne(msg);
|
|
|
|
|
return true;
|
2018-10-30 13:07:29 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|