Compare commits

...

1 Commits

Author SHA1 Message Date
Robert Paciorek
f515ab6f45 user data export and import interfce (WIP) 2025-07-17 19:17:16 +00:00
27 changed files with 257 additions and 10 deletions

View File

@ -0,0 +1,146 @@
using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using System.Text.Json;
using System.Text.Json.Serialization;
using System.Text.Encodings.Web;
using sodoff.Model;
namespace sodoff.Controllers.Common;
public class ExportController : ControllerBase {
private readonly DBContext ctx;
public ExportController(DBContext ctx) {
this.ctx = ctx;
}
[HttpPost]
[Route("ImportExport.asmx/Export")]
public IActionResult Export([FromForm] string username, [FromForm] string password) {
// Authenticate user by Username
User? user = ctx.Users.FirstOrDefault(e => e.Username == username);
if (user is null || new PasswordHasher<object>().VerifyHashedPassword(null, user.Password, password) == PasswordVerificationResult.Failed) {
return Unauthorized("Invalid username or password.");
}
// Serialize to JSON
var options = new JsonSerializerOptions
{
ReferenceHandler = ReferenceHandler.IgnoreCycles,
Encoder = System.Text.Encodings.Web.JavaScriptEncoder.UnsafeRelaxedJsonEscaping,
WriteIndented = true
};
string jsonData = JsonSerializer.Serialize(user, options);
return Ok(jsonData);
}
[HttpPost]
[Route("ImportExport.asmx/Import")]
public IActionResult Import([FromForm] string username, [FromForm] string password, [FromForm] string vikingName, [FromForm] IFormFile dataFile) {
User? user = ctx.Users.FirstOrDefault(e => e.Username == username);
if (user is null || new PasswordHasher<object>().VerifyHashedPassword(null, user.Password, password) == PasswordVerificationResult.Failed) {
return Unauthorized("Invalid username or password.");
}
User user_data;
using (var reader = new StreamReader(dataFile.OpenReadStream())) {
user_data = System.Text.Json.JsonSerializer.Deserialize<User>(reader.ReadToEnd());
}
foreach (var v in user_data.Vikings) {
if (v.Name == vikingName) {
Viking viking = new Viking {
Uid = v.Uid, // TODO check for unique or just generate new?
Name = v.Name, // TODO check for unique
User = user,
AvatarSerialized = v.AvatarSerialized,
CreationDate = v.CreationDate, // TODO or use now?
BirthDate = v.BirthDate,
Gender = v.Gender,
GameVersion = v.GameVersion
};
user.Vikings.Add(viking);
foreach (var x in v.Dragons) {
x.Viking = viking;
// TODO check EntityId for unique or just generate new?
x.Id = 0; // FIXME map old→new value for dragon id to update (stables) xml's
ctx.Dragons.Add(x);
}
foreach (var x in v.Images) {
x.Viking = viking;
ctx.Images.Add(x);
}
foreach (var x in v.InventoryItems) {
x.Id = 0; // FIXME map old→new value for item id to update xml's and rooms
x.Viking = viking;
ctx.InventoryItems.Add(x);
}
foreach (var x in v.Rooms) {
x.Viking = viking;
ctx.Rooms.Add(x); // FIXME need update room name (if numeric)
}
foreach (var x in v.MissionStates) {
x.Viking = viking;
ctx.MissionStates.Add(x);
}
foreach (var x in v.TaskStatuses) {
x.Viking = viking;
ctx.TaskStatuses.Add(x);
}
foreach (var x in v.AchievementTaskStates) {
x.Viking = viking;
ctx.AchievementTaskState.Add(x);
}
foreach (var x in v.AchievementPoints) {
x.Viking = viking;
ctx.AchievementPoints.Add(x);
}
foreach (var x in v.PairData) {
x.Viking = viking;
ctx.PairData.Add(x); // FIXME need update PetID in stable XML
}
foreach (var x in v.ProfileAnswers) {
x.Viking = viking;
ctx.ProfileAnswers.Add(x);
}
foreach (var x in v.GameData) {
x.Viking = viking;
ctx.GameData.Add(x);
}
foreach (var x in v.SavedData) {
x.Viking = viking;
ctx.SavedData.Add(x);
}
foreach (var x in v.Parties) {
x.Viking = viking;
ctx.Parties.Add(x);
}
foreach (var x in v.UserMissions) {
x.Viking = viking;
ctx.UserMissions.Add(x);
}
foreach (var x in v.UserBadgesCompleted) {
x.Viking = viking;
ctx.UserBadgesCompleted.Add(x);
}
if (v.Ratings.Count > 0) {
viking.Ratings = new List<Rating>();
foreach (var x in v.Ratings) {
// TODO (non-SoD) add rating via SetRating(viking, x.Rank.CategoryID, x.Rank.RatedEntityID, x.Rank.RatedUserID, x.Value);
}
}
if (v.Neighborhood != null) {
v.Neighborhood.Viking = viking;
ctx.Neighborhoods.Add(v.Neighborhood);
}
// TODO set viking.SelectedDragon
ctx.SaveChanges();
return Ok("OK");
}
}
return Ok("Viking Not Found");
}
}

View File

@ -1,12 +1,15 @@
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using System.Text.Json.Serialization;
namespace sodoff.Model; namespace sodoff.Model;
public class AchievementPoints { public class AchievementPoints {
[JsonIgnore]
public int VikingId { get; set; } public int VikingId { get; set; }
public int Type { get; set; } public int Type { get; set; }
public int Value { get; set; } public int Value { get; set; }
[JsonIgnore]
public virtual Viking? Viking { get; set; } public virtual Viking? Viking { get; set; }
} }

View File

@ -1,15 +1,18 @@
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using System.Text.Json.Serialization;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
namespace sodoff.Model; namespace sodoff.Model;
[PrimaryKey(nameof(TaskId), nameof(VikingId))] [PrimaryKey(nameof(TaskId), nameof(VikingId))]
public class AchievementTaskState { public class AchievementTaskState {
[JsonIgnore]
public int VikingId { get; set; } public int VikingId { get; set; }
public int TaskId { get; set; } public int TaskId { get; set; }
public int Points { get; set; } public int Points { get; set; }
[JsonIgnore]
public virtual Viking? Viking { get; set; } public virtual Viking? Viking { get; set; }
} }

View File

@ -23,6 +23,9 @@ public class DBContext : DbContext {
public DbSet<ProfileAnswer> ProfileAnswers { get; set; } = null!; public DbSet<ProfileAnswer> ProfileAnswers { get; set; } = null!;
public DbSet<MMORole> MMORoles { get; set; } = null!; public DbSet<MMORole> MMORoles { get; set; } = null!;
public DbSet<Party> Parties { get; set; } = null!; public DbSet<Party> Parties { get; set; } = null!;
public DbSet<AchievementTaskState> AchievementTaskState { get; set; } = null!;
public DbSet<SavedData> SavedData { get; set; } = null!;
public DbSet<UserMissionData> UserMissions { get; set; } = null!;
public DbSet<Neighborhood> Neighborhoods { get; set; } = null!; public DbSet<Neighborhood> Neighborhoods { get; set; } = null!;
// we had a brief debate on whether it's neighborhoods or neighborheed // we had a brief debate on whether it's neighborhoods or neighborheed
public DbSet<Group> Groups { get; set; } = null!; public DbSet<Group> Groups { get; set; } = null!;

View File

@ -1,22 +1,27 @@
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema; using System.ComponentModel.DataAnnotations.Schema;
using System.Text.Json.Serialization;
namespace sodoff.Model; namespace sodoff.Model;
public class Dragon { public class Dragon {
[Key] [Key]
// [JsonIgnore] used in serialised xml (stables)
[DatabaseGenerated(DatabaseGeneratedOption.Identity)] [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int Id { get; set; } public int Id { get; set; }
[Required] [Required]
public Guid EntityId { get; set; } public Guid EntityId { get; set; }
[Required] [Required]
[JsonIgnore]
public int VikingId { get; set; } public int VikingId { get; set; }
public string? RaisedPetData { get; set; } public string? RaisedPetData { get; set; }
public int? PetXP { get; set; } public int? PetXP { get; set; }
[JsonIgnore]
public virtual Viking Viking { get; set; } = null!; public virtual Viking Viking { get; set; } = null!;
public virtual ICollection<PairData> PairData { get; set; } = null!; public virtual ICollection<PairData> PairData { get; set; } = null!;
} }

View File

@ -1,10 +1,13 @@
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using System.Text.Json.Serialization;
namespace sodoff.Model; namespace sodoff.Model;
public class GameData { public class GameData {
[Key] [Key]
[JsonIgnore]
public int Id { get; set; } public int Id { get; set; }
[JsonIgnore]
public int VikingId { get; set; } public int VikingId { get; set; }
public int GameId { get; set; } public int GameId { get; set; }
@ -15,6 +18,6 @@ public class GameData {
public bool Win { get; set; } public bool Win { get; set; }
public bool Loss { get; set; } public bool Loss { get; set; }
public virtual ICollection<GameDataPair> GameDataPairs { get; set; } = null!; public virtual ICollection<GameDataPair> GameDataPairs { get; set; } = null!;
[JsonIgnore]
public virtual Viking Viking { get; set; } = null!; public virtual Viking Viking { get; set; } = null!;
} }

View File

@ -1,11 +1,15 @@
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using System.Text.Json.Serialization;
namespace sodoff.Model; namespace sodoff.Model;
public class GameDataPair { public class GameDataPair {
[Key] [Key]
[JsonIgnore]
public int Id { get; set; } public int Id { get; set; }
[JsonIgnore]
public int GameDataId { get; set; } public int GameDataId { get; set; }
public string Name { get; set; } = null!; public string Name { get; set; } = null!;
public int Value { get; set; } public int Value { get; set; }
[JsonIgnore]
public virtual GameData GameData { get; set; } = null!; public virtual GameData GameData { get; set; } = null!;
} }

View File

@ -1,4 +1,5 @@
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using System.Text.Json.Serialization;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
namespace sodoff.Model; namespace sodoff.Model;
@ -12,11 +13,13 @@ public class Image {
public int ImageSlot { get; set; } public int ImageSlot { get; set; }
[Required] [Required]
[JsonIgnore]
public int VikingId { get; set; } public int VikingId { get; set; }
public string? ImageData { get; set; } public string? ImageData { get; set; }
public string? TemplateName { get; set; } public string? TemplateName { get; set; }
[JsonIgnore]
public virtual Viking Viking { get; set; } = null!; public virtual Viking Viking { get; set; } = null!;
} }

View File

@ -1,18 +1,22 @@
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using System.Text.Json.Serialization;
namespace sodoff.Model { namespace sodoff.Model {
public class InventoryItem { public class InventoryItem {
[Key] [Key]
// [JsonIgnore] used as room id, used in serialised xml (pairs, ...)
public int Id { get; set; } public int Id { get; set; }
public int ItemId { get; set; } public int ItemId { get; set; }
[JsonIgnore]
public int VikingId { get; set; } public int VikingId { get; set; }
public string? StatsSerialized { get; set; } public string? StatsSerialized { get; set; }
public string? AttributesSerialized { get; set; } public string? AttributesSerialized { get; set; }
[JsonIgnore]
public virtual Viking Viking { get; set; } = null!; public virtual Viking Viking { get; set; } = null!;
public int Quantity { get; set; } public int Quantity { get; set; }

View File

@ -1,15 +1,18 @@
using sodoff.Schema; using sodoff.Schema;
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using System.Text.Json.Serialization;
namespace sodoff.Model; namespace sodoff.Model;
public class MMORole { public class MMORole {
[Key] [Key]
[JsonIgnore]
public int Id { get; set; } public int Id { get; set; }
public int VikingId { get; set; } public int VikingId { get; set; }
public Role Role { get; set; } public Role Role { get; set; }
[JsonIgnore]
public virtual Viking? Viking { get; set; } public virtual Viking? Viking { get; set; }
} }

View File

@ -1,15 +1,19 @@
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using System.Text.Json.Serialization;
namespace sodoff.Model; namespace sodoff.Model;
public class MissionState { public class MissionState {
[Key] [Key]
[JsonIgnore]
public int Id { get; set; } public int Id { get; set; }
public int MissionId { get; set; } public int MissionId { get; set; }
[JsonIgnore]
public int VikingId { get; set; } public int VikingId { get; set; }
[JsonIgnore]
public virtual Viking? Viking { get; set; } public virtual Viking? Viking { get; set; }
public MissionStatus MissionStatus { get; set; } public MissionStatus MissionStatus { get; set; }
@ -19,4 +23,4 @@ public class MissionState {
public enum MissionStatus { public enum MissionStatus {
Upcoming,Active,Completed Upcoming,Active,Completed
} }

View File

@ -1,18 +1,20 @@
using sodoff.Schema; using sodoff.Schema;
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using System.Data; using System.Text.Json.Serialization;
using System.Diagnostics.CodeAnalysis;
namespace sodoff.Model namespace sodoff.Model
{ {
public class Neighborhood public class Neighborhood
{ {
[JsonIgnore]
public virtual Viking? Viking { get; set; } public virtual Viking? Viking { get; set; }
[Key] [Key]
[JsonIgnore]
public int Id { get; set; } public int Id { get; set; }
[Required] [Required]
[JsonIgnore]
public int VikingId { get; set; } public int VikingId { get; set; }
[Required] [Required]

View File

@ -1,18 +1,22 @@
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema; using System.ComponentModel.DataAnnotations.Schema;
using System.Text.Json.Serialization;
namespace sodoff.Model; namespace sodoff.Model;
public class Pair { public class Pair {
[Key] [Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)] [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
[JsonIgnore]
public int Id { get; set; } public int Id { get; set; }
public string Key { get; set; } = null!; public string Key { get; set; } = null!;
public string Value { get; set; } = null!; public string Value { get; set; } = null!;
[JsonIgnore]
public int MasterId { get; set; } public int MasterId { get; set; }
[JsonIgnore]
public virtual PairData PairData { get; set; } = null!; public virtual PairData PairData { get; set; } = null!;
} }

View File

@ -1,6 +1,7 @@
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema; using System.ComponentModel.DataAnnotations.Schema;
using System.Text.Json.Serialization;
namespace sodoff.Model; namespace sodoff.Model;
@ -9,21 +10,28 @@ namespace sodoff.Model;
public class PairData { public class PairData {
[Key] [Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)] [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
[JsonIgnore]
public int Id { get; set; } public int Id { get; set; }
public int PairId { get; set; } public int PairId { get; set; }
[JsonIgnore]
public Guid? UserId { get; set; } public Guid? UserId { get; set; }
[JsonIgnore]
public int? VikingId { get; set; } public int? VikingId { get; set; }
[JsonIgnore]
public int? DragonId { get; set; } public int? DragonId { get; set; }
public virtual ICollection<Pair> Pairs { get; set; } public virtual ICollection<Pair> Pairs { get; set; }
[JsonIgnore]
public virtual User? User { get; set; } public virtual User? User { get; set; }
[JsonIgnore]
public virtual Viking? Viking { get; set; } public virtual Viking? Viking { get; set; }
[JsonIgnore]
public virtual Dragon? Dragon { get; set; } public virtual Dragon? Dragon { get; set; }
} }

View File

@ -1,18 +1,21 @@
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema; using System.Text.Json.Serialization;
namespace sodoff.Model namespace sodoff.Model
{ {
public class Party public class Party
{ {
[Key] [Key]
[JsonIgnore]
public int Id { get; set; } public int Id { get; set; }
public string Location { get; set; } = null!; public string Location { get; set; } = null!;
[JsonIgnore]
public int VikingId { get; set; } public int VikingId { get; set; }
public DateTime ExpirationDate { get; set; } = DateTime.UtcNow; public DateTime ExpirationDate { get; set; } = DateTime.UtcNow;
public bool? PrivateParty { get; set; } public bool? PrivateParty { get; set; }
public string LocationIconAsset { get; set; } = null!; public string LocationIconAsset { get; set; } = null!;
public string AssetBundle { get; set; } = null!; public string AssetBundle { get; set; } = null!;
[JsonIgnore]
public virtual Viking? Viking { get; set; } public virtual Viking? Viking { get; set; }
} }
} }

View File

@ -1,15 +1,19 @@
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using System.Text.Json.Serialization;
namespace sodoff.Model namespace sodoff.Model
{ {
public class ProfileAnswer public class ProfileAnswer
{ {
[Key] [Key]
[JsonIgnore]
public int Id { get; set; } public int Id { get; set; }
[JsonIgnore]
public int VikingId { get; set; } public int VikingId { get; set; }
public int QuestionID { get; set; } public int QuestionID { get; set; }
public int AnswerID { get; set; } public int AnswerID { get; set; }
[JsonIgnore]
public virtual Viking Viking { get; set; } = null!; public virtual Viking Viking { get; set; } = null!;
} }
} }

View File

@ -1,17 +1,21 @@
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using System.Text.Json.Serialization;
namespace sodoff.Model; namespace sodoff.Model;
public class Rating { public class Rating {
[Key] [Key]
[JsonIgnore]
public int Id { get; set; } public int Id { get; set; }
[JsonIgnore]
public int VikingId { get; set; } public int VikingId { get; set; }
public int RankId { get; set; } public int RankId { get; set; }
public int Value { get; set; } public int Value { get; set; }
public DateTime Date { get; set; } public DateTime Date { get; set; }
[JsonIgnore]
public virtual Viking Viking { get; set; } public virtual Viking Viking { get; set; }
public virtual RatingRank Rank { get; set; } public virtual RatingRank Rank { get; set; }
} }

View File

@ -1,9 +1,11 @@
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using System.Text.Json.Serialization;
namespace sodoff.Model; namespace sodoff.Model;
public class RatingRank { public class RatingRank {
[Key] [Key]
[JsonIgnore]
public int Id { get; set; } public int Id { get; set; }
public int CategoryID { get; set; } public int CategoryID { get; set; }
@ -14,5 +16,6 @@ public class RatingRank {
public float RatingAverage { get; set; } // On a scale of 1-5 public float RatingAverage { get; set; } // On a scale of 1-5
public DateTime UpdateDate { get; set; } public DateTime UpdateDate { get; set; }
[JsonIgnore]
public virtual ICollection<Rating> Ratings { get; set; } = null!; public virtual ICollection<Rating> Ratings { get; set; } = null!;
} }

View File

@ -1,18 +1,22 @@
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using System.Text.Json.Serialization;
namespace sodoff.Model; namespace sodoff.Model;
public class Room { public class Room {
[Key] [Key]
[JsonIgnore]
public int Id { get; set; } public int Id { get; set; }
public string RoomId { get; set; } public string RoomId { get; set; }
[JsonIgnore]
public int VikingId { get; set; } public int VikingId { get; set; }
public string? Name { get; set; } public string? Name { get; set; }
[JsonIgnore]
public virtual Viking? Viking { get; set; } public virtual Viking? Viking { get; set; }
public virtual ICollection<RoomItem> Items { get; set; } = null!; public virtual ICollection<RoomItem> Items { get; set; } = null!;
} }

View File

@ -1,12 +1,16 @@
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using System.Text.Json.Serialization;
namespace sodoff.Model; namespace sodoff.Model;
public class RoomItem { public class RoomItem {
[Key] [Key]
[JsonIgnore]
public int Id { get; set; } public int Id { get; set; }
[JsonIgnore]
public int RoomId { get; set; } public int RoomId { get; set; }
[JsonIgnore]
public virtual Room Room { get; set; } public virtual Room Room { get; set; }
public string RoomItemData { get; set; } public string RoomItemData { get; set; }

View File

@ -1,8 +1,12 @@
namespace sodoff.Model; using System.Text.Json.Serialization;
namespace sodoff.Model;
public class SavedData { public class SavedData {
[JsonIgnore]
public int VikingId { get; set; } public int VikingId { get; set; }
public uint SaveId { get; set; } public uint SaveId { get; set; }
public string? SerializedData { get; set; } public string? SerializedData { get; set; }
[JsonIgnore]
public virtual Viking Viking { get; set; } = null!; public virtual Viking Viking { get; set; } = null!;
} }

View File

@ -1,14 +1,18 @@
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using System.Text.Json.Serialization;
namespace sodoff.Model namespace sodoff.Model
{ {
public class SceneData public class SceneData
{ {
[Key] [Key]
[JsonIgnore]
public int Id { get; set; } public int Id { get; set; }
public int VikingId { get; set; } public int VikingId { get; set; }
public string SceneName { get; set; } = null!; public string SceneName { get; set; } = null!;
public string XmlData { get; set; } = null!; public string XmlData { get; set; } = null!;
[JsonIgnore]
public virtual Viking Viking { get; set; } = null!; public virtual Viking Viking { get; set; } = null!;
} }
} }

View File

@ -1,11 +1,15 @@
namespace sodoff.Model { using System.Text.Json.Serialization;
namespace sodoff.Model {
public class TaskStatus { public class TaskStatus {
public int Id { get; set; } public int Id { get; set; }
public int MissionId { get; set; } public int MissionId { get; set; }
[JsonIgnore]
public int VikingId { get; set; } public int VikingId { get; set; }
[JsonIgnore]
public virtual Viking? Viking { get; set; } public virtual Viking? Viking { get; set; }
public string? Payload { get; set; } public string? Payload { get; set; }

View File

@ -1,4 +1,5 @@
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using System.Text.Json.Serialization;
namespace sodoff.Model; namespace sodoff.Model;
public class User { public class User {
@ -14,6 +15,7 @@ public class User {
[Required] [Required]
public string Password { get; set; } = null!; public string Password { get; set; } = null!;
[JsonIgnore]
public virtual ICollection<Session> Sessions { get; set; } = null!; public virtual ICollection<Session> Sessions { get; set; } = null!;
public virtual ICollection<Viking> Vikings { get; set; } = null!; public virtual ICollection<Viking> Vikings { get; set; } = null!;
public virtual ICollection<PairData> PairData { get; set; } = null!; public virtual ICollection<PairData> PairData { get; set; } = null!;

View File

@ -1,11 +1,16 @@
namespace sodoff.Model using System.Text.Json.Serialization;
namespace sodoff.Model
{ {
public class UserBadgeCompleteData public class UserBadgeCompleteData
{ {
[JsonIgnore]
public int Id { get; set; } public int Id { get; set; }
[JsonIgnore]
public int VikingId { get; set; } public int VikingId { get; set; }
public int BadgeId { get; set; } public int BadgeId { get; set; }
[JsonIgnore]
public virtual Viking? Viking { get; set; } public virtual Viking? Viking { get; set; }
} }
} }

View File

@ -1,4 +1,5 @@
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using System.Text.Json.Serialization;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
namespace sodoff.Model namespace sodoff.Model
@ -6,6 +7,7 @@ namespace sodoff.Model
[PrimaryKey(nameof(VikingId), nameof(WorldId), nameof(MissionId))] [PrimaryKey(nameof(VikingId), nameof(WorldId), nameof(MissionId))]
public class UserMissionData public class UserMissionData
{ {
[JsonIgnore]
public int VikingId { get; set; } public int VikingId { get; set; }
public int WorldId { get; set; } public int WorldId { get; set; }
public int MissionId { get; set; } public int MissionId { get; set; }
@ -13,6 +15,7 @@ namespace sodoff.Model
public int TaskId { get; set; } public int TaskId { get; set; }
public bool IsCompleted { get; set; } = false; public bool IsCompleted { get; set; } = false;
[JsonIgnore]
public virtual Viking? Viking { get; set; } public virtual Viking? Viking { get; set; }
} }
} }

View File

@ -1,5 +1,6 @@
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using System.Text.Json.Serialization;
using sodoff.Schema; using sodoff.Schema;
namespace sodoff.Model; namespace sodoff.Model;
@ -7,6 +8,7 @@ namespace sodoff.Model;
[Index(nameof(Uid))] [Index(nameof(Uid))]
public class Viking { public class Viking {
[Key] [Key]
[JsonIgnore]
public int Id { get; set; } public int Id { get; set; }
public Guid Uid { get; set; } public Guid Uid { get; set; }
@ -15,13 +17,17 @@ public class Viking {
public string Name { get; set; } = null!; public string Name { get; set; } = null!;
[Required] [Required]
[JsonIgnore]
public Guid UserId { get; set; } public Guid UserId { get; set; }
public string? AvatarSerialized { get; set; } public string? AvatarSerialized { get; set; }
[JsonIgnore]
public int? SelectedDragonId { get; set; } public int? SelectedDragonId { get; set; }
[JsonIgnore]
public virtual ICollection<Session> Sessions { get; set; } = null!; public virtual ICollection<Session> Sessions { get; set; } = null!;
[JsonIgnore]
public virtual User User { get; set; } = null!; public virtual User User { get; set; } = null!;
public virtual ICollection<Dragon> Dragons { get; set; } = null!; public virtual ICollection<Dragon> Dragons { get; set; } = null!;
public virtual ICollection<Image> Images { get; set; } = null!; public virtual ICollection<Image> Images { get; set; } = null!;
@ -37,8 +43,10 @@ public class Viking {
public virtual ICollection<ProfileAnswer> ProfileAnswers { get; set; } = null!; public virtual ICollection<ProfileAnswer> ProfileAnswers { get; set; } = null!;
public virtual ICollection<SavedData> SavedData { get; set; } = null!; public virtual ICollection<SavedData> SavedData { get; set; } = null!;
public virtual ICollection<Party> Parties { get; set; } = null!; public virtual ICollection<Party> Parties { get; set; } = null!;
[JsonIgnore]
public virtual ICollection<MMORole> MMORoles { get; set; } = null!; public virtual ICollection<MMORole> MMORoles { get; set; } = null!;
public virtual Neighborhood? Neighborhood { get; set; } = null!; public virtual Neighborhood? Neighborhood { get; set; } = null!;
[JsonIgnore]
public virtual ICollection<Group> Groups { get; set; } = null!; public virtual ICollection<Group> Groups { get; set; } = null!;
public virtual ICollection<Rating> Ratings { get; set; } = null!; public virtual ICollection<Rating> Ratings { get; set; } = null!;
public virtual Dragon? SelectedDragon { get; set; } public virtual Dragon? SelectedDragon { get; set; }