Uploading save game automatically creates SaveGameEntry.

This commit is contained in:
2020-07-05 16:11:44 +01:00
parent 88cb929501
commit 99465c51b6
2 changed files with 23 additions and 11 deletions
+20 -6
View File
@@ -1,6 +1,7 @@
using Firelance; using Firelance;
using Firelance.Models; using Firelance.Models;
using Gsm; using Gsm;
using MongoDB.Bson;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel; using System.ComponentModel;
@@ -246,21 +247,23 @@ namespace DevConsole
{ {
Guid firstMasterGameRecordGuid = flcCRUD.LoadRecordsFromTable<MasterGameRecordModel>( Guid firstMasterGameRecordGuid = flcCRUD.LoadRecordsFromTable<MasterGameRecordModel>(
Firelance.Collections.GameRecords).First().Id; Firelance.Collections.GameRecords).First().Id;
var masterGameRecordToRemove = flcCRUD.LoadRecordById<MasterGameRecordModel>( MasterGameRecordModel masterGameRecordToRemove = flcCRUD.LoadRecordById<MasterGameRecordModel>(
Firelance.Collections.GameRecords, firstMasterGameRecordGuid); Firelance.Collections.GameRecords, firstMasterGameRecordGuid);
Guid firstSaveGameEntryGuid = masterGameRecordToRemove.SaveGameEntries.Select(x => x.SaveDataID).First(); ObjectId firstSaveGameEntryObjId = masterGameRecordToRemove.SaveGameEntries.Select(x => x.SaveDataID).First();
masterGameRecordToRemove.SaveGameEntries.RemoveAll(x => x.SaveDataID == firstSaveGameEntryGuid); masterGameRecordToRemove.SaveGameEntries.RemoveAll(x => x.SaveDataID == firstSaveGameEntryObjId);
flcCRUD.UpsertRecordById(Firelance.Collections.GameRecords, flcCRUD.UpsertRecordById(Firelance.Collections.GameRecords,
firstMasterGameRecordGuid, firstMasterGameRecordGuid,
masterGameRecordToRemove); masterGameRecordToRemove);
} }
private static void FlcInsertSaveEntryAction() private static void FlcInsertSaveEntryAction()
{ {
Guid firstMasterGameRecordGuid = flcCRUD.LoadRecordsFromTable<MasterGameRecordModel>( Guid firstMasterGameRecordGuid = flcCRUD.LoadRecordsFromTable<MasterGameRecordModel>(
Firelance.Collections.GameRecords).First().Id; Firelance.Collections.GameRecords).First().Id;
var masterGameRecordToInsert = flcCRUD.LoadRecordById<MasterGameRecordModel>( MasterGameRecordModel masterGameRecordToInsert = flcCRUD.LoadRecordById<MasterGameRecordModel>(
Firelance.Collections.GameRecords, firstMasterGameRecordGuid); Firelance.Collections.GameRecords, firstMasterGameRecordGuid);
masterGameRecordToInsert.SaveGameEntries.Add(new SaveGameEntriesModel()); masterGameRecordToInsert.SaveGameEntries.Add(new SaveGameEntriesModel());
@@ -272,8 +275,19 @@ namespace DevConsole
private static void FlcUploadToGridFsAction() private static void FlcUploadToGridFsAction()
{ {
var flcGFS = new FirelanceGFS(flcMgr.Database); var flcGFS = new FirelanceGFS(flcMgr.Database);
var ulResult = flcGFS.UploadFile("TestFile", @"C:\Users\Dunestorm\Downloads\OpenMW-0.46.0-win64.exe"); var ulObjId = new ObjectId(flcGFS.UploadFile("TestFile", @"C:\Users\Dunestorm\Downloads\OpenMW-0.46.0-win64.exe").Result);
Console.WriteLine(ulResult.Result);
Guid firstMasterGameRecordGuid = flcCRUD.LoadRecordsFromTable<MasterGameRecordModel>(
Firelance.Collections.GameRecords).First().Id;
var saveGameEntry = flcCRUD.LoadRecordById<MasterGameRecordModel>(
Firelance.Collections.GameRecords, firstMasterGameRecordGuid);
saveGameEntry.SaveGameEntries.Add(new SaveGameEntriesModel() { SaveDataID = ulObjId });
flcCRUD.UpsertRecordById(Firelance.Collections.GameRecords,
firstMasterGameRecordGuid,
saveGameEntry);
Console.WriteLine(ulObjId);
} }
private static void FlcDownloadToGridFsAction() private static void FlcDownloadToGridFsAction()
+3 -5
View File
@@ -1,4 +1,5 @@
using MongoDB.Bson.Serialization.Attributes; using MongoDB.Bson;
using MongoDB.Bson.Serialization.Attributes;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@@ -6,10 +7,7 @@ namespace Firelance.Models
{ {
public class SaveGameEntriesModel public class SaveGameEntriesModel
{ {
//[BsonId] public ObjectId SaveDataID { get; set; }
//public Guid Id { get; set; }
public Guid SaveDataID { get; set; }
public Dictionary<string,uint> SaveDirectoryTreeSize { get; set; } public Dictionary<string,uint> SaveDirectoryTreeSize { get; set; }
public string Description { get; set; } public string Description { get; set; }
} }