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