diff --git a/DA_Business/DA_Business.csproj b/DA_Business/DA_Business.csproj index 491cb1d..089008c 100644 --- a/DA_Business/DA_Business.csproj +++ b/DA_Business/DA_Business.csproj @@ -16,6 +16,11 @@ + + + + + diff --git a/DA_Business/Mapper/MappingProfile.cs b/DA_Business/Mapper/MappingProfile.cs index c57aa5e..eac68ec 100644 --- a/DA_Business/Mapper/MappingProfile.cs +++ b/DA_Business/Mapper/MappingProfile.cs @@ -1,5 +1,6 @@ using AutoMapper; using DA_DataAccess.CharacterClasses; +using DA_DataAccess.Chat; using DA_Models.CharacterModels; using System; using System.Collections.Generic; @@ -26,6 +27,10 @@ public MappingProfile() CreateMap().ReverseMap(); CreateMap().ReverseMap(); CreateMap().ReverseMap(); + CreateMap().ReverseMap(); + CreateMap().ReverseMap(); + CreateMap().ReverseMap(); + } } } diff --git a/DA_Business/Repository/CharacterReps/AttributeRepository.cs b/DA_Business/Repository/CharacterReps/AttributeRepository.cs index bca2c73..14cf155 100644 --- a/DA_Business/Repository/CharacterReps/AttributeRepository.cs +++ b/DA_Business/Repository/CharacterReps/AttributeRepository.cs @@ -3,6 +3,7 @@ using DA_DataAccess.CharacterClasses; using DA_DataAccess.Data; using DA_Models.CharacterModels; +using DagoniteEmpire.Exceptions; using Microsoft.EntityFrameworkCore; using Attribute = DA_DataAccess.CharacterClasses.Attribute; @@ -27,10 +28,7 @@ public async Task Create(AttributeDTO objDTO) { await _db.SaveChangesAsync(); } - catch (Exception ex) - { - ; - } + catch (Exception ex) { throw new RepositoryErrorException("Error in" + System.Reflection.MethodBase.GetCurrentMethod().Name); } return _mapper.Map(addedObj.Entity); } @@ -55,12 +53,9 @@ public async Task> GetAll(int? charId = null) if (obj != null && obj.Any()) return _mapper.Map, IEnumerable>(obj); } - catch(Exception ex) - { - ; - } - - + catch (Exception ex) { throw new RepositoryErrorException("Error in" + System.Reflection.MethodBase.GetCurrentMethod().Name); } + + return new List(); } diff --git a/DA_Business/Repository/CharacterReps/CharacterRepository.cs b/DA_Business/Repository/CharacterReps/CharacterRepository.cs index 0822a0e..9c834d9 100644 --- a/DA_Business/Repository/CharacterReps/CharacterRepository.cs +++ b/DA_Business/Repository/CharacterReps/CharacterRepository.cs @@ -64,10 +64,7 @@ public async Task Create(CharacterDTO objDTO) await contex.SaveChangesAsync(); return _mapper.Map(addedObj.Entity); } - catch (Exception ex) - { - throw new RepositoryErrorException("Error in Character Repository Create"); - } + catch (Exception ex) {throw new RepositoryErrorException("Error in"+ System.Reflection.MethodBase.GetCurrentMethod().Name); } } public async Task Delete(int id) @@ -114,10 +111,7 @@ public async Task Delete(int id) return contex.SaveChanges(); } - catch (Exception ex) - { - throw new RepositoryErrorException("Error in Character Repository Create"); - } + catch (Exception ex) { throw new RepositoryErrorException("Error in" + System.Reflection.MethodBase.GetCurrentMethod().Name); } } public async Task> GetAll(int? id=null) @@ -138,6 +132,17 @@ public async Task GetById(int id) } return new CharacterDTO(); } + public async Task GetByName(string npcName) + { + using var contex = await _db.CreateDbContextAsync(); + var obj = await contex.Characters.Include(t => t.TraitsAdv).ThenInclude(b => b.Bonuses).Include(r => r.Race).Include(r => r.Profession).Include(r => r.Equipment).FirstOrDefaultAsync(u => u.NPCName == npcName); + if (obj != null) + { + return _mapper.Map(obj); + } + return new CharacterDTO(); + } + public async Task> GetAllForUser(string userName) { using var contex = await _db.CreateDbContextAsync(); @@ -145,6 +150,22 @@ public async Task> GetAllForUser(string userName) return new List(); return _mapper.Map, IEnumerable>(contex.Characters.Include(r => r.Race).Include(r => r.Race).Include(r => r.Profession).Include(r=>r.Equipment).Where(u => u.UserName == userName)); } + public async Task> GetAllForCampaign(int campaignId) + { + //try + //{ + // using var contex = await _db.CreateDbContextAsync(); + // if (campaignId == null || campaignId == 0) + // return new List(); + // return _mapper.Map, IEnumerable>(contex.Characters.Include(r => r.Race).Include(r => r.Race).Include(r => r.Profession).Include(r => r.Equipment) + // .Where(u => u.Campaigns != null && u.Campaigns.FirstOrDefault(c => c.Id == campaignId) != null)); + //} + //catch (Exception ex) + //{ + // throw new RepositoryErrorException("Error in" + System.Reflection.MethodBase.GetCurrentMethod().Name); + //} + return null; + } public async Task Update(CharacterDTO objDTO) { @@ -161,6 +182,7 @@ public async Task Update(CharacterDTO objDTO) obj.Age = updatedChar.Age; obj.NPCName = updatedChar.NPCName; + obj.IsApproved = updatedChar.IsApproved; obj.Description = updatedChar.Description; obj.CurrentExpPoints = updatedChar.CurrentExpPoints; obj.UsedExpPoints = updatedChar.UsedExpPoints; @@ -464,10 +486,7 @@ public async Task Update(CharacterDTO objDTO) }else return objDTO; } - catch (Exception ex) - { - throw new RepositoryErrorException("Error in Character Repository Update"); - } + catch (Exception ex) { throw new RepositoryErrorException("Error in" + System.Reflection.MethodBase.GetCurrentMethod().Name); } } } diff --git a/DA_Business/Repository/CharacterReps/IRepository/ICharacterRepository.cs b/DA_Business/Repository/CharacterReps/IRepository/ICharacterRepository.cs index 6f5d60a..22e80d5 100644 --- a/DA_Business/Repository/CharacterReps/IRepository/ICharacterRepository.cs +++ b/DA_Business/Repository/CharacterReps/IRepository/ICharacterRepository.cs @@ -15,7 +15,10 @@ public interface ICharacterRepository public Task Delete(int id); public Task GetById(int id); + public Task GetByName(string npcName); public Task> GetAll(int? id=null); public Task> GetAllForUser(string userName); + + public Task> GetAllForCampaign(int campaignId); } } diff --git a/DA_Business/Repository/ChatRepos/CampaignRepository.cs b/DA_Business/Repository/ChatRepos/CampaignRepository.cs new file mode 100644 index 0000000..fe6f96f --- /dev/null +++ b/DA_Business/Repository/ChatRepos/CampaignRepository.cs @@ -0,0 +1,139 @@ +using AutoMapper; +using DA_Business.Repository.CharacterReps.IRepository; +using DA_DataAccess.CharacterClasses; +using DA_DataAccess.Chat; +using DA_DataAccess.Data; +using DA_Models.CharacterModels; +using DagoniteEmpire.Exceptions; +using Microsoft.EntityFrameworkCore; + +namespace DA_Business.Repository.ChatRepos +{ + public class CampaignRepository : ICampaignRepository + { + //private readonly ApplicationDbContext _db; + private readonly IDbContextFactory _db; + private readonly IMapper _mapper; + + public CampaignRepository(IDbContextFactory db, IMapper mapper) + { + _db = db; + _mapper = mapper; + } + + public async Task Create(CampaignDTO objDTO) + { + try + { + using var contex = await _db.CreateDbContextAsync(); + var obj = _mapper.Map(objDTO); + + foreach(var cha in obj.Characters) + { + cha.Profession = null; + cha.Race = null; + } + + var characterts = await contex.Characters.ToListAsync(); + characterts.ForEach(t => + { + if (obj.Characters.Any(nt => nt.Id == t.Id)) + { + var untracked = obj.Characters.FirstOrDefault(nt => nt.Id == t.Id); + obj.Characters.Remove(untracked); + obj.Characters.Add(t); + } + }); + + var addedObj = await contex.Campaigns.AddAsync(obj); + await contex.SaveChangesAsync(); + return _mapper.Map(addedObj.Entity); + } + catch (Exception ex) { + throw new RepositoryErrorException("Error in" + System.Reflection.MethodBase.GetCurrentMethod().Name); + } + + } + + public async Task Delete(int id) + { + try + { + + using var contex = await _db.CreateDbContextAsync(); + var obj = await contex.Campaigns.FirstOrDefaultAsync(u => u.Id == id); + if (obj != null) + { + contex.Campaigns.Remove(obj); + return await contex.SaveChangesAsync(); + } + } + catch (Exception ex) { + throw new RepositoryErrorException("Error in" + System.Reflection.MethodBase.GetCurrentMethod().Name); + } + return 0; + } + + public async Task> GetAll(int? characterId = null) + { + try + { + + using var contex = await _db.CreateDbContextAsync(); + if (characterId==null) + return _mapper.Map, IEnumerable>(contex.Campaigns.Include(a => a.Characters)); + + var obj = contex.Campaigns.Include(a=>a.Characters).Where(u => u.Characters.FirstOrDefault(a=>a.Id==characterId)!=null).OrderBy(u => u.CreatedDate); + if (obj != null && obj.Any()) + return _mapper.Map, IEnumerable>(obj); + else + return new List(); + + + } + catch (Exception ex) { + throw new RepositoryErrorException("Error in" + System.Reflection.MethodBase.GetCurrentMethod().Name); + } + } + + public async Task GetById(int id) + { + try + { + using var contex = await _db.CreateDbContextAsync(); + var obj = await contex.Campaigns.Include(a => a.Characters).FirstOrDefaultAsync(u => u.Id == id); + if (obj != null) + { + return _mapper.Map(obj); + } + } + catch (Exception ex) { + throw new RepositoryErrorException("Error in" + System.Reflection.MethodBase.GetCurrentMethod().Name); + } + return new CampaignDTO(); + } + + public async Task Update(CampaignDTO objDTO) + { + try + { + using var contex = await _db.CreateDbContextAsync(); + var obj = await contex.Campaigns.FirstOrDefaultAsync(u => u.Id == objDTO.Id); + if (obj != null) + { + obj.IsFinished = objDTO.IsFinished; + obj.Description = objDTO.Description; + obj.Name = objDTO.Name; + + contex.Campaigns.Update(obj); + await contex.SaveChangesAsync(); + return _mapper.Map(obj); + } + } + catch (Exception ex) { + throw new RepositoryErrorException("Error in" + System.Reflection.MethodBase.GetCurrentMethod().Name); + } + return objDTO; + } + } +} diff --git a/DA_Business/Repository/ChatRepos/ChapterRepository.cs b/DA_Business/Repository/ChatRepos/ChapterRepository.cs new file mode 100644 index 0000000..1c802c0 --- /dev/null +++ b/DA_Business/Repository/ChatRepos/ChapterRepository.cs @@ -0,0 +1,149 @@ +using AutoMapper; +using DA_Business.Repository.CharacterReps.IRepository; +using DA_DataAccess.CharacterClasses; +using DA_DataAccess.Chat; +using DA_DataAccess.Data; +using DA_Models.CharacterModels; +using DagoniteEmpire.Exceptions; +using Microsoft.EntityFrameworkCore; +using System.Diagnostics.Metrics; +using System.Net.NetworkInformation; + +namespace DA_Business.Repository.ChatRepos +{ + public class ChapterRepository : IChapterRepository + { + private readonly IDbContextFactory _db; + private readonly IMapper _mapper; + + public ChapterRepository(IDbContextFactory db, IMapper mapper) + { + _db = db; + _mapper = mapper; + } + + + public async Task Create(ChapterDTO objDTO) + { + try + { + using var contex = await _db.CreateDbContextAsync(); + var obj = _mapper.Map(objDTO); + + foreach (var cha in obj.Characters) + { + cha.Profession = null; + cha.Race = null; + } + + var characterts = await contex.Characters.ToListAsync(); + characterts.ForEach(t => + { + if (obj.Characters.Any(nt => nt.Id == t.Id)) + { + var untracked = obj.Characters.FirstOrDefault(nt => nt.Id == t.Id); + obj.Characters.Remove(untracked); + obj.Characters.Add(t); + } + }); + var posts = await contex.Posts.ToListAsync(); + posts.ForEach(t => + { + if (obj.Posts.Any(nt => nt.Id == t.Id)) + { + var untracked = obj.Posts.FirstOrDefault(nt => nt.Id == t.Id); + obj.Posts.Remove(untracked); + obj.Posts.Add(t); + } + }); + + var addedObj = await contex.Chapters.AddAsync(obj); + await contex.SaveChangesAsync(); + return _mapper.Map(addedObj.Entity); + } + catch (Exception ex) + { + throw new RepositoryErrorException("Error in" + System.Reflection.MethodBase.GetCurrentMethod().Name); + } + + } + + public async Task Delete(int id) + { + try + { + using var contex = await _db.CreateDbContextAsync(); + var obj = await contex.Chapters.Include(a => a.Posts).FirstOrDefaultAsync(u => u.Id == id); + if (obj != null) + { + if (obj.Posts != null && obj.Posts.Any()) + { + foreach(var post in obj.Posts) + { + contex.Posts.Remove(post); + } + } + contex.Chapters.Remove(obj); + return contex.SaveChanges(); + } + } + catch (Exception ex) { throw new RepositoryErrorException("Error in" + System.Reflection.MethodBase.GetCurrentMethod().Name);} + return 0; + } + + public async Task> GetAll(int? campaignId = null) + { + try + { + using var contex = await _db.CreateDbContextAsync(); + if (campaignId == null || campaignId < 1) + return _mapper.Map, IEnumerable>(contex.Chapters.Include(a => a.Characters).Include(a=>a.Posts)); + + var obj = contex.Chapters.Include(a => a.Characters).Include(a => a.Posts).Where(u => u.CampaignId == campaignId).OrderBy(u => u.CreatedDate); + if (obj != null && obj.Any()) + return _mapper.Map, IEnumerable>(obj); + } + catch (Exception ex) { throw new RepositoryErrorException("Error in" + System.Reflection.MethodBase.GetCurrentMethod().Name); } + + return new List(); + } + + public async Task GetById(int id) + { + try + { + using var contex = await _db.CreateDbContextAsync(); + var obj = await contex.Chapters.Include(a => a.Characters).Include(a => a.Posts).FirstOrDefaultAsync(u => u.Id == id); + if (obj != null) + { + return _mapper.Map(obj); + } + } + catch (Exception ex) { throw new RepositoryErrorException("Error in" + System.Reflection.MethodBase.GetCurrentMethod().Name); } + return new ChapterDTO(); + } + + public async Task Update(ChapterDTO objDTO) + { + try + { + using var contex = await _db.CreateDbContextAsync(); + var obj = await contex.Chapters.FirstOrDefaultAsync(u => u.Id == objDTO.Id); + if (obj != null) + { + obj.Day = objDTO.Day; + obj.Place = objDTO.Day; + obj.IsFinished = objDTO.IsFinished; + obj.Description = objDTO.Description; + obj.Name = objDTO.Name; + + contex.Chapters.Update(obj); + await contex.SaveChangesAsync(); + return _mapper.Map(obj); + } + } + catch (Exception ex) { throw new RepositoryErrorException("Error in" + System.Reflection.MethodBase.GetCurrentMethod().Name); } + return objDTO; + } + } +} diff --git a/DA_Business/Repository/ChatRepos/IRepository/ICampaignRepository.cs b/DA_Business/Repository/ChatRepos/IRepository/ICampaignRepository.cs new file mode 100644 index 0000000..c08c738 --- /dev/null +++ b/DA_Business/Repository/ChatRepos/IRepository/ICampaignRepository.cs @@ -0,0 +1,23 @@ +using DA_DataAccess.Chat; +using DA_DataAccess; +using DA_Models.CharacterModels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DA_Business.Repository.CharacterReps.IRepository +{ + public interface ICampaignRepository + { + Task Create(CampaignDTO objDTO); + + Task Delete(int id); + Task> GetAll(int? characterId=null); + + Task GetById(int id); + + Task Update(CampaignDTO objDTO); + } +} diff --git a/DA_Business/Repository/ChatRepos/IRepository/IChapterRepository.cs b/DA_Business/Repository/ChatRepos/IRepository/IChapterRepository.cs new file mode 100644 index 0000000..8437ff1 --- /dev/null +++ b/DA_Business/Repository/ChatRepos/IRepository/IChapterRepository.cs @@ -0,0 +1,23 @@ +using DA_DataAccess.Chat; +using DA_DataAccess; +using DA_Models.CharacterModels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DA_Business.Repository.CharacterReps.IRepository +{ + public interface IChapterRepository + { + Task Create(ChapterDTO objDTO); + + Task Delete(int id); + Task> GetAll(int? campaignId = null); + + Task GetById(int id); + + Task Update(ChapterDTO objDTO); + } +} diff --git a/DA_Business/Repository/ChatRepos/IRepository/IPostRepository.cs b/DA_Business/Repository/ChatRepos/IRepository/IPostRepository.cs new file mode 100644 index 0000000..859c625 --- /dev/null +++ b/DA_Business/Repository/ChatRepos/IRepository/IPostRepository.cs @@ -0,0 +1,23 @@ +using DA_DataAccess.Chat; +using DA_DataAccess; +using DA_Models.CharacterModels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DA_Business.Repository.CharacterReps.IRepository +{ + public interface IPostRepository + { + Task Create(PostDTO objDTO); + + Task Delete(int id); + Task> GetAll(int? chapterId = null); + + Task GetById(int id); + + Task Update(PostDTO objDTO); + } +} diff --git a/DA_Business/Repository/ChatRepos/PostRepository.cs b/DA_Business/Repository/ChatRepos/PostRepository.cs new file mode 100644 index 0000000..0ee65b8 --- /dev/null +++ b/DA_Business/Repository/ChatRepos/PostRepository.cs @@ -0,0 +1,115 @@ +using AutoMapper; +using DA_Business.Repository.CharacterReps.IRepository; +using DA_DataAccess.CharacterClasses; +using DA_DataAccess.Chat; +using DA_DataAccess.Data; +using DA_Models.CharacterModels; +using DagoniteEmpire.Exceptions; +using Microsoft.EntityFrameworkCore; +using System.Diagnostics.Metrics; + +namespace DA_Business.Repository.ChatRepos +{ + public class PostRepository : IPostRepository + { + private readonly IDbContextFactory _db; + private readonly IMapper _mapper; + + public PostRepository(IDbContextFactory db, IMapper mapper) + { + _db = db; + _mapper = mapper; + } + + public async Task Create(PostDTO objDTO) + { + + try + { + using var contex = await _db.CreateDbContextAsync(); + var obj = _mapper.Map(objDTO); + obj.Character = null; + obj.Chapter = null; + var addedObj = contex.Posts.Add(obj); + + await contex.SaveChangesAsync(); + return _mapper.Map(addedObj.Entity); + } + catch (Exception ex) { + throw new RepositoryErrorException("Error in" + System.Reflection.MethodBase.GetCurrentMethod().Name); + } + + } + + public async Task Delete(int id) + { + try + { + using var contex = await _db.CreateDbContextAsync(); + var obj = await contex.Posts.FirstOrDefaultAsync(u => u.Id == id); + if (obj != null) + { + contex.Posts.Remove(obj); + return contex.SaveChanges(); + } + } + catch (Exception ex) { throw new RepositoryErrorException("Error in" + System.Reflection.MethodBase.GetCurrentMethod().Name);} + return 0; + } + + public async Task> GetAll(int? chapterId = null) + { + try + { + using var contex = await _db.CreateDbContextAsync(); + if (chapterId == null || chapterId < 1) + return _mapper.Map, IEnumerable>(contex.Posts.Include(u => u.Character)); + + + var obj = contex.Posts.Include(u=>u.Character).Where(u => u.ChapterId == chapterId).OrderBy(u => u.CreatedDate); + if (obj != null && obj.Any()) + return _mapper.Map, IEnumerable>(obj); + } + catch (Exception ex) { + throw new RepositoryErrorException("Error in" + System.Reflection.MethodBase.GetCurrentMethod().Name); + } + + return new List(); + } + + public async Task GetById(int id) + { + try + { + using var contex = await _db.CreateDbContextAsync(); + var obj = await contex.Posts.Include(u => u.Character).FirstOrDefaultAsync(u => u.Id == id); + if (obj != null) + { + return _mapper.Map(obj); + } + } + catch (Exception ex) { throw new RepositoryErrorException("Error in" + System.Reflection.MethodBase.GetCurrentMethod().Name); } + return new PostDTO(); + } + + public async Task Update(PostDTO objDTO) + { + try + { + using var contex = await _db.CreateDbContextAsync(); + var obj = await contex.Posts.FirstOrDefaultAsync(u => u.Id == objDTO.Id); + if (obj != null) + { + obj.Content = objDTO.Content; + obj.CreatedDate = objDTO.CreatedDate; + + contex.Posts.Update(obj); + await contex.SaveChangesAsync(); + return _mapper.Map(obj); + } + } + catch (Exception ex) { throw new RepositoryErrorException("Error in" + System.Reflection.MethodBase.GetCurrentMethod().Name); } + return objDTO; + } + } +} diff --git a/DA_Common/SD.cs b/DA_Common/SD.cs index 867aead..a14b8e1 100644 --- a/DA_Common/SD.cs +++ b/DA_Common/SD.cs @@ -1,6 +1,7 @@ using Syncfusion.Blazor.RichTextEditor; using System; using System.Collections.Generic; +using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; @@ -33,6 +34,13 @@ public static class SD public const string Willpower = "Willpower"; public const string Charisma = "Charisma"; + + } + public static class MyIcon + { + public const string Bookmark = "icons/bookmarklet.svg"; + public const string Scroll = "icons/scroll.svg"; + public const string Quill = "icons/quill.svg"; } diff --git a/DA_DataAccess/CharacterClasses/Character.cs b/DA_DataAccess/CharacterClasses/Character.cs index 9f09805..9f83dd4 100644 --- a/DA_DataAccess/CharacterClasses/Character.cs +++ b/DA_DataAccess/CharacterClasses/Character.cs @@ -1,4 +1,5 @@ -using System; +using DA_DataAccess.Chat; +using System; using System.Collections; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; @@ -35,15 +36,21 @@ public class Character public ICollection? Equipment { get; set; } + public ICollection? Campaigns { get; set; } + + public ICollection? Posts { get; set; } + public ICollection? Chapters { get; set; } + public int? RaceId { get; set; } [ForeignKey(nameof(RaceId))] - public Race? Race { get; set; } + public Race? Race { get; set; } = null; + public bool IsApproved { get; set; } public int ProfessionId { get; set; } = 0; [ForeignKey(nameof(ProfessionId))] - public Profession? Profession { get; set; } + public Profession? Profession { get; set; } = null; } } diff --git a/DA_DataAccess/CharacterClasses/Profession.cs b/DA_DataAccess/CharacterClasses/Profession.cs index e7485e2..33f7096 100644 --- a/DA_DataAccess/CharacterClasses/Profession.cs +++ b/DA_DataAccess/CharacterClasses/Profession.cs @@ -14,14 +14,14 @@ public class Profession public int Id { get; set; } public string Name { get; set; } - public string Description { get; set; } - public string RelatedAttribute { get; set; } - public int ClassLevel { get; set; } - public int MaxFocusPoints { get; set; } - public int CurrentCofusPoints { get; set; } - public bool IsApproved { get; set; } + public string Description { get; set; } = string.Empty; + public string RelatedAttribute { get; set; } = string.Empty; + public int ClassLevel { get; set; } = 1; + public int MaxFocusPoints { get; set; } = 0; + public int CurrentCofusPoints { get; set; } = 0; + public bool IsApproved { get; set; } = false; - public bool IsUniversal { get; set; } + public bool IsUniversal { get; set; } = false; public ICollection? Characters { get; set; } diff --git a/DA_DataAccess/CharacterClasses/Race.cs b/DA_DataAccess/CharacterClasses/Race.cs index 3d225e7..a6dbddd 100644 --- a/DA_DataAccess/CharacterClasses/Race.cs +++ b/DA_DataAccess/CharacterClasses/Race.cs @@ -16,11 +16,11 @@ public class Race public ICollection? Characters { get; set; } - public string Name { get; set; } //for example "dwarf" - public int Index { get; set; } + public string Name { get; set; } //for example "dwarf" + public int Index { get; set; } = 0; - public string Description { get; set; } // descritpion of race - public bool RaceApproved { get; set; } // race have to be approved by Game Master + public string Description { get; set; } = string.Empty; // descritpion of race + public bool RaceApproved { get; set; } = false; // race have to be approved by Game Master } } diff --git a/DA_DataAccess/Chat/Campaign.cs b/DA_DataAccess/Chat/Campaign.cs new file mode 100644 index 0000000..d6c94ce --- /dev/null +++ b/DA_DataAccess/Chat/Campaign.cs @@ -0,0 +1,22 @@ +using DA_DataAccess.CharacterClasses; +using MudBlazor.Charts; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DA_DataAccess.Chat +{ + public class Campaign + { + public int Id { get; set; } + public string Name { get; set; } + public string Description { get; set; } + public ICollection Chapters { get; set; } + public DateTime CreatedDate { get; set; } + public ICollection Characters { get; set; } + public string GameMaster { get; set; } + public bool IsFinished { get; set; } + } +} diff --git a/DA_DataAccess/Chat/Chapter.cs b/DA_DataAccess/Chat/Chapter.cs new file mode 100644 index 0000000..8da096f --- /dev/null +++ b/DA_DataAccess/Chat/Chapter.cs @@ -0,0 +1,28 @@ +using DA_DataAccess.CharacterClasses; +using MudBlazor.Charts; +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations.Schema; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DA_DataAccess.Chat +{ + public class Chapter + { + public int Id { get; set; } + public string Name { get; set; } + public string Description { get; set; } + public string Day { get; set; } + public string Place { get; set; } + public ICollection Posts { get; set; } + public DateTime CreatedDate { get; set; } + public ICollection Characters { get; set; } + public bool IsFinished { get; set; } + + [ForeignKey(nameof(Campaign))] + public int CampaignId { get; set; } + public virtual Campaign Campaign { get; set; } + } +} diff --git a/DA_DataAccess/Chat/ChatMessage.cs b/DA_DataAccess/Chat/ChatMessage.cs index 87061c2..83f84e9 100644 --- a/DA_DataAccess/Chat/ChatMessage.cs +++ b/DA_DataAccess/Chat/ChatMessage.cs @@ -16,7 +16,7 @@ public class ChatMessage public DateTime CreatedDate { get; set; } public virtual ApplicationUser FromUser { get; set; } public virtual ApplicationUser ToUser { get; set; } - public bool IsNotice => Message.StartsWith("[Notice]"); + //public bool IsNotice => Message.StartsWith("[Notice]"); public bool IsRead { get; set; } = false; } diff --git a/DA_DataAccess/Chat/Post.cs b/DA_DataAccess/Chat/Post.cs new file mode 100644 index 0000000..dcbb7eb --- /dev/null +++ b/DA_DataAccess/Chat/Post.cs @@ -0,0 +1,26 @@ +using DA_DataAccess.CharacterClasses; +using MudBlazor.Charts; +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations.Schema; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DA_DataAccess.Chat +{ + public class Post + { + public int Id { get; set; } + public string Content { get; set; } + public DateTime CreatedDate { get; set; } + + [ForeignKey(nameof(Character))] + public int CharacterId { get; set; } + public Character? Character { get; set; } + + [ForeignKey(nameof(Chapter))] + public int ChapterId { get; set; } + public virtual Chapter? Chapter { get; set; } + } +} diff --git a/DA_DataAccess/Data/ApplicationDbContext.cs b/DA_DataAccess/Data/ApplicationDbContext.cs index 05f40a3..2a004e5 100644 --- a/DA_DataAccess/Data/ApplicationDbContext.cs +++ b/DA_DataAccess/Data/ApplicationDbContext.cs @@ -32,6 +32,9 @@ public ApplicationDbContext(DbContextOptions options) : ba public DbSet ProfessionSkills { get; set; } public DbSet ChatMessages { get; set; } + public DbSet Posts { get; set; } + public DbSet Chapters { get; set; } + public DbSet Campaigns { get; set; } protected override void OnModelCreating(ModelBuilder modelBuilder) { @@ -57,6 +60,8 @@ protected override void OnModelCreating(ModelBuilder modelBuilder) .WithMany(p => p.ChatMessagesToUsers) .HasForeignKey(d => d.ToUserId) .OnDelete(DeleteBehavior.ClientSetNull); + + } } } diff --git a/DA_DataAccess/Migrations/20240517125003_addchatnotification.Designer.cs b/DA_DataAccess/Migrations/20240517125003_addchatnotification.Designer.cs deleted file mode 100644 index 7d02875..0000000 --- a/DA_DataAccess/Migrations/20240517125003_addchatnotification.Designer.cs +++ /dev/null @@ -1,1085 +0,0 @@ -// -using System; -using DA_DataAccess.Data; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; - -#nullable disable - -namespace DA_DataAccess.Migrations -{ - [DbContext(typeof(ApplicationDbContext))] - [Migration("20240517125003_addchatnotification")] - partial class addchatnotification - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "7.0.15") - .HasAnnotation("Relational:MaxIdentifierLength", 63); - - NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); - - modelBuilder.Entity("CharacterEquipment", b => - { - b.Property("CharactersId") - .HasColumnType("integer"); - - b.Property("EquipmentId") - .HasColumnType("integer"); - - b.HasKey("CharactersId", "EquipmentId"); - - b.HasIndex("EquipmentId"); - - b.ToTable("CharacterEquipment"); - }); - - modelBuilder.Entity("CharacterTraitAdv", b => - { - b.Property("CharactersId") - .HasColumnType("integer"); - - b.Property("TraitsAdvId") - .HasColumnType("integer"); - - b.HasKey("CharactersId", "TraitsAdvId"); - - b.HasIndex("TraitsAdvId"); - - b.ToTable("CharacterTraitAdv"); - }); - - modelBuilder.Entity("DA_DataAccess.CharacterClasses.Attribute", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("BaseBonus") - .HasColumnType("integer"); - - b.Property("CharacterId") - .HasColumnType("integer"); - - b.Property("FeatureType") - .HasColumnType("text"); - - b.Property("GearBonus") - .HasColumnType("integer"); - - b.Property("HealthBonus") - .HasColumnType("integer"); - - b.Property("Index") - .HasColumnType("integer"); - - b.Property("Name") - .HasColumnType("text"); - - b.Property("OtherBonuses") - .HasColumnType("integer"); - - b.Property("RaceBonus") - .HasColumnType("integer"); - - b.Property("TempBonuses") - .HasColumnType("integer"); - - b.Property("TraitBonus") - .HasColumnType("integer"); - - b.HasKey("Id"); - - b.HasIndex("CharacterId"); - - b.ToTable("Attributes"); - }); - - modelBuilder.Entity("DA_DataAccess.CharacterClasses.BaseSkill", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("BaseBonus") - .HasColumnType("integer"); - - b.Property("CharacterId") - .HasColumnType("integer"); - - b.Property("FeatureType") - .HasColumnType("text"); - - b.Property("GearBonus") - .HasColumnType("integer"); - - b.Property("HealthBonus") - .HasColumnType("integer"); - - b.Property("Index") - .HasColumnType("integer"); - - b.Property("Name") - .HasColumnType("text"); - - b.Property("OtherBonuses") - .HasColumnType("integer"); - - b.Property("RaceBonus") - .HasColumnType("integer"); - - b.Property("RelatedAttribute1") - .IsRequired() - .HasColumnType("text"); - - b.Property("RelatedAttribute2") - .IsRequired() - .HasColumnType("text"); - - b.Property("TempBonuses") - .HasColumnType("integer"); - - b.Property("TraitBonus") - .HasColumnType("integer"); - - b.HasKey("Id"); - - b.HasIndex("CharacterId"); - - b.ToTable("BaseSkills"); - }); - - modelBuilder.Entity("DA_DataAccess.CharacterClasses.Bonus", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("BonusValue") - .HasColumnType("integer"); - - b.Property("Description") - .HasColumnType("text"); - - b.Property("FeatureName") - .HasColumnType("text"); - - b.Property("FeatureType") - .IsRequired() - .HasColumnType("text"); - - b.Property("Index") - .HasColumnType("integer"); - - b.Property("TraitId") - .HasColumnType("integer"); - - b.HasKey("Id"); - - b.HasIndex("TraitId"); - - b.ToTable("Bonuses"); - }); - - modelBuilder.Entity("DA_DataAccess.CharacterClasses.Character", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Age") - .HasColumnType("integer"); - - b.Property("AttributePoints") - .HasColumnType("integer"); - - b.Property("CurrentExpPoints") - .HasColumnType("integer"); - - b.Property("Description") - .HasColumnType("text"); - - b.Property("ImageUrl") - .HasColumnType("text"); - - b.Property("NPCName") - .HasColumnType("text"); - - b.Property("NPCType") - .HasColumnType("text"); - - b.Property("ProfessionId") - .HasColumnType("integer"); - - b.Property("RaceId") - .HasColumnType("integer"); - - b.Property("TraitBalance") - .HasColumnType("integer"); - - b.Property("UsedExpPoints") - .HasColumnType("integer"); - - b.Property("UserName") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id"); - - b.HasIndex("ProfessionId"); - - b.HasIndex("RaceId"); - - b.ToTable("Characters"); - }); - - modelBuilder.Entity("DA_DataAccess.CharacterClasses.Equipment", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Count") - .HasColumnType("integer"); - - b.Property("Description") - .IsRequired() - .HasColumnType("text"); - - b.Property("Index") - .HasColumnType("integer"); - - b.Property("IsApproved") - .HasColumnType("boolean"); - - b.Property("Name") - .IsRequired() - .HasColumnType("text"); - - b.Property("Price") - .HasColumnType("numeric"); - - b.Property("ShortDescr") - .IsRequired() - .HasColumnType("text"); - - b.Property("Weight") - .HasColumnType("numeric"); - - b.HasKey("Id"); - - b.ToTable("Equipment"); - }); - - modelBuilder.Entity("DA_DataAccess.CharacterClasses.Profession", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("ClassLevel") - .HasColumnType("integer"); - - b.Property("CurrentCofusPoints") - .HasColumnType("integer"); - - b.Property("Description") - .IsRequired() - .HasColumnType("text"); - - b.Property("IsApproved") - .HasColumnType("boolean"); - - b.Property("IsUniversal") - .HasColumnType("boolean"); - - b.Property("MaxFocusPoints") - .HasColumnType("integer"); - - b.Property("Name") - .IsRequired() - .HasColumnType("text"); - - b.Property("RelatedAttribute") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id"); - - b.ToTable("Professions"); - }); - - modelBuilder.Entity("DA_DataAccess.CharacterClasses.ProfessionSkill", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("ActiveProfessionId") - .HasColumnType("integer"); - - b.Property("Cost") - .HasColumnType("integer"); - - b.Property("DC") - .HasColumnType("integer"); - - b.Property("Description") - .HasColumnType("text"); - - b.Property("Index") - .HasColumnType("bigint"); - - b.Property("IsApproved") - .HasColumnType("boolean"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("Name") - .HasColumnType("text"); - - b.Property("PassiveProfessionId") - .HasColumnType("integer"); - - b.Property("Range") - .HasColumnType("text"); - - b.HasKey("Id"); - - b.HasIndex("ActiveProfessionId"); - - b.HasIndex("PassiveProfessionId"); - - b.ToTable("ProfessionSkills"); - }); - - modelBuilder.Entity("DA_DataAccess.CharacterClasses.Race", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Description") - .IsRequired() - .HasColumnType("text"); - - b.Property("Index") - .HasColumnType("integer"); - - b.Property("Name") - .IsRequired() - .HasColumnType("text"); - - b.Property("RaceApproved") - .HasColumnType("boolean"); - - b.HasKey("Id"); - - b.ToTable("Races"); - }); - - modelBuilder.Entity("DA_DataAccess.CharacterClasses.SpecialSkill", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("BaseBonus") - .HasColumnType("integer"); - - b.Property("CharacterId") - .HasColumnType("integer"); - - b.Property("ChosenAttribute") - .HasColumnType("text"); - - b.Property("Editable") - .HasColumnType("boolean"); - - b.Property("FeatureType") - .HasColumnType("text"); - - b.Property("GearBonus") - .HasColumnType("integer"); - - b.Property("HealthBonus") - .HasColumnType("integer"); - - b.Property("Index") - .HasColumnType("integer"); - - b.Property("Name") - .HasColumnType("text"); - - b.Property("OtherBonuses") - .HasColumnType("integer"); - - b.Property("RaceBonus") - .HasColumnType("integer"); - - b.Property("RelatedAttribute1") - .IsRequired() - .HasColumnType("text"); - - b.Property("RelatedAttribute2") - .IsRequired() - .HasColumnType("text"); - - b.Property("RelatedBaseSkillName") - .HasColumnType("text"); - - b.Property("TempBonuses") - .HasColumnType("integer"); - - b.Property("TraitBonus") - .HasColumnType("integer"); - - b.HasKey("Id"); - - b.HasIndex("CharacterId"); - - b.ToTable("SpecialSkills"); - }); - - modelBuilder.Entity("DA_DataAccess.CharacterClasses.Trait", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Descr") - .IsRequired() - .HasColumnType("text"); - - b.Property("Discriminator") - .IsRequired() - .HasColumnType("text"); - - b.Property("Index") - .HasColumnType("integer"); - - b.Property("IsUnique") - .HasColumnType("boolean"); - - b.Property("Name") - .HasColumnType("text"); - - b.Property("SummaryDescr") - .IsRequired() - .HasColumnType("text"); - - b.Property("TraitApproved") - .HasColumnType("boolean"); - - b.Property("TraitType") - .IsRequired() - .HasColumnType("text"); - - b.Property("TraitValue") - .HasColumnType("integer"); - - b.HasKey("Id"); - - b.ToTable("Traits"); - - b.HasDiscriminator("Discriminator").HasValue("Trait"); - - b.UseTphMappingStrategy(); - }); - - modelBuilder.Entity("DA_DataAccess.Chat.ChatMessage", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("CreatedDate") - .HasColumnType("timestamp without time zone"); - - b.Property("FromUserId") - .IsRequired() - .HasColumnType("text"); - - b.Property("Message") - .IsRequired() - .HasColumnType("text"); - - b.Property("ToUserId") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id"); - - b.HasIndex("FromUserId"); - - b.HasIndex("ToUserId"); - - b.ToTable("ChatMessages"); - }); - - modelBuilder.Entity("DA_DataAccess.ImageFile", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("ImageName") - .IsRequired() - .HasColumnType("text"); - - b.Property("fileData") - .IsRequired() - .HasColumnType("bytea"); - - b.HasKey("Id"); - - b.ToTable("ImageFiles"); - }); - - modelBuilder.Entity("EquipmentTraitEquipment", b => - { - b.Property("EquipmentId") - .HasColumnType("integer"); - - b.Property("TraitsId") - .HasColumnType("integer"); - - b.HasKey("EquipmentId", "TraitsId"); - - b.HasIndex("TraitsId"); - - b.ToTable("EquipmentTraitEquipment"); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRole", b => - { - b.Property("Id") - .HasColumnType("text"); - - b.Property("ConcurrencyStamp") - .IsConcurrencyToken() - .HasColumnType("text"); - - b.Property("Name") - .HasMaxLength(256) - .HasColumnType("character varying(256)"); - - b.Property("NormalizedName") - .HasMaxLength(256) - .HasColumnType("character varying(256)"); - - b.HasKey("Id"); - - b.HasIndex("NormalizedName") - .IsUnique() - .HasDatabaseName("RoleNameIndex"); - - b.ToTable("AspNetRoles", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("ClaimType") - .HasColumnType("text"); - - b.Property("ClaimValue") - .HasColumnType("text"); - - b.Property("RoleId") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id"); - - b.HasIndex("RoleId"); - - b.ToTable("AspNetRoleClaims", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUser", b => - { - b.Property("Id") - .HasColumnType("text"); - - b.Property("AccessFailedCount") - .HasColumnType("integer"); - - b.Property("ConcurrencyStamp") - .IsConcurrencyToken() - .HasColumnType("text"); - - b.Property("Discriminator") - .IsRequired() - .HasColumnType("text"); - - b.Property("Email") - .HasMaxLength(256) - .HasColumnType("character varying(256)"); - - b.Property("EmailConfirmed") - .HasColumnType("boolean"); - - b.Property("LockoutEnabled") - .HasColumnType("boolean"); - - b.Property("LockoutEnd") - .HasColumnType("timestamp with time zone"); - - b.Property("NormalizedEmail") - .HasMaxLength(256) - .HasColumnType("character varying(256)"); - - b.Property("NormalizedUserName") - .HasMaxLength(256) - .HasColumnType("character varying(256)"); - - b.Property("PasswordHash") - .HasColumnType("text"); - - b.Property("PhoneNumber") - .HasColumnType("text"); - - b.Property("PhoneNumberConfirmed") - .HasColumnType("boolean"); - - b.Property("SecurityStamp") - .HasColumnType("text"); - - b.Property("TwoFactorEnabled") - .HasColumnType("boolean"); - - b.Property("UserName") - .HasMaxLength(256) - .HasColumnType("character varying(256)"); - - b.HasKey("Id"); - - b.HasIndex("NormalizedEmail") - .HasDatabaseName("EmailIndex"); - - b.HasIndex("NormalizedUserName") - .IsUnique() - .HasDatabaseName("UserNameIndex"); - - b.ToTable("AspNetUsers", (string)null); - - b.HasDiscriminator("Discriminator").HasValue("IdentityUser"); - - b.UseTphMappingStrategy(); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("ClaimType") - .HasColumnType("text"); - - b.Property("ClaimValue") - .HasColumnType("text"); - - b.Property("UserId") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id"); - - b.HasIndex("UserId"); - - b.ToTable("AspNetUserClaims", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => - { - b.Property("LoginProvider") - .HasColumnType("text"); - - b.Property("ProviderKey") - .HasColumnType("text"); - - b.Property("ProviderDisplayName") - .HasColumnType("text"); - - b.Property("UserId") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("LoginProvider", "ProviderKey"); - - b.HasIndex("UserId"); - - b.ToTable("AspNetUserLogins", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => - { - b.Property("UserId") - .HasColumnType("text"); - - b.Property("RoleId") - .HasColumnType("text"); - - b.HasKey("UserId", "RoleId"); - - b.HasIndex("RoleId"); - - b.ToTable("AspNetUserRoles", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => - { - b.Property("UserId") - .HasColumnType("text"); - - b.Property("LoginProvider") - .HasColumnType("text"); - - b.Property("Name") - .HasColumnType("text"); - - b.Property("Value") - .HasColumnType("text"); - - b.HasKey("UserId", "LoginProvider", "Name"); - - b.ToTable("AspNetUserTokens", (string)null); - }); - - modelBuilder.Entity("RaceTraitRace", b => - { - b.Property("RacesId") - .HasColumnType("integer"); - - b.Property("TraitsId") - .HasColumnType("integer"); - - b.HasKey("RacesId", "TraitsId"); - - b.HasIndex("TraitsId"); - - b.ToTable("RaceTraitRace"); - }); - - modelBuilder.Entity("DA_DataAccess.CharacterClasses.TraitAdv", b => - { - b.HasBaseType("DA_DataAccess.CharacterClasses.Trait"); - - b.HasDiscriminator().HasValue("TraitAdv"); - }); - - modelBuilder.Entity("DA_DataAccess.CharacterClasses.TraitEquipment", b => - { - b.HasBaseType("DA_DataAccess.CharacterClasses.Trait"); - - b.HasDiscriminator().HasValue("TraitEquipment"); - }); - - modelBuilder.Entity("DA_DataAccess.CharacterClasses.TraitRace", b => - { - b.HasBaseType("DA_DataAccess.CharacterClasses.Trait"); - - b.HasDiscriminator().HasValue("TraitRace"); - }); - - modelBuilder.Entity("DA_DataAccess.ApplicationUser", b => - { - b.HasBaseType("Microsoft.AspNetCore.Identity.IdentityUser"); - - b.Property("BadgeContent") - .HasColumnType("integer"); - - b.Property("Name") - .IsRequired() - .HasColumnType("text"); - - b.Property("ShowBadge") - .HasColumnType("boolean"); - - b.HasDiscriminator().HasValue("ApplicationUser"); - }); - - modelBuilder.Entity("CharacterEquipment", b => - { - b.HasOne("DA_DataAccess.CharacterClasses.Character", null) - .WithMany() - .HasForeignKey("CharactersId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("DA_DataAccess.CharacterClasses.Equipment", null) - .WithMany() - .HasForeignKey("EquipmentId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("CharacterTraitAdv", b => - { - b.HasOne("DA_DataAccess.CharacterClasses.Character", null) - .WithMany() - .HasForeignKey("CharactersId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("DA_DataAccess.CharacterClasses.TraitAdv", null) - .WithMany() - .HasForeignKey("TraitsAdvId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("DA_DataAccess.CharacterClasses.Attribute", b => - { - b.HasOne("DA_DataAccess.CharacterClasses.Character", "Character") - .WithMany("Attributes") - .HasForeignKey("CharacterId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Character"); - }); - - modelBuilder.Entity("DA_DataAccess.CharacterClasses.BaseSkill", b => - { - b.HasOne("DA_DataAccess.CharacterClasses.Character", "Character") - .WithMany("BaseSkills") - .HasForeignKey("CharacterId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Character"); - }); - - modelBuilder.Entity("DA_DataAccess.CharacterClasses.Bonus", b => - { - b.HasOne("DA_DataAccess.CharacterClasses.Trait", "Trait") - .WithMany("Bonuses") - .HasForeignKey("TraitId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Trait"); - }); - - modelBuilder.Entity("DA_DataAccess.CharacterClasses.Character", b => - { - b.HasOne("DA_DataAccess.CharacterClasses.Profession", "Profession") - .WithMany("Characters") - .HasForeignKey("ProfessionId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("DA_DataAccess.CharacterClasses.Race", "Race") - .WithMany("Characters") - .HasForeignKey("RaceId"); - - b.Navigation("Profession"); - - b.Navigation("Race"); - }); - - modelBuilder.Entity("DA_DataAccess.CharacterClasses.ProfessionSkill", b => - { - b.HasOne("DA_DataAccess.CharacterClasses.Profession", "ActiveProfession") - .WithMany("ActiveSkills") - .HasForeignKey("ActiveProfessionId") - .OnDelete(DeleteBehavior.NoAction); - - b.HasOne("DA_DataAccess.CharacterClasses.Profession", "PassiveProfession") - .WithMany("PassiveSkills") - .HasForeignKey("PassiveProfessionId") - .OnDelete(DeleteBehavior.NoAction); - - b.Navigation("ActiveProfession"); - - b.Navigation("PassiveProfession"); - }); - - modelBuilder.Entity("DA_DataAccess.CharacterClasses.SpecialSkill", b => - { - b.HasOne("DA_DataAccess.CharacterClasses.Character", "Character") - .WithMany("SpecialSkills") - .HasForeignKey("CharacterId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Character"); - }); - - modelBuilder.Entity("DA_DataAccess.Chat.ChatMessage", b => - { - b.HasOne("DA_DataAccess.ApplicationUser", "FromUser") - .WithMany("ChatMessagesFromUsers") - .HasForeignKey("FromUserId") - .IsRequired(); - - b.HasOne("DA_DataAccess.ApplicationUser", "ToUser") - .WithMany("ChatMessagesToUsers") - .HasForeignKey("ToUserId") - .IsRequired(); - - b.Navigation("FromUser"); - - b.Navigation("ToUser"); - }); - - modelBuilder.Entity("EquipmentTraitEquipment", b => - { - b.HasOne("DA_DataAccess.CharacterClasses.Equipment", null) - .WithMany() - .HasForeignKey("EquipmentId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("DA_DataAccess.CharacterClasses.TraitEquipment", null) - .WithMany() - .HasForeignKey("TraitsId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => - { - b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null) - .WithMany() - .HasForeignKey("RoleId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => - { - b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null) - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => - { - b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null) - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => - { - b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null) - .WithMany() - .HasForeignKey("RoleId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null) - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => - { - b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null) - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("RaceTraitRace", b => - { - b.HasOne("DA_DataAccess.CharacterClasses.Race", null) - .WithMany() - .HasForeignKey("RacesId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("DA_DataAccess.CharacterClasses.TraitRace", null) - .WithMany() - .HasForeignKey("TraitsId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("DA_DataAccess.CharacterClasses.Character", b => - { - b.Navigation("Attributes"); - - b.Navigation("BaseSkills"); - - b.Navigation("SpecialSkills"); - }); - - modelBuilder.Entity("DA_DataAccess.CharacterClasses.Profession", b => - { - b.Navigation("ActiveSkills"); - - b.Navigation("Characters"); - - b.Navigation("PassiveSkills"); - }); - - modelBuilder.Entity("DA_DataAccess.CharacterClasses.Race", b => - { - b.Navigation("Characters"); - }); - - modelBuilder.Entity("DA_DataAccess.CharacterClasses.Trait", b => - { - b.Navigation("Bonuses"); - }); - - modelBuilder.Entity("DA_DataAccess.ApplicationUser", b => - { - b.Navigation("ChatMessagesFromUsers"); - - b.Navigation("ChatMessagesToUsers"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/DA_DataAccess/Migrations/20240519204653_chatupdate.cs b/DA_DataAccess/Migrations/20240519204653_chatupdate.cs deleted file mode 100644 index f0a9e5f..0000000 --- a/DA_DataAccess/Migrations/20240519204653_chatupdate.cs +++ /dev/null @@ -1,29 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace DA_DataAccess.Migrations -{ - /// - public partial class chatupdate : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.AddColumn( - name: "IsRead", - table: "ChatMessages", - type: "boolean", - nullable: false, - defaultValue: false); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropColumn( - name: "IsRead", - table: "ChatMessages"); - } - } -} diff --git a/DA_DataAccess/Migrations/20240519204653_chatupdate.Designer.cs b/DA_DataAccess/Migrations/20240524120442_updateposts.Designer.cs similarity index 84% rename from DA_DataAccess/Migrations/20240519204653_chatupdate.Designer.cs rename to DA_DataAccess/Migrations/20240524120442_updateposts.Designer.cs index 1212e10..264b0c3 100644 --- a/DA_DataAccess/Migrations/20240519204653_chatupdate.Designer.cs +++ b/DA_DataAccess/Migrations/20240524120442_updateposts.Designer.cs @@ -12,8 +12,8 @@ namespace DA_DataAccess.Migrations { [DbContext(typeof(ApplicationDbContext))] - [Migration("20240519204653_chatupdate")] - partial class chatupdate + [Migration("20240524120442_updateposts")] + partial class updateposts { /// protected override void BuildTargetModel(ModelBuilder modelBuilder) @@ -25,6 +25,36 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + modelBuilder.Entity("CampaignCharacter", b => + { + b.Property("CampaignsId") + .HasColumnType("integer"); + + b.Property("CharactersId") + .HasColumnType("integer"); + + b.HasKey("CampaignsId", "CharactersId"); + + b.HasIndex("CharactersId"); + + b.ToTable("CampaignCharacter"); + }); + + modelBuilder.Entity("ChapterCharacter", b => + { + b.Property("ChaptersId") + .HasColumnType("integer"); + + b.Property("CharactersId") + .HasColumnType("integer"); + + b.HasKey("ChaptersId", "CharactersId"); + + b.HasIndex("CharactersId"); + + b.ToTable("ChapterCharacter"); + }); + modelBuilder.Entity("CharacterEquipment", b => { b.Property("CharactersId") @@ -216,6 +246,9 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.Property("ImageUrl") .HasColumnType("text"); + b.Property("IsApproved") + .HasColumnType("boolean"); + b.Property("NPCName") .HasColumnType("text"); @@ -514,6 +547,77 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.UseTphMappingStrategy(); }); + modelBuilder.Entity("DA_DataAccess.Chat.Campaign", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("CreatedDate") + .HasColumnType("timestamp without time zone"); + + b.Property("Description") + .IsRequired() + .HasColumnType("text"); + + b.Property("GameMaster") + .IsRequired() + .HasColumnType("text"); + + b.Property("IsFinished") + .HasColumnType("boolean"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("Campaigns"); + }); + + modelBuilder.Entity("DA_DataAccess.Chat.Chapter", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("CampaignId") + .HasColumnType("integer"); + + b.Property("CreatedDate") + .HasColumnType("timestamp without time zone"); + + b.Property("Day") + .IsRequired() + .HasColumnType("text"); + + b.Property("Description") + .IsRequired() + .HasColumnType("text"); + + b.Property("IsFinished") + .HasColumnType("boolean"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("Place") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("CampaignId"); + + b.ToTable("Chapters"); + }); + modelBuilder.Entity("DA_DataAccess.Chat.ChatMessage", b => { b.Property("Id") @@ -549,6 +653,36 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.ToTable("ChatMessages"); }); + modelBuilder.Entity("DA_DataAccess.Chat.Post", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ChapterId") + .HasColumnType("integer"); + + b.Property("CharacterId") + .HasColumnType("integer"); + + b.Property("Content") + .IsRequired() + .HasColumnType("text"); + + b.Property("CreatedDate") + .HasColumnType("timestamp without time zone"); + + b.HasKey("Id"); + + b.HasIndex("ChapterId"); + + b.HasIndex("CharacterId"); + + b.ToTable("Posts"); + }); + modelBuilder.Entity("DA_DataAccess.ImageFile", b => { b.Property("Id") @@ -842,6 +976,36 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.HasDiscriminator().HasValue("ApplicationUser"); }); + modelBuilder.Entity("CampaignCharacter", b => + { + b.HasOne("DA_DataAccess.Chat.Campaign", null) + .WithMany() + .HasForeignKey("CampaignsId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("DA_DataAccess.CharacterClasses.Character", null) + .WithMany() + .HasForeignKey("CharactersId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("ChapterCharacter", b => + { + b.HasOne("DA_DataAccess.Chat.Chapter", null) + .WithMany() + .HasForeignKey("ChaptersId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("DA_DataAccess.CharacterClasses.Character", null) + .WithMany() + .HasForeignKey("CharactersId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + modelBuilder.Entity("CharacterEquipment", b => { b.HasOne("DA_DataAccess.CharacterClasses.Character", null) @@ -950,6 +1114,17 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.Navigation("Character"); }); + modelBuilder.Entity("DA_DataAccess.Chat.Chapter", b => + { + b.HasOne("DA_DataAccess.Chat.Campaign", "Campaign") + .WithMany("Chapters") + .HasForeignKey("CampaignId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Campaign"); + }); + modelBuilder.Entity("DA_DataAccess.Chat.ChatMessage", b => { b.HasOne("DA_DataAccess.ApplicationUser", "FromUser") @@ -967,6 +1142,25 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.Navigation("ToUser"); }); + modelBuilder.Entity("DA_DataAccess.Chat.Post", b => + { + b.HasOne("DA_DataAccess.Chat.Chapter", "Chapter") + .WithMany("Posts") + .HasForeignKey("ChapterId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("DA_DataAccess.CharacterClasses.Character", "Character") + .WithMany("Posts") + .HasForeignKey("CharacterId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Chapter"); + + b.Navigation("Character"); + }); + modelBuilder.Entity("EquipmentTraitEquipment", b => { b.HasOne("DA_DataAccess.CharacterClasses.Equipment", null) @@ -1054,6 +1248,8 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.Navigation("BaseSkills"); + b.Navigation("Posts"); + b.Navigation("SpecialSkills"); }); @@ -1076,6 +1272,16 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.Navigation("Bonuses"); }); + modelBuilder.Entity("DA_DataAccess.Chat.Campaign", b => + { + b.Navigation("Chapters"); + }); + + modelBuilder.Entity("DA_DataAccess.Chat.Chapter", b => + { + b.Navigation("Posts"); + }); + modelBuilder.Entity("DA_DataAccess.ApplicationUser", b => { b.Navigation("ChatMessagesFromUsers"); diff --git a/DA_DataAccess/Migrations/20240517125003_addchatnotification.cs b/DA_DataAccess/Migrations/20240524120442_updateposts.cs similarity index 82% rename from DA_DataAccess/Migrations/20240517125003_addchatnotification.cs rename to DA_DataAccess/Migrations/20240524120442_updateposts.cs index ff4ff69..ff4927b 100644 --- a/DA_DataAccess/Migrations/20240517125003_addchatnotification.cs +++ b/DA_DataAccess/Migrations/20240524120442_updateposts.cs @@ -7,7 +7,7 @@ namespace DA_DataAccess.Migrations { /// - public partial class addchatnotification : Migration + public partial class updateposts : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) @@ -55,6 +55,23 @@ protected override void Up(MigrationBuilder migrationBuilder) table.PrimaryKey("PK_AspNetUsers", x => x.Id); }); + migrationBuilder.CreateTable( + name: "Campaigns", + columns: table => new + { + Id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + Name = table.Column(type: "text", nullable: false), + Description = table.Column(type: "text", nullable: false), + CreatedDate = table.Column(type: "timestamp without time zone", nullable: false), + GameMaster = table.Column(type: "text", nullable: false), + IsFinished = table.Column(type: "boolean", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Campaigns", x => x.Id); + }); + migrationBuilder.CreateTable( name: "Equipment", columns: table => new @@ -261,7 +278,8 @@ protected override void Up(MigrationBuilder migrationBuilder) FromUserId = table.Column(type: "text", nullable: false), ToUserId = table.Column(type: "text", nullable: false), Message = table.Column(type: "text", nullable: false), - CreatedDate = table.Column(type: "timestamp without time zone", nullable: false) + CreatedDate = table.Column(type: "timestamp without time zone", nullable: false), + IsRead = table.Column(type: "boolean", nullable: false) }, constraints: table => { @@ -278,6 +296,31 @@ protected override void Up(MigrationBuilder migrationBuilder) principalColumn: "Id"); }); + migrationBuilder.CreateTable( + name: "Chapters", + columns: table => new + { + Id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + Name = table.Column(type: "text", nullable: false), + Description = table.Column(type: "text", nullable: false), + Day = table.Column(type: "text", nullable: false), + Place = table.Column(type: "text", nullable: false), + CreatedDate = table.Column(type: "timestamp without time zone", nullable: false), + IsFinished = table.Column(type: "boolean", nullable: false), + CampaignId = table.Column(type: "integer", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Chapters", x => x.Id); + table.ForeignKey( + name: "FK_Chapters_Campaigns_CampaignId", + column: x => x.CampaignId, + principalTable: "Campaigns", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + migrationBuilder.CreateTable( name: "ProfessionSkills", columns: table => new @@ -327,6 +370,7 @@ protected override void Up(MigrationBuilder migrationBuilder) UsedExpPoints = table.Column(type: "integer", nullable: false), TraitBalance = table.Column(type: "integer", nullable: false), RaceId = table.Column(type: "integer", nullable: true), + IsApproved = table.Column(type: "boolean", nullable: false), ProfessionId = table.Column(type: "integer", nullable: false) }, constraints: table => @@ -477,6 +521,54 @@ protected override void Up(MigrationBuilder migrationBuilder) onDelete: ReferentialAction.Cascade); }); + migrationBuilder.CreateTable( + name: "CampaignCharacter", + columns: table => new + { + CampaignsId = table.Column(type: "integer", nullable: false), + CharactersId = table.Column(type: "integer", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_CampaignCharacter", x => new { x.CampaignsId, x.CharactersId }); + table.ForeignKey( + name: "FK_CampaignCharacter_Campaigns_CampaignsId", + column: x => x.CampaignsId, + principalTable: "Campaigns", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_CampaignCharacter_Characters_CharactersId", + column: x => x.CharactersId, + principalTable: "Characters", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "ChapterCharacter", + columns: table => new + { + ChaptersId = table.Column(type: "integer", nullable: false), + CharactersId = table.Column(type: "integer", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_ChapterCharacter", x => new { x.ChaptersId, x.CharactersId }); + table.ForeignKey( + name: "FK_ChapterCharacter_Chapters_ChaptersId", + column: x => x.ChaptersId, + principalTable: "Chapters", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_ChapterCharacter_Characters_CharactersId", + column: x => x.CharactersId, + principalTable: "Characters", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + migrationBuilder.CreateTable( name: "CharacterEquipment", columns: table => new @@ -525,6 +617,34 @@ protected override void Up(MigrationBuilder migrationBuilder) onDelete: ReferentialAction.Cascade); }); + migrationBuilder.CreateTable( + name: "Posts", + columns: table => new + { + Id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + Content = table.Column(type: "text", nullable: false), + CreatedDate = table.Column(type: "timestamp without time zone", nullable: false), + CharacterId = table.Column(type: "integer", nullable: false), + ChapterId = table.Column(type: "integer", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Posts", x => x.Id); + table.ForeignKey( + name: "FK_Posts_Chapters_ChapterId", + column: x => x.ChapterId, + principalTable: "Chapters", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_Posts_Characters_CharacterId", + column: x => x.CharacterId, + principalTable: "Characters", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + migrationBuilder.CreateTable( name: "SpecialSkills", columns: table => new @@ -611,6 +731,21 @@ protected override void Up(MigrationBuilder migrationBuilder) table: "Bonuses", column: "TraitId"); + migrationBuilder.CreateIndex( + name: "IX_CampaignCharacter_CharactersId", + table: "CampaignCharacter", + column: "CharactersId"); + + migrationBuilder.CreateIndex( + name: "IX_ChapterCharacter_CharactersId", + table: "ChapterCharacter", + column: "CharactersId"); + + migrationBuilder.CreateIndex( + name: "IX_Chapters_CampaignId", + table: "Chapters", + column: "CampaignId"); + migrationBuilder.CreateIndex( name: "IX_CharacterEquipment_EquipmentId", table: "CharacterEquipment", @@ -646,6 +781,16 @@ protected override void Up(MigrationBuilder migrationBuilder) table: "EquipmentTraitEquipment", column: "TraitsId"); + migrationBuilder.CreateIndex( + name: "IX_Posts_ChapterId", + table: "Posts", + column: "ChapterId"); + + migrationBuilder.CreateIndex( + name: "IX_Posts_CharacterId", + table: "Posts", + column: "CharacterId"); + migrationBuilder.CreateIndex( name: "IX_ProfessionSkills_ActiveProfessionId", table: "ProfessionSkills", @@ -694,6 +839,12 @@ protected override void Down(MigrationBuilder migrationBuilder) migrationBuilder.DropTable( name: "Bonuses"); + migrationBuilder.DropTable( + name: "CampaignCharacter"); + + migrationBuilder.DropTable( + name: "ChapterCharacter"); + migrationBuilder.DropTable( name: "CharacterEquipment"); @@ -709,6 +860,9 @@ protected override void Down(MigrationBuilder migrationBuilder) migrationBuilder.DropTable( name: "ImageFiles"); + migrationBuilder.DropTable( + name: "Posts"); + migrationBuilder.DropTable( name: "ProfessionSkills"); @@ -727,12 +881,18 @@ protected override void Down(MigrationBuilder migrationBuilder) migrationBuilder.DropTable( name: "Equipment"); + migrationBuilder.DropTable( + name: "Chapters"); + migrationBuilder.DropTable( name: "Traits"); migrationBuilder.DropTable( name: "Characters"); + migrationBuilder.DropTable( + name: "Campaigns"); + migrationBuilder.DropTable( name: "Professions"); diff --git a/DA_DataAccess/Migrations/ApplicationDbContextModelSnapshot.cs b/DA_DataAccess/Migrations/ApplicationDbContextModelSnapshot.cs index 2f26830..970a01d 100644 --- a/DA_DataAccess/Migrations/ApplicationDbContextModelSnapshot.cs +++ b/DA_DataAccess/Migrations/ApplicationDbContextModelSnapshot.cs @@ -22,6 +22,36 @@ protected override void BuildModel(ModelBuilder modelBuilder) NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + modelBuilder.Entity("CampaignCharacter", b => + { + b.Property("CampaignsId") + .HasColumnType("integer"); + + b.Property("CharactersId") + .HasColumnType("integer"); + + b.HasKey("CampaignsId", "CharactersId"); + + b.HasIndex("CharactersId"); + + b.ToTable("CampaignCharacter"); + }); + + modelBuilder.Entity("ChapterCharacter", b => + { + b.Property("ChaptersId") + .HasColumnType("integer"); + + b.Property("CharactersId") + .HasColumnType("integer"); + + b.HasKey("ChaptersId", "CharactersId"); + + b.HasIndex("CharactersId"); + + b.ToTable("ChapterCharacter"); + }); + modelBuilder.Entity("CharacterEquipment", b => { b.Property("CharactersId") @@ -213,6 +243,9 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("ImageUrl") .HasColumnType("text"); + b.Property("IsApproved") + .HasColumnType("boolean"); + b.Property("NPCName") .HasColumnType("text"); @@ -511,6 +544,77 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.UseTphMappingStrategy(); }); + modelBuilder.Entity("DA_DataAccess.Chat.Campaign", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("CreatedDate") + .HasColumnType("timestamp without time zone"); + + b.Property("Description") + .IsRequired() + .HasColumnType("text"); + + b.Property("GameMaster") + .IsRequired() + .HasColumnType("text"); + + b.Property("IsFinished") + .HasColumnType("boolean"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("Campaigns"); + }); + + modelBuilder.Entity("DA_DataAccess.Chat.Chapter", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("CampaignId") + .HasColumnType("integer"); + + b.Property("CreatedDate") + .HasColumnType("timestamp without time zone"); + + b.Property("Day") + .IsRequired() + .HasColumnType("text"); + + b.Property("Description") + .IsRequired() + .HasColumnType("text"); + + b.Property("IsFinished") + .HasColumnType("boolean"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("Place") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("CampaignId"); + + b.ToTable("Chapters"); + }); + modelBuilder.Entity("DA_DataAccess.Chat.ChatMessage", b => { b.Property("Id") @@ -546,6 +650,36 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.ToTable("ChatMessages"); }); + modelBuilder.Entity("DA_DataAccess.Chat.Post", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ChapterId") + .HasColumnType("integer"); + + b.Property("CharacterId") + .HasColumnType("integer"); + + b.Property("Content") + .IsRequired() + .HasColumnType("text"); + + b.Property("CreatedDate") + .HasColumnType("timestamp without time zone"); + + b.HasKey("Id"); + + b.HasIndex("ChapterId"); + + b.HasIndex("CharacterId"); + + b.ToTable("Posts"); + }); + modelBuilder.Entity("DA_DataAccess.ImageFile", b => { b.Property("Id") @@ -839,6 +973,36 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasDiscriminator().HasValue("ApplicationUser"); }); + modelBuilder.Entity("CampaignCharacter", b => + { + b.HasOne("DA_DataAccess.Chat.Campaign", null) + .WithMany() + .HasForeignKey("CampaignsId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("DA_DataAccess.CharacterClasses.Character", null) + .WithMany() + .HasForeignKey("CharactersId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("ChapterCharacter", b => + { + b.HasOne("DA_DataAccess.Chat.Chapter", null) + .WithMany() + .HasForeignKey("ChaptersId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("DA_DataAccess.CharacterClasses.Character", null) + .WithMany() + .HasForeignKey("CharactersId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + modelBuilder.Entity("CharacterEquipment", b => { b.HasOne("DA_DataAccess.CharacterClasses.Character", null) @@ -947,6 +1111,17 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Navigation("Character"); }); + modelBuilder.Entity("DA_DataAccess.Chat.Chapter", b => + { + b.HasOne("DA_DataAccess.Chat.Campaign", "Campaign") + .WithMany("Chapters") + .HasForeignKey("CampaignId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Campaign"); + }); + modelBuilder.Entity("DA_DataAccess.Chat.ChatMessage", b => { b.HasOne("DA_DataAccess.ApplicationUser", "FromUser") @@ -964,6 +1139,25 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Navigation("ToUser"); }); + modelBuilder.Entity("DA_DataAccess.Chat.Post", b => + { + b.HasOne("DA_DataAccess.Chat.Chapter", "Chapter") + .WithMany("Posts") + .HasForeignKey("ChapterId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("DA_DataAccess.CharacterClasses.Character", "Character") + .WithMany("Posts") + .HasForeignKey("CharacterId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Chapter"); + + b.Navigation("Character"); + }); + modelBuilder.Entity("EquipmentTraitEquipment", b => { b.HasOne("DA_DataAccess.CharacterClasses.Equipment", null) @@ -1051,6 +1245,8 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Navigation("BaseSkills"); + b.Navigation("Posts"); + b.Navigation("SpecialSkills"); }); @@ -1073,6 +1269,16 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Navigation("Bonuses"); }); + modelBuilder.Entity("DA_DataAccess.Chat.Campaign", b => + { + b.Navigation("Chapters"); + }); + + modelBuilder.Entity("DA_DataAccess.Chat.Chapter", b => + { + b.Navigation("Posts"); + }); + modelBuilder.Entity("DA_DataAccess.ApplicationUser", b => { b.Navigation("ChatMessagesFromUsers"); diff --git a/DA_Models/CharacterModels/CharacterDTO.cs b/DA_Models/CharacterModels/CharacterDTO.cs index 8037066..a441758 100644 --- a/DA_Models/CharacterModels/CharacterDTO.cs +++ b/DA_Models/CharacterModels/CharacterDTO.cs @@ -1,5 +1,7 @@ using DA_DataAccess.CharacterClasses; +using DA_DataAccess.Chat; using System.ComponentModel.DataAnnotations; +using System.Security.Cryptography.X509Certificates; using Attribute = DA_DataAccess.CharacterClasses.Attribute; namespace DA_Models.CharacterModels @@ -9,12 +11,12 @@ public class CharacterDTO public int Id { get; set; } [Required(ErrorMessage = "Please enter name of character")] public string? UserName { get; set; } - public string? NPCName { get; set; } + public string? NPCName { get; set; } = string.Empty; public string? Description { get; set; } [Range(16, 300, ErrorMessage = "Age must be between 16 and 300 years")] public int Age { get; set; } - public string? ImageUrl { get; set; } + public string? ImageUrl { get; set; } = "/upload/portraits/def-char-img.webp"; public string? NPCType { get; set; } public int AttributePoints { get; set; } public int CurrentExpPoints { get; set; } @@ -30,8 +32,13 @@ public class CharacterDTO public ICollection? SpecialSkills { get; set; } public ICollection ? TraitsAdv { get; set; } public ICollection? Equipment { get; set; } + public ICollection? Campaigns { get; set; } + public ICollection? Posts { get; set; } + public ICollection? Chapters { get; set; } public int RaceId { get; set; } = 0; public int ProfessionId { get; set; } = 0; + public bool IsApproved { get; set; } = false; + public override string ToString() => NPCName; } } diff --git a/DA_Models/CharacterModels/ProfessionDTO.cs b/DA_Models/CharacterModels/ProfessionDTO.cs index 9478272..f7b7c2a 100644 --- a/DA_Models/CharacterModels/ProfessionDTO.cs +++ b/DA_Models/CharacterModels/ProfessionDTO.cs @@ -65,6 +65,7 @@ public ProfessionDTO() new ProfessionSkill(){ Level = 6, Index=5}, new ProfessionSkill(){ Level = 7, Index=6}, }; + Description = string.Empty; } public void CalculateClassParams(IEnumerable attributes) { diff --git a/DA_Models/ChatModels/CampaignDTO.cs b/DA_Models/ChatModels/CampaignDTO.cs new file mode 100644 index 0000000..9a4c425 --- /dev/null +++ b/DA_Models/ChatModels/CampaignDTO.cs @@ -0,0 +1,23 @@ +using DA_DataAccess.CharacterClasses; +using DA_Models.CharacterModels; +using MudBlazor.Charts; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DA_DataAccess.Chat +{ + public class CampaignDTO + { + public int Id { get; set; } + public string Name { get; set; } = string.Empty; + public string Description { get; set; } = string.Empty; + public ICollection Chapters { get; set; } = new List(); + public DateTime CreatedDate { get; set; } + public ICollection Characters { get; set; } = new List(); + public string GameMaster { get; set; } = string.Empty; + public bool IsFinished { get; set; } = false; + } +} diff --git a/DA_Models/ChatModels/ChapterDTO.cs b/DA_Models/ChatModels/ChapterDTO.cs new file mode 100644 index 0000000..c2df63e --- /dev/null +++ b/DA_Models/ChatModels/ChapterDTO.cs @@ -0,0 +1,25 @@ +using DA_Models; +using DA_Models.CharacterModels; +using MudBlazor.Charts; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DA_DataAccess.Chat +{ + public class ChapterDTO + { + public int Id { get; set; } + public string Name { get; set; } + public string Description { get; set; } + public string Day { get; set; } + public string Place { get ; set; } + public ICollection Posts { get; set; } + public DateTime CreatedDate { get; set; } + public ICollection Characters { get; set; } + public bool IsFinished { get; set; } + public int CampaignId { get; set; } + } +} diff --git a/DA_Models/ChatModels/PostDTO.cs b/DA_Models/ChatModels/PostDTO.cs new file mode 100644 index 0000000..edb5c1d --- /dev/null +++ b/DA_Models/ChatModels/PostDTO.cs @@ -0,0 +1,21 @@ +using DA_DataAccess.CharacterClasses; +using DA_Models.CharacterModels; +using MudBlazor.Charts; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DA_DataAccess.Chat +{ + public class PostDTO + { + public int Id { get; set; } + public string Content { get; set; } + public DateTime CreatedDate { get; set; } + public int CharacterId { get; set; } + public CharacterDTO? Character { get; set; } + public int ChapterId { get; set; } + } +} diff --git a/DagoniteEmpire/DagoniteEmpire.csproj b/DagoniteEmpire/DagoniteEmpire.csproj index 8015f7a..a3489bf 100644 --- a/DagoniteEmpire/DagoniteEmpire.csproj +++ b/DagoniteEmpire/DagoniteEmpire.csproj @@ -61,8 +61,4 @@ - - - - diff --git a/DagoniteEmpire/Pages/CharacterPages/CharacterUpsert.razor b/DagoniteEmpire/Pages/CharacterPages/CharacterUpsert.razor index 6da15b2..a294407 100644 --- a/DagoniteEmpire/Pages/CharacterPages/CharacterUpsert.razor +++ b/DagoniteEmpire/Pages/CharacterPages/CharacterUpsert.razor @@ -43,6 +43,12 @@ + @if(IsAdminOrMG){ +
+ + +
+ }
@@ -72,7 +78,7 @@
- +
@@ -85,7 +91,6 @@ @Character.AttributePoints
-
@@ -440,7 +445,8 @@ private bool ModifChanged = false; private bool IsLeaveAllowed { get; set; } = false; private bool IsDukeAllowed { get; set; } = false; - private string TargetLocation { get; set; } = ""; + private string TargetLocation { get; set; } = ""; + public bool IsAdminOrMG { get; set; } = true; private List NoTools = new List(); private List ToolbarItems = new List() { @@ -448,7 +454,7 @@ new ItemModel(){ Text = "Edit", PrefixIcon= "e-edit", Id="Grid_edit"}, new ItemModel(){ Text = "Delete", PrefixIcon= "e-delete", Id="Grid_delete"}, }; - + private string ChooseFile = "Choose file"; [CascadingParameter] public Task AuthenticationState { get; set; } @@ -460,6 +466,11 @@ var uri = new Uri(_navigationManager.Uri); _navigationManager.NavigateTo($"/identity/account/login?returnUrl={uri.LocalPath}", forceLoad: true); } + var user = authState.User; + if (user == null) + return; // failed to load + + IsAdminOrMG = user.IsInRole(SD.Role_Admin) || user.IsInRole(SD.Role_GameMaster); } protected override async Task OnAfterRenderAsync(bool firstRender) @@ -714,6 +725,7 @@ { if (e.GetMultipleFiles().Count > 0) { + ChooseFile = string.Empty; foreach (var file in e.GetMultipleFiles()) { System.IO.FileInfo fileInfo = new System.IO.FileInfo(file.Name); diff --git a/DagoniteEmpire/Pages/CharacterPages/CharacterUpsert.razor.css b/DagoniteEmpire/Pages/CharacterPages/CharacterUpsert.razor.css index 201669c..f807d7b 100644 --- a/DagoniteEmpire/Pages/CharacterPages/CharacterUpsert.razor.css +++ b/DagoniteEmpire/Pages/CharacterPages/CharacterUpsert.razor.css @@ -121,8 +121,7 @@ td { flex-direction: column; justify-content: center; align-items: center; - padding: 5px 5px 0px 5px; - border: 1px solid RGB(206 212 218); + /*border: 1px solid RGB(206 212 218);*/ border-radius: 4px; /*width: 320px;*/ height: 390px; @@ -135,21 +134,22 @@ td { width: 100%; max-height: 93%; border: 0px solid white; + } .portrait-input { - width: 200px; + position: absolute; + width: 100%; + height: 100%; font-size: 16px; font-weight: bold; - justify-content:center; - align-content:center; padding: 4px; bottom: 0; overflow: hidden; white-space: nowrap; /* Don't forget this one */ text-overflow: ellipsis; + z-index: 1000; } .sr-only { - sr-only position: absolute; width: 1px; height: 1px; padding: 0; @@ -161,14 +161,23 @@ td { } .input-label { - width: 100%; + position:absolute; + width: 250px; + height: 300px; padding: 30px; text-align: center; + align-content:center; background-color: transparent; color: black; - border: 1px solid RGB(206 212 218); + border: none;/* 1px solid RGB(206 212 218);*/ border-radius: 10px; cursor: pointer; + margin-left: auto; + margin-right: auto; + top: 110px; + left: 0; + right: 0; + z-index: 1500; } .trait-container { padding: 0; diff --git a/DagoniteEmpire/Pages/Chat/CampaignList.Razor.css b/DagoniteEmpire/Pages/Chat/CampaignList.Razor.css new file mode 100644 index 0000000..7e31f94 --- /dev/null +++ b/DagoniteEmpire/Pages/Chat/CampaignList.Razor.css @@ -0,0 +1,13 @@ +/* improved for chat text box */ + +.camp { + transition: transform 0.1s; +} + +.camp:hover { + transform: scale(1.03); +} + + .camp:active { + transform: scale(0.97); + } diff --git a/DagoniteEmpire/Pages/Chat/CampaignList.razor b/DagoniteEmpire/Pages/Chat/CampaignList.razor new file mode 100644 index 0000000..acbe9da --- /dev/null +++ b/DagoniteEmpire/Pages/Chat/CampaignList.razor @@ -0,0 +1,220 @@ +@page "/campaignlist" + +@using Syncfusion.Blazor.Navigations; +@inject NavigationManager _navigationManager +@inject ISnackbar _snackBar +@inject IDialogService DialogService +@inject IJSRuntime _jsRuntime +@inject ICharacterRepository _characterRepository +@inject ICampaignRepository _campaignRepository +@inject IChapterRepository _chapterRepository +@inject AuthenticationStateProvider GetAuthenticationStateAsync +@inject IChatManager _chatManager +@inject ICampaignRepository _campaignRepository + + +@using Microsoft.AspNetCore.SignalR.Client; + + + + @if (IsLoading == true){ +
+ +
+ }else{ + + Avalible campaigns + @if (IsAdminOrMG) + { +
+ + + Add new Campaign... + +
+ } + else + { + @if (Characters.Count() > 0) + { + + + @foreach (var character in Characters) + { + + } + + } + } + + + @if(Campaigns is not null && Campaigns.Any()) + { + @foreach(var camp in Campaigns) + { +
+ + + @camp.Name + Started by: @camp.GameMaster at: @camp.CreatedDate + @camp.Description +
+ @foreach (var adv in camp.Characters) + { + + + @if (string.IsNullOrEmpty(adv.ImageUrl)) + { + @adv.NPCName.ToUpper().First() + } + else + { + + + + } + + @adv.NPCName + + } +
+
+ +
+ + } + + } + else + { + Not signed into any adventures yet + } +
+ } + + + + +
+ + + + +@code{ + + private IEnumerable Characters { get; set; } = new List(); + private List Campaigns { get; set; } = new List(); + public bool IsLoading { get; set; } = true; + public bool IsAdminOrMG { get; set; } = true; + private string Title { get; set; } = "Your characters"; + private CharacterDTO SelectedCharacter = new(); + public CampaignDTO NewCampaign { get; set; } = new(); + [CascadingParameter] + public Task AuthenticationState { get; set; } + + protected override async Task OnInitializedAsync() + { + var authState = await AuthenticationState; + if (!authState.User.Identity.IsAuthenticated) + { + var uri = new Uri(_navigationManager.Uri); + _navigationManager.NavigateTo($"/identity/account/login?returnUrl={uri.LocalPath}", forceLoad: true); + } + + var user = authState.User; + if (user == null) + return; // failed to load + + IsAdminOrMG = user.IsInRole(SD.Role_Admin) || user.IsInRole(SD.Role_GameMaster); + } + + protected override async Task OnAfterRenderAsync(bool firstRender) + { + if (firstRender) + { + await LoadCharactersAndCampaigns(); + } + } + + private async Task SelectCharacter(CharacterDTO character) + { + IsLoading = true; + StateHasChanged(); + SelectedCharacter = character; + Campaigns = (await _campaignRepository.GetAll(character.Id)).ToList(); + IsLoading = false; + StateHasChanged(); + } + + private async Task LoadCharactersAndCampaigns() + { + IsLoading = true; + StateHasChanged(); + var authstate = await GetAuthenticationStateAsync.GetAuthenticationStateAsync(); + var user = authstate.User; + if (user == null) + return; // failed to load + + + if (IsAdminOrMG) + { + Title = "All avalible campaingns"; + Characters = await _characterRepository.GetAll(); + Campaigns = (await _campaignRepository.GetAll()).ToList(); + SelectedCharacter = await _characterRepository.GetByName("Game Master"); + } + else + { + Title = "Characters of " + user.Identity.Name; + Characters = await _characterRepository.GetAllForUser(user.Identity.Name); + if (Characters.Any()) + { + SelectedCharacter = Characters.First(); + Campaigns = (await _campaignRepository.GetAll(SelectedCharacter.Id)).ToList(); + } + + + } + IsLoading = false; + StateHasChanged(); + } + + private async Task CreateCampaign(){ + + NewCampaign.Characters = Characters.ToList(); + + var parameters = new DialogParameters { { x => x.NewCampaign, NewCampaign } }; + + var dialog = await DialogService.ShowAsync("Create Campaig", parameters); + var result = await dialog.Result; + + if (!result.Canceled) + { + NewCampaign = (CampaignDTO)result.Data; + + var authstate = await GetAuthenticationStateAsync.GetAuthenticationStateAsync(); + if (authstate is not null) + NewCampaign.GameMaster = authstate.User.Identity.Name; + + + + // await _campaignRepository.Create(NewCampaign); + + Campaigns.Add(await _campaignRepository.Create(NewCampaign)); + } + } + + private async Task ChooseCampaign(CampaignDTO campaign) + { + _navigationManager.NavigateTo($"/campaign/{campaign.Id}/{SelectedCharacter.Id}"); + } + + + + + + + + + +} \ No newline at end of file diff --git a/DagoniteEmpire/Pages/Chat/ChapterList.Razor.css b/DagoniteEmpire/Pages/Chat/ChapterList.Razor.css new file mode 100644 index 0000000..7e31f94 --- /dev/null +++ b/DagoniteEmpire/Pages/Chat/ChapterList.Razor.css @@ -0,0 +1,13 @@ +/* improved for chat text box */ + +.camp { + transition: transform 0.1s; +} + +.camp:hover { + transform: scale(1.03); +} + + .camp:active { + transform: scale(0.97); + } diff --git a/DagoniteEmpire/Pages/Chat/ChapterList.razor b/DagoniteEmpire/Pages/Chat/ChapterList.razor new file mode 100644 index 0000000..1024570 --- /dev/null +++ b/DagoniteEmpire/Pages/Chat/ChapterList.razor @@ -0,0 +1,177 @@ +@page "/campaign/{id:int}/{charId:int}" + +@using Syncfusion.Blazor.Navigations; +@inject NavigationManager _navigationManager +@inject ISnackbar _snackBar +@inject IDialogService DialogService +@inject IJSRuntime _jsRuntime +@inject ICharacterRepository _characterRepository +@inject ICampaignRepository _campaignRepository +@inject IChapterRepository _chapterRepository +@inject AuthenticationStateProvider GetAuthenticationStateAsync +@inject IChatManager _chatManager +@inject ICampaignRepository _campaignRepository + + +@using Microsoft.AspNetCore.SignalR.Client; + + + + @if (IsLoading == true){ +
+ +
+ }else{ + @if (Campaign is not null) + { + Chapter list of @Campaign.Name + } + @if (IsAdminOrMG) + { +
+ + Add new Chapter... + +
+ } + else + { + + Chapters for @SelectedCharacter.NPCName + + + } + + + @if(Chapters is not null) + { + @foreach (var chap in Chapters) + { +
+ + + @chap.Name + Started at: @chap.CreatedDate + @chap.Day, @chap.Place + @chap.Description +
+ @foreach (var adv in chap.Characters) + { + + + @if (string.IsNullOrEmpty(adv.ImageUrl)) + { + @adv.NPCName.ToUpper().First() + } + else + { + + + + } + + @adv.NPCName + + } +
+
+ +
+ + } + } +
+ } + + + + +
+ + + + +@code{ + [Parameter] + public int Id { get; set; } + [Parameter] + public int CharId { get; set; } + private CampaignDTO Campaign { get; set; } + private List Chapters { get; set; } = new List(); + public ChapterDTO NewChapter { get; set; } = new(); + public bool IsLoading { get; set; } = true; + public bool IsAdminOrMG { get; set; } = true; + private string Title { get; set; } = "Campaign name"; + private CharacterDTO SelectedCharacter = null; + [CascadingParameter] + public Task AuthenticationState { get; set; } + + protected override async Task OnInitializedAsync() + { + var authState = await AuthenticationState; + if (!authState.User.Identity.IsAuthenticated) + { + var uri = new Uri(_navigationManager.Uri); + _navigationManager.NavigateTo($"/identity/account/login?returnUrl={uri.LocalPath}", forceLoad: true); + } + + var user = authState.User; + if (user == null) + return; // failed to load + + IsAdminOrMG = user.IsInRole(SD.Role_Admin) || user.IsInRole(SD.Role_GameMaster); + } + + protected override async Task OnAfterRenderAsync(bool firstRender) + { + if (firstRender) + { + await LoadCampaign(); + } + } + + + private async Task LoadCampaign() + { + IsLoading = true; + StateHasChanged(); + + Campaign = await _campaignRepository.GetById(Id); + Chapters = (await _chapterRepository.GetAll(Id)).ToList(); + SelectedCharacter = await _characterRepository.GetById(CharId); + Title = Campaign.Name; + + IsLoading = false; + StateHasChanged(); + } + + private async Task CreateChapter() + { + NewChapter.Characters = Campaign.Characters.ToList(); + + var parameters = new DialogParameters { { x => x.NewChapter, NewChapter } }; + + var dialog = await DialogService.ShowAsync("Create Campaign", parameters); + var result = await dialog.Result; + + if (!result.Canceled) + { + NewChapter = (ChapterDTO)result.Data; + NewChapter.CampaignId = Campaign.Id; + + + Chapters.Add(await _chapterRepository.Create(NewChapter)); + } + } + + private async Task ChooseChapter(ChapterDTO chapter) + { + _navigationManager.NavigateTo($"/chapter/{chapter.Id}/{SelectedCharacter.Id}"); + } + + + + + + +} \ No newline at end of file diff --git a/DagoniteEmpire/Pages/Chat/ChapterThread.Razor.css b/DagoniteEmpire/Pages/Chat/ChapterThread.Razor.css new file mode 100644 index 0000000..7e31f94 --- /dev/null +++ b/DagoniteEmpire/Pages/Chat/ChapterThread.Razor.css @@ -0,0 +1,13 @@ +/* improved for chat text box */ + +.camp { + transition: transform 0.1s; +} + +.camp:hover { + transform: scale(1.03); +} + + .camp:active { + transform: scale(0.97); + } diff --git a/DagoniteEmpire/Pages/Chat/ChapterThread.razor b/DagoniteEmpire/Pages/Chat/ChapterThread.razor new file mode 100644 index 0000000..96ea234 --- /dev/null +++ b/DagoniteEmpire/Pages/Chat/ChapterThread.razor @@ -0,0 +1,214 @@ +@page "/chapter/{id:int}/{charId:int}" + +@using Syncfusion.Blazor.Navigations; +@inject NavigationManager _navigationManager +@inject ISnackbar _snackBar +@inject IDialogService DialogService +@inject IJSRuntime _jsRuntime +@inject ICharacterRepository _characterRepository +@inject IChapterRepository _chapterRepository +@inject IPostRepository _postRepository +@inject AuthenticationStateProvider GetAuthenticationStateAsync +@inject IChatManager _chatManager +@inject ICampaignRepository _campaignRepository + + +@using Microsoft.AspNetCore.SignalR.Client; + + + + @if (IsLoading == true){ +
+ +
+ }else{ + + + @if (Chapter is not null) + { + Chapter: @Chapter.Name + @Chapter.Day, @Chapter.Place + Started at: @Chapter.CreatedDate + + + @if(Chapter.Posts is not null){ + @foreach (var post in Posts) + { + if (post.Character is not null) + { + string postId = "postnumber_" + post.Id.ToString(); + + + @post.Character.NPCName + + + + Posted at: @post.CreatedDate + + + + + + + } + } + } + + } + + + + + Save + + } + +
+ + + +@code{ + [Parameter] + public int Id { get; set; } + [Parameter] + public int CharId { get; set; } + private ChapterDTO Chapter { get; set; } + private List Posts { get; set; } = new List(); + private List Characters { get; set; } = new List(); + public PostDTO NewPost { get; set; } = new(); + public bool IsLoading { get; set; } = true; + public bool IsAdminOrMG { get; set; } = true; + private string Title { get; set; } = "Campaign name"; + private CharacterDTO SelectedCharacter = null; + private List NoTools = new List(); + private List Tools = new List() + { + new ToolbarItemModel() { Command = ToolbarCommand.Bold }, + new ToolbarItemModel() { Command = ToolbarCommand.Italic }, + new ToolbarItemModel() { Command = ToolbarCommand.Underline }, + new ToolbarItemModel() { Command = ToolbarCommand.StrikeThrough }, + new ToolbarItemModel() { Command = ToolbarCommand.FontName }, + new ToolbarItemModel() { Command = ToolbarCommand.FontSize }, + new ToolbarItemModel() { Command = ToolbarCommand.FontColor }, + new ToolbarItemModel() { Command = ToolbarCommand.Separator }, + new ToolbarItemModel() { Command = ToolbarCommand.Formats }, + new ToolbarItemModel() { Command = ToolbarCommand.Alignments }, + new ToolbarItemModel() { Command = ToolbarCommand.OrderedList }, + new ToolbarItemModel() { Command = ToolbarCommand.UnorderedList }, + new ToolbarItemModel() { Command = ToolbarCommand.Outdent }, + new ToolbarItemModel() { Command = ToolbarCommand.Indent }, + new ToolbarItemModel() { Command = ToolbarCommand.Separator }, + new ToolbarItemModel() { Command = ToolbarCommand.CreateLink }, + new ToolbarItemModel() { Command = ToolbarCommand.Image }, + new ToolbarItemModel() { Command = ToolbarCommand.Separator }, + new ToolbarItemModel() { Command = ToolbarCommand.Undo }, + new ToolbarItemModel() { Command = ToolbarCommand.Redo }, + new ToolbarItemModel() { Command = ToolbarCommand.FullScreen }, + }; + [CascadingParameter] + public Task AuthenticationState { get; set; } + + protected override async Task OnInitializedAsync() + { + var authState = await AuthenticationState; + if (!authState.User.Identity.IsAuthenticated) + { + var uri = new Uri(_navigationManager.Uri); + _navigationManager.NavigateTo($"/identity/account/login?returnUrl={uri.LocalPath}", forceLoad: true); + } + + var user = authState.User; + if (user == null) + return; // failed to load + + + IsAdminOrMG = user.IsInRole(SD.Role_Admin) || user.IsInRole(SD.Role_GameMaster); + if (IsAdminOrMG) + { + SelectedCharacter = new() + { + NPCName = "Game Master", + UserName = user.Identity.Name, + }; + } + } + + protected override async Task OnAfterRenderAsync(bool firstRender) + { + if (firstRender) + { + await LoadChapter(); + } + } + + + private async Task LoadChapter() + { + IsLoading = true; + StateHasChanged(); + + Chapter = await _chapterRepository.GetById(Id); + Posts = (await _postRepository.GetAll(Id)).ToList(); + Characters = (await _characterRepository.GetAll()).ToList(); + + if (IsAdminOrMG) + { + SelectedCharacter = await _characterRepository.GetByName("Game Master"); + } + else + { + SelectedCharacter = await _characterRepository.GetById(CharId); + } + + Title = Chapter.Name; + + IsLoading = false; + StateHasChanged(); + } + + private async Task CreatePost() + { + if (string.IsNullOrEmpty(NewPost.Content)) + return; + + IsLoading = true; + StateHasChanged(); + NewPost.ChapterId = Id; + NewPost.CharacterId = SelectedCharacter.Id; + NewPost.Character = SelectedCharacter; + NewPost.CreatedDate = DateTime.Now; + + var result = await _postRepository.Create(NewPost); + if(result is not null) + Posts.Add(NewPost); + + NewPost = new(); + + IsLoading = false; + StateHasChanged(); + } + + public void ResizePostContent(string args) + { + //pass ID(column name) of multiline textbox + _jsRuntime.InvokeVoidAsync("ResizeRichTextArea", $"{args}"); + } + + + + + +} \ No newline at end of file diff --git a/DagoniteEmpire/Pages/Chat/Chat.razor b/DagoniteEmpire/Pages/Chat/Chat.razor index b9d78d1..a3d7216 100644 --- a/DagoniteEmpire/Pages/Chat/Chat.razor +++ b/DagoniteEmpire/Pages/Chat/Chat.razor @@ -192,7 +192,7 @@ } await _jsRuntime.ScrollToBottom("chatContainer"); // Inform blazor the UI needs updating - InvokeAsync(StateHasChanged); + await InvokeAsync(StateHasChanged); } } diff --git a/DagoniteEmpire/Pages/Chat/ChatRoom.Razor.css b/DagoniteEmpire/Pages/Chat/ChatRoom.Razor.css deleted file mode 100644 index 59d3f92..0000000 --- a/DagoniteEmpire/Pages/Chat/ChatRoom.Razor.css +++ /dev/null @@ -1,63 +0,0 @@ -/* improved for chat text box */ -textarea { - border: 1px dashed #888; - border-radius: 5px; - width: 80%; - overflow: auto; - background: #f7f7f7 -} - -/* improved for speech bubbles */ -.received, .sent { - position: relative; - font-family: arial; - font-size: 1.1em; - border-radius: 10px; - padding: 20px; - margin-bottom: 20px; -} - - .received:after, .sent:after { - content: ''; - border: 20px solid transparent; - position: absolute; - margin-top: -30px; - } - -.sent { - background: #03a9f4; - color: #fff; - margin-left: 10%; - top: 50%; - text-align: right; -} - -.received { - background: #4CAF50; - color: #fff; - margin-left: 10px; - margin-right: 10%; -} - -.sent:after { - border-left-color: #03a9f4; - border-right: 0; - right: -20px; -} - -.received:after { - border-right-color: #4CAF50; - border-left: 0; - left: -20px; -} - -/* div within bubble for name */ -.user { - font-size: 0.8em; - font-weight: bold; - color: #000; -} - -.msg { - /*display: inline;*/ -} diff --git a/DagoniteEmpire/Pages/Chat/ChatRoom.razor b/DagoniteEmpire/Pages/Chat/ChatRoom.razor deleted file mode 100644 index 70788db..0000000 --- a/DagoniteEmpire/Pages/Chat/ChatRoom.razor +++ /dev/null @@ -1,173 +0,0 @@ -@* -@page "/chatroom" - - -@inject NavigationManager _navigationManager -@inject ISnackbar _snackBar -@inject IJSRuntime _jsRuntime -@inject AuthenticationStateProvider _stateProvider -@inject IChatManager _chatManager - -@using Microsoft.AspNetCore.SignalR.Client; - -

Blazor SignalR Chat Sample

-
- -@if (!_isChatting) -{ -

- Enter your name to start chatting: -

- - - - - // Error messages - @if (_message != null) - { -
@_message
- @_message - } -} -else -{ - // banner to show current user - - // display messages -
- @foreach (var item in _messages) - { - @if (item.IsNotice) - { -
@item.Body
- } - else - { -
-
@item.Username
-
@item.Body
-
- } - } -
- - -
-} - -@code { - // flag to indicate chat status - private bool _isChatting = false; - - // name of the user who will be chatting - private string _username; - - // on-screen message - private string _message; - - // new message input - private string _newMessage; - - // list of messages in chat - private List _messages = new List(); - - private string _hubUrl; - private HubConnection _hubConnection; - - public async Task Chat() - { - // check username is valid - if (string.IsNullOrWhiteSpace(_username)) - { - _message = "Please enter a name"; - return; - }; - - try - { - // Start chatting and force refresh UI. - _isChatting = true; - await Task.Delay(1); - - // remove old messages if any - _messages.Clear(); - - // Create the chat client - string baseUrl = navigationManager.BaseUri; - - _hubUrl = baseUrl.TrimEnd('/') + SignalRHub.HubUrl; - - _hubConnection = new HubConnectionBuilder() - .WithUrl(_hubUrl) - .Build(); - - _hubConnection.On("Broadcast", BroadcastMessage); - - await _hubConnection.StartAsync(); - - await SendAsync($"[Notice] {_username} joined chat room."); - } - catch (Exception e) - { - _message = $"ERROR: Failed to start chat client: {e.Message}"; - _isChatting = false; - } - } - - private void BroadcastMessage(string name, string message) - { - bool isMine = name.Equals(_username, StringComparison.OrdinalIgnoreCase); - - _messages.Add(new Message(name, message, isMine)); - - // Inform blazor the UI needs updating - InvokeAsync(StateHasChanged); - } - - private async Task DisconnectAsync() - { - if (_isChatting) - { - await SendAsync($"[Notice] {_username} left chat room."); - - await _hubConnection.StopAsync(); - await _hubConnection.DisposeAsync(); - - _hubConnection = null; - _isChatting = false; - } - } - - private async Task SendAsync(string message) - { - if (_isChatting && !string.IsNullOrWhiteSpace(message)) - { - await _hubConnection.SendAsync("Broadcast", _username, message); - - _newMessage = string.Empty; - } - } - - private class Message - { - public Message(string username, string body, bool mine) - { - Username = username; - Body = body; - Mine = mine; - } - - public string Username { get; set; } - public string Body { get; set; } - public bool Mine { get; set; } - - public bool IsNotice => Body.StartsWith("[Notice]"); - - public string CSS => Mine ? "sent" : "received"; - } -} -*@ \ No newline at end of file diff --git a/DagoniteEmpire/Pages/Components/CampaignComponent.razor b/DagoniteEmpire/Pages/Components/CampaignComponent.razor new file mode 100644 index 0000000..728ef75 --- /dev/null +++ b/DagoniteEmpire/Pages/Components/CampaignComponent.razor @@ -0,0 +1,5 @@ +

CampaignComponent

+ +@code { + +} diff --git a/DagoniteEmpire/Pages/Dialogs/CreateCampaignDialog.razor b/DagoniteEmpire/Pages/Dialogs/CreateCampaignDialog.razor new file mode 100644 index 0000000..c2dc751 --- /dev/null +++ b/DagoniteEmpire/Pages/Dialogs/CreateCampaignDialog.razor @@ -0,0 +1,60 @@ + +@inject ISnackbar Snackbar + + + + + + Create new Campaign + + + + + + + @foreach (var adv in NewCampaign.Characters) + { + + } + + + + + Cancel + Create campaign + + + +@code { + [CascadingParameter] MudDialogInstance MudDialog { get; set; } + + [Parameter] public CampaignDTO NewCampaign { get; set; } + MudChip[] SelectedCharacters { get; set; } + private List Characters { get; set; } = new List(); + + private void Cancel() + { + MudDialog.Cancel(); + } + + private void CreateCampaign() + { + //In a real world scenario this bool would probably be a service to delete the item from api/database + Snackbar.Add("Campaign Created", Severity.Success); + + if (SelectedCharacters is not null) + { + foreach (var charac in SelectedCharacters) + { + var adventurer = NewCampaign.Characters.FirstOrDefault(c => c.NPCName == charac.Text); + if (adventurer is not null) + Characters.Add(adventurer); + } + } + NewCampaign.Characters = Characters; + NewCampaign.CreatedDate = DateTime.Now; + + + MudDialog.Close(DialogResult.Ok(NewCampaign)); + } +} diff --git a/DagoniteEmpire/Pages/Dialogs/CreateChapterDialog.razor b/DagoniteEmpire/Pages/Dialogs/CreateChapterDialog.razor new file mode 100644 index 0000000..a0696b2 --- /dev/null +++ b/DagoniteEmpire/Pages/Dialogs/CreateChapterDialog.razor @@ -0,0 +1,62 @@ + +@inject ISnackbar Snackbar + + + + + + Create new Chapter + + + + + + + + + + @foreach (var adv in NewChapter.Characters) + { + + } + + + + + Cancel + Create campaign + + + +@code { + [CascadingParameter] MudDialogInstance MudDialog { get; set; } + + [Parameter] public ChapterDTO NewChapter { get; set; } + MudChip[] SelectedCharacters { get; set; } + private List Characters { get; set; } = new List(); + + private void Cancel() + { + MudDialog.Cancel(); + } + + private void CreateCampaign() + { + //In a real world scenario this bool would probably be a service to delete the item from api/database + Snackbar.Add("Chapter Created", Severity.Success); + + if (SelectedCharacters is not null) + { + foreach (var charac in SelectedCharacters) + { + var adventurer = NewChapter.Characters.FirstOrDefault(c => c.NPCName == charac.Text); + if (adventurer is not null) + Characters.Add(adventurer); + } + } + NewChapter.Characters = Characters; + NewChapter.CreatedDate = DateTime.Now; + + MudDialog.Close(DialogResult.Ok(NewChapter)); + } +} diff --git a/DagoniteEmpire/Pages/Index.razor b/DagoniteEmpire/Pages/Index.razor index ebe695d..e0062a6 100644 --- a/DagoniteEmpire/Pages/Index.razor +++ b/DagoniteEmpire/Pages/Index.razor @@ -1,15 +1,32 @@ @page "/" -@* Dagonite Empire *@ - -
-
-

Welcome to Dagonite Empire!

+@if (IsLoading) +{ +
+
-
+} +else +{ +
+
+

Welcome to Dagonite Empire!

+
+
+ +
-
-@* -

Welcome to Dagonite Empire!

*@ +} +@code{ + public bool IsLoading { get; set; } = true; + protected override async Task OnAfterRenderAsync(bool firstRender) + { + if (firstRender) + { + IsLoading = false; + StateHasChanged(); + } + } +} \ No newline at end of file diff --git a/DagoniteEmpire/Pages/Shared/_Layout.cshtml b/DagoniteEmpire/Pages/Shared/_Layout.cshtml index 937eb72..ca81054 100644 --- a/DagoniteEmpire/Pages/Shared/_Layout.cshtml +++ b/DagoniteEmpire/Pages/Shared/_Layout.cshtml @@ -80,12 +80,12 @@ crossorigin="anonymous" integrity="sha384-ZvpUoO/+PpLXR1lu4jmpXWu80pZlYUAfxl5NsBMWOEPSjUn/6Z/hRTt8+pR6L4N2"> - + *@ diff --git a/DagoniteEmpire/Pages/_Host.cshtml b/DagoniteEmpire/Pages/_Host.cshtml index 367c28a..4f0cf09 100644 --- a/DagoniteEmpire/Pages/_Host.cshtml +++ b/DagoniteEmpire/Pages/_Host.cshtml @@ -49,14 +49,15 @@ + - - - + + + diff --git a/DagoniteEmpire/Program.cs b/DagoniteEmpire/Program.cs index 0875986..6d9c2eb 100644 --- a/DagoniteEmpire/Program.cs +++ b/DagoniteEmpire/Program.cs @@ -20,6 +20,7 @@ using DA_Models.CharacterModels; using DA_Models.ChatModels; using MudBlazor; +using DA_Business.Repository.ChatRepos; var builder = WebApplication.CreateBuilder(args); @@ -62,6 +63,9 @@ builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddScoped(); +builder.Services.AddScoped(); +builder.Services.AddScoped(); +builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddScoped(); diff --git a/DagoniteEmpire/Service/DbInitializer.cs b/DagoniteEmpire/Service/DbInitializer.cs index d3ce21f..73ca95c 100644 --- a/DagoniteEmpire/Service/DbInitializer.cs +++ b/DagoniteEmpire/Service/DbInitializer.cs @@ -74,6 +74,33 @@ public void Initialize() _userManager.CreateAsync(user, "Guest123*").GetAwaiter().GetResult(); _userManager.AddToRoleAsync(user, SD.Role_GameMaster).GetAwaiter().GetResult(); } + if (_db.Professions.FirstOrDefault(c => c.Name == "Game Master") == null) + { + var proff = new Profession() { Name = "Game Master",Description="", RelatedAttribute= "" }; + + _db.Professions.Add(proff); + _db.SaveChanges(); + } + if (_db.Races.FirstOrDefault(c => c.Name == "Game Master") == null) + { + var race = new Race() { Name = "Game Master" }; + + _db.Races.Add(race); + _db.SaveChanges(); + } + if (_db.Characters.FirstOrDefault(c=>c.NPCName == "Game Master") == null) + { + var charac = new Character() { UserName = "GM", NPCName = "Game Master" }; + + var profession = _db.Professions.FirstOrDefault(c => c.Name == "Game Master"); + var race = _db.Races.FirstOrDefault(c => c.Name == "Game Master"); + charac.ProfessionId = profession.Id; + charac.RaceId = race.Id; + charac.ImageUrl = "../images/gm_avatar.webp"; + + _db.Characters.Add(charac); + _db.SaveChanges(); + } if (_db.Races.FirstOrDefault(u => u.Name == "Human") == null) { diff --git a/DagoniteEmpire/Shared/Chat.Razor.css b/DagoniteEmpire/Shared/Chat.Razor.css index 340817e..dc7bd4e 100644 --- a/DagoniteEmpire/Shared/Chat.Razor.css +++ b/DagoniteEmpire/Shared/Chat.Razor.css @@ -17,7 +17,6 @@ position: fixed; bottom: 0; right: 0; - width: 100%; height: 600px; z-index: 6000; } diff --git a/DagoniteEmpire/Shared/Chat.razor b/DagoniteEmpire/Shared/Chat.razor index 5fa0d64..bdd72f7 100644 --- a/DagoniteEmpire/Shared/Chat.razor +++ b/DagoniteEmpire/Shared/Chat.razor @@ -8,11 +8,11 @@ - Chat + Chat
- + @foreach (var user in ChatUsers) { @@ -237,7 +237,7 @@ ChosenUser = user; ChosenUser.IsUserChosen = true; - InvokeAsync(StateHasChanged); + await InvokeAsync(StateHasChanged); } ClearBadgeContent(); @@ -306,7 +306,7 @@ } } // Inform blazor the UI needs updating - InvokeAsync(StateHasChanged); + await InvokeAsync(StateHasChanged); ScrollToBottom = true; } diff --git a/DagoniteEmpire/Shared/MainLayout.razor b/DagoniteEmpire/Shared/MainLayout.razor index 3fab880..6aae879 100644 --- a/DagoniteEmpire/Shared/MainLayout.razor +++ b/DagoniteEmpire/Shared/MainLayout.razor @@ -21,7 +21,7 @@
Character list - Chat + Campaign
diff --git a/DagoniteEmpire/Shared/NavMenu.razor b/DagoniteEmpire/Shared/NavMenu.razor index dd84940..e4efe7d 100644 --- a/DagoniteEmpire/Shared/NavMenu.razor +++ b/DagoniteEmpire/Shared/NavMenu.razor @@ -1,64 +1,4 @@ -@* - - - - -@code { - private string AdminRole = DA_Common.SD.Role_Admin; - private string LoggedRole = DA_Common.SD.Role_Admin + "," + DA_Common.SD.Role_Admin + "," + DA_Common.SD.Role_Admin + "," + SD.Role_GameMaster; - private bool collapseNavMenu = true; - - private string? NavMenuCssClass => collapseNavMenu ? "collapse" : null; - - private void ToggleNavMenu() - { - collapseNavMenu = !collapseNavMenu; - } -} - *@ - + Home @@ -66,7 +6,7 @@ Character sheets - - Chat room + + Campaign \ No newline at end of file diff --git a/DagoniteEmpire/wwwroot/icons/bookmarklet.svg b/DagoniteEmpire/wwwroot/icons/bookmarklet.svg new file mode 100644 index 0000000..84076bc --- /dev/null +++ b/DagoniteEmpire/wwwroot/icons/bookmarklet.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/DagoniteEmpire/wwwroot/icons/quill.svg b/DagoniteEmpire/wwwroot/icons/quill.svg new file mode 100644 index 0000000..3816ba7 --- /dev/null +++ b/DagoniteEmpire/wwwroot/icons/quill.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/DagoniteEmpire/wwwroot/icons/scroll.svg b/DagoniteEmpire/wwwroot/icons/scroll.svg new file mode 100644 index 0000000..ee26adc --- /dev/null +++ b/DagoniteEmpire/wwwroot/icons/scroll.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/DagoniteEmpire/wwwroot/images/gm_avatar.webp b/DagoniteEmpire/wwwroot/images/gm_avatar.webp new file mode 100644 index 0000000..fc7e8f6 Binary files /dev/null and b/DagoniteEmpire/wwwroot/images/gm_avatar.webp differ diff --git a/DagoniteEmpire/wwwroot/js/common.js b/DagoniteEmpire/wwwroot/js/common.js index 3fdb3c8..74bc432 100644 --- a/DagoniteEmpire/wwwroot/js/common.js +++ b/DagoniteEmpire/wwwroot/js/common.js @@ -90,6 +90,15 @@ function ResizeTextArea(id) { } return true; } +function ResizeRichTextArea(id) { + var el = document.getElementById(id); + if (el) { + el.style.height = "5px"; + el.style.height = (el.scrollHeight + 5) + "px"; + el.style.border = "none"; + } + return true; +} window.ScrollToBottom = (elementName) => { element = document.getElementById(elementName); diff --git a/DagoniteEmpire/wwwroot/upload/portraits/04238dc8-989a-4c50-931e-7f09e10d2a8d.webp b/DagoniteEmpire/wwwroot/upload/portraits/04238dc8-989a-4c50-931e-7f09e10d2a8d.webp deleted file mode 100644 index dbd5468..0000000 Binary files a/DagoniteEmpire/wwwroot/upload/portraits/04238dc8-989a-4c50-931e-7f09e10d2a8d.webp and /dev/null differ diff --git a/DagoniteEmpire/wwwroot/upload/portraits/0959c2a0-5518-4448-9959-10e90241395c.webp b/DagoniteEmpire/wwwroot/upload/portraits/0959c2a0-5518-4448-9959-10e90241395c.webp deleted file mode 100644 index 6d997ea..0000000 Binary files a/DagoniteEmpire/wwwroot/upload/portraits/0959c2a0-5518-4448-9959-10e90241395c.webp and /dev/null differ diff --git a/DagoniteEmpire/wwwroot/upload/portraits/104f550a-0692-4d64-b701-188c56dd0777.webp b/DagoniteEmpire/wwwroot/upload/portraits/104f550a-0692-4d64-b701-188c56dd0777.webp deleted file mode 100644 index 6d997ea..0000000 Binary files a/DagoniteEmpire/wwwroot/upload/portraits/104f550a-0692-4d64-b701-188c56dd0777.webp and /dev/null differ diff --git a/DagoniteEmpire/wwwroot/upload/portraits/155e55a0-090e-4b8a-82dc-57d02032b845.webp b/DagoniteEmpire/wwwroot/upload/portraits/155e55a0-090e-4b8a-82dc-57d02032b845.webp deleted file mode 100644 index 83e9860..0000000 Binary files a/DagoniteEmpire/wwwroot/upload/portraits/155e55a0-090e-4b8a-82dc-57d02032b845.webp and /dev/null differ diff --git a/DagoniteEmpire/wwwroot/upload/portraits/25ca8a7c-971b-43ce-ad2a-fa085630f868.webp b/DagoniteEmpire/wwwroot/upload/portraits/25ca8a7c-971b-43ce-ad2a-fa085630f868.webp deleted file mode 100644 index 83e9860..0000000 Binary files a/DagoniteEmpire/wwwroot/upload/portraits/25ca8a7c-971b-43ce-ad2a-fa085630f868.webp and /dev/null differ diff --git a/DagoniteEmpire/wwwroot/upload/portraits/60806e87-5211-41bc-bca0-2244752cbd22.webp b/DagoniteEmpire/wwwroot/upload/portraits/60806e87-5211-41bc-bca0-2244752cbd22.webp deleted file mode 100644 index 19d3885..0000000 Binary files a/DagoniteEmpire/wwwroot/upload/portraits/60806e87-5211-41bc-bca0-2244752cbd22.webp and /dev/null differ diff --git a/DagoniteEmpire/wwwroot/upload/portraits/80a41935-a2a8-478d-8d2e-32c160c421e7.webp b/DagoniteEmpire/wwwroot/upload/portraits/80a41935-a2a8-478d-8d2e-32c160c421e7.webp deleted file mode 100644 index 6d997ea..0000000 Binary files a/DagoniteEmpire/wwwroot/upload/portraits/80a41935-a2a8-478d-8d2e-32c160c421e7.webp and /dev/null differ diff --git a/DagoniteEmpire/wwwroot/upload/portraits/c1ddfcaa-16c2-46c8-ac60-fdce7e479292.webp b/DagoniteEmpire/wwwroot/upload/portraits/c1ddfcaa-16c2-46c8-ac60-fdce7e479292.webp deleted file mode 100644 index 6d997ea..0000000 Binary files a/DagoniteEmpire/wwwroot/upload/portraits/c1ddfcaa-16c2-46c8-ac60-fdce7e479292.webp and /dev/null differ diff --git a/DagoniteEmpire/wwwroot/upload/portraits/caa0957d-26f1-4fa9-a2cc-78b6574bf793.webp b/DagoniteEmpire/wwwroot/upload/portraits/caa0957d-26f1-4fa9-a2cc-78b6574bf793.webp deleted file mode 100644 index 5c079b9..0000000 Binary files a/DagoniteEmpire/wwwroot/upload/portraits/caa0957d-26f1-4fa9-a2cc-78b6574bf793.webp and /dev/null differ diff --git a/DagoniteEmpire/wwwroot/upload/portraits/def-char-img.webp b/DagoniteEmpire/wwwroot/upload/portraits/def-char-img.webp new file mode 100644 index 0000000..0222a9e Binary files /dev/null and b/DagoniteEmpire/wwwroot/upload/portraits/def-char-img.webp differ diff --git a/DagoniteEmpire/wwwroot/upload/portraits/ec3d8087-a6b7-4f29-b555-75f793957d94.webp b/DagoniteEmpire/wwwroot/upload/portraits/ec3d8087-a6b7-4f29-b555-75f793957d94.webp deleted file mode 100644 index 19d3885..0000000 Binary files a/DagoniteEmpire/wwwroot/upload/portraits/ec3d8087-a6b7-4f29-b555-75f793957d94.webp and /dev/null differ