Fixed dockerfiles and fixed chapter upserts
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2022-07-17 10:16:32 -04:00
parent d98324c11e
commit e4529e11c0
15 changed files with 659 additions and 12 deletions

View File

@@ -19,24 +19,27 @@ public class NovelRepository : BaseRepository<Novel>, INovelRepository
public override async Task<Novel> Upsert(Novel entity, bool saveAfter=true)
{
var dbEntity = await GetIncluded(entity) ?? entity;
// Author
if (entity.Author != null)
{
entity.Author = await _authorRepository.Upsert(entity.Author, saveAfter);
entity.Author = await _authorRepository.Upsert(entity.Author, false);
}
//Tags
var newTags = await _tagRepository.UpsertMany(entity.Tags, false);
entity.Tags.Clear();
entity.Tags = newTags.ToList();
//chapters
//chapters are getting deleted now that their required...
var newChapters = await _chapterRepository.UpsertMany(entity.Chapters, false);
entity.Chapters.Clear();
entity.Chapters = newChapters.ToList();
// update in db
var dbEntity = await GetIncluded(entity) ?? entity;
entity.Guid = dbEntity.Guid;
DbContext.Entry(dbEntity).CurrentValues.SetValues(entity);
dbEntity.Tags.Clear();
dbEntity.Tags.AddRange(newTags);
dbEntity.Chapters.Clear();
dbEntity.Chapters.AddRange(newChapters);
if (DbContext.Entry(dbEntity).State == EntityState.Detached)
{
dbEntity.Guid = Guid.NewGuid();