40 lines
1.1 KiB
C#
40 lines
1.1 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using Microsoft.Extensions.Options;
|
|
using MongoDB.Driver;
|
|
using UGQDatabase.Models;
|
|
using UGQDataAccess.Settings;
|
|
using ServerCommon.UGQ;
|
|
|
|
namespace UGQDataAccess.Repository
|
|
{
|
|
public class NpcNameRepository : BaseRepository<NpcNameEntity>
|
|
{
|
|
private const string CollectionName = "NpcName";
|
|
|
|
public NpcNameRepository(IMongoClient mongoClient, IOptions<UGQDatabaseSettings> settings) :
|
|
base(mongoClient, settings.Value.DatabaseName, CollectionName)
|
|
{
|
|
}
|
|
|
|
public async Task upsertNpcName(int npcId, TextEntity npcName)
|
|
{
|
|
var filter = Builders<NpcNameEntity>.Filter.Eq(x => x.NpcId, npcId);
|
|
|
|
var update = Builders<NpcNameEntity>.Update
|
|
.Set(x => x.NpcName, npcName);
|
|
|
|
var option = new UpdateOptions
|
|
{
|
|
IsUpsert = true,
|
|
};
|
|
|
|
await Collection.UpdateOneAsync(filter, update, option);
|
|
}
|
|
}
|
|
}
|
|
|