Workshop - Added installed entries and update profiles when reinstalling them

This commit is contained in:
Robert committed 2023-09-06 20:39:43 +02:00
1 parent fcde1d4ecc
commit c69be2836e
17 files changed
+327 -58

No files matched your search

@@ -0,0 +1,21 @@
using System;
namespace Artemis.Storage.Entities.Workshop;
public class EntryEntity
{
public Guid Id { get; set; }
public Guid EntryId { get; set; }
public int EntryType { get; set; }
public string Author { get; set; }
public string Name { get; set; } = string.Empty;
public string Summary { get; set; } = string.Empty;
public Guid ReleaseId { get; set; }
public string ReleaseVersion { get; set; }
public DateTimeOffset InstalledAt { get; set; }
public string LocalReference { get; set; }
}
@@ -0,0 +1,54 @@
using System;
using System.Collections.Generic;
using Artemis.Storage.Entities.Workshop;
using Artemis.Storage.Repositories.Interfaces;
using LiteDB;
namespace Artemis.Storage.Repositories;
internal class EntryRepository : IEntryRepository
{
private readonly LiteRepository _repository;
public EntryRepository(LiteRepository repository)
{
_repository = repository;
_repository.Database.GetCollection<EntryEntity>().EnsureIndex(s => s.Id);
_repository.Database.GetCollection<EntryEntity>().EnsureIndex(s => s.EntryId);
}
public void Add(EntryEntity entryEntity)
{
_repository.Insert(entryEntity);
}
public void Remove(EntryEntity entryEntity)
{
_repository.Delete<EntryEntity>(entryEntity.Id);
}
public EntryEntity Get(Guid id)
{
return _repository.FirstOrDefault<EntryEntity>(s => s.Id == id);
}
public EntryEntity GetByEntryId(Guid entryId)
{
return _repository.FirstOrDefault<EntryEntity>(s => s.EntryId == entryId);
}
public List<EntryEntity> GetAll()
{
return _repository.Query<EntryEntity>().ToList();
}
public void Save(EntryEntity entryEntity)
{
_repository.Upsert(entryEntity);
}
public void Save(IEnumerable<EntryEntity> entryEntities)
{
_repository.Upsert(entryEntities);
}
}
@@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using Artemis.Storage.Entities.Workshop;
namespace Artemis.Storage.Repositories.Interfaces;
public interface IEntryRepository : IRepository
{
void Add(EntryEntity entryEntity);
void Remove(EntryEntity entryEntity);
EntryEntity Get(Guid id);
EntryEntity GetByEntryId(Guid entryId);
List<EntryEntity> GetAll();
void Save(EntryEntity entryEntity);
void Save(IEnumerable<EntryEntity> entryEntities);
}