diff --git a/DA_Business/Repository/CharacterReps/CharacterRepository.cs b/DA_Business/Repository/CharacterReps/CharacterRepository.cs index fd7124a..0822a0e 100644 --- a/DA_Business/Repository/CharacterReps/CharacterRepository.cs +++ b/DA_Business/Repository/CharacterReps/CharacterRepository.cs @@ -48,6 +48,17 @@ public async Task Create(CharacterDTO objDTO) obj.TraitsAdv.Add(t); } }); + //handle equipment + var equipment = await contex.Equipment.ToListAsync(); + equipment.ForEach(e => + { + if (obj.Equipment.Any(nt => nt.Id == e.Id)) + { + var untracked = obj.Equipment.FirstOrDefault(nt => nt.Id == e.Id); + obj.Equipment.Remove(untracked); + obj.Equipment.Add(e); + } + }); var addedObj = contex.Characters.Add(obj); await contex.SaveChangesAsync(); diff --git a/DA_Business/Repository/CharacterReps/RaceRepository.cs b/DA_Business/Repository/CharacterReps/RaceRepository.cs index 21339e7..f0b136d 100644 --- a/DA_Business/Repository/CharacterReps/RaceRepository.cs +++ b/DA_Business/Repository/CharacterReps/RaceRepository.cs @@ -66,6 +66,7 @@ public async Task Delete(int id) { using var contex = await _db.CreateDbContextAsync(); var obj = await contex.Races.Include(u=>u.Traits).FirstOrDefaultAsync(u => u.Id == id); + if (obj is not null) { var traits = obj.Traits; diff --git a/DA_Business/Repository/ChatRepos/ChatManager.cs b/DA_Business/Repository/ChatRepos/ChatManager.cs new file mode 100644 index 0000000..72575d8 --- /dev/null +++ b/DA_Business/Repository/ChatRepos/ChatManager.cs @@ -0,0 +1,97 @@ +using AutoMapper; +using DA_Business.Repository.CharacterReps.IRepository; +using DA_DataAccess; +using DA_DataAccess.CharacterClasses; +using DA_DataAccess.Chat; +using DA_DataAccess.Data; +using DA_Models.CharacterModels; +using Microsoft.AspNetCore.Components.Authorization; +using Microsoft.AspNetCore.Identity; +using Microsoft.EntityFrameworkCore; +using Microsoft.JSInterop; +using System.Net.Http.Json; +using System.Security.Claims; +using Attribute = DA_DataAccess.CharacterClasses.Attribute; + +namespace DA_Business.Repository.CharacterReps +{ + public class ChatManager : IChatManager + { + private readonly AuthenticationStateProvider _authState; + private readonly HttpClient _httpClient; + private readonly IDbContextFactory _db; + private readonly IJSRuntime _jsRuntime; + private readonly UserManager _userManager; + + public ChatManager(HttpClient httpClient, IDbContextFactory db, IJSRuntime jsRuntime, AuthenticationStateProvider authState, UserManager userManager) + { + _httpClient = httpClient; + _db = db; + _jsRuntime = jsRuntime; + _authState = authState; + _userManager = userManager; + } + public async Task> GetConversationAsync(string contactId) + { + using var contex = await _db.CreateDbContextAsync(); + var user = (await _authState.GetAuthenticationStateAsync()).User; + var userId = user.Claims.Where(a => a.Type == ClaimTypes.NameIdentifier).Select(a => a.Value).FirstOrDefault(); + var messages = await contex.ChatMessages + .Where(h => (h.FromUserId == contactId && h.ToUserId == userId) || (h.FromUserId == userId && h.ToUserId == contactId)) + .OrderBy(a => a.CreatedDate) + .Include(a => a.FromUser) + .Include(a => a.ToUser) + .Select(x => new ChatMessage + { + FromUserId = x.FromUserId, + Message = x.Message, + CreatedDate = x.CreatedDate, + Id = x.Id, + ToUserId = x.ToUserId, + ToUser = x.ToUser, + FromUser = x.FromUser + }).ToListAsync(); + + return messages; + } + public async Task GetUserDetailsAsync(string userId) + { + using var contex = await _db.CreateDbContextAsync(); + // var user = await contex.ApplicationUsers.Where(user => user.Id == userId).FirstOrDefaultAsync(); + var user = _userManager.Users.Where(user => user.Id == userId).FirstOrDefaultAsync(); + + return await user; + } + public async Task> GetUsersAsync() + { + using var contex = await _db.CreateDbContextAsync(); + var user = (await _authState.GetAuthenticationStateAsync()).User; + + var userId = user.Claims.Where(a => a.Type == ClaimTypes.NameIdentifier).Select(a => a.Value).FirstOrDefault(); + var allUsers = _userManager.Users.Where(user => user.Id != userId).ToListAsync(); + + return await allUsers; + } + public async Task SaveMessageAsync(ChatMessage message) + { + try + { + + using var contex = await _db.CreateDbContextAsync(); + var user = (await _authState.GetAuthenticationStateAsync()).User; + var userId = user.Claims.Where(a => a.Type == ClaimTypes.NameIdentifier).Select(a => a.Value).FirstOrDefault(); + message.FromUserId = userId; + message.CreatedDate = DateTime.Now; + message.ToUser = await contex.ApplicationUsers.Where(user => user.Id == message.ToUserId).FirstOrDefaultAsync(); + var result = contex.ChatMessages.AddAsync(message); + await contex.SaveChangesAsync(); + + } + catch(Exception ex) + { + ; + } + + } + } +} diff --git a/DA_Business/Repository/ChatRepos/IRepository/IChatManager.cs b/DA_Business/Repository/ChatRepos/IRepository/IChatManager.cs new file mode 100644 index 0000000..28d0975 --- /dev/null +++ b/DA_Business/Repository/ChatRepos/IRepository/IChatManager.cs @@ -0,0 +1,19 @@ +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 IChatManager + { + Task> GetUsersAsync(); + Task SaveMessageAsync(ChatMessage message); + Task> GetConversationAsync(string contactId); + Task GetUserDetailsAsync(string userId); + } +} diff --git a/DA_DataAccess/ApplicationUser.cs b/DA_DataAccess/ApplicationUser.cs index 82d53f1..2c87778 100644 --- a/DA_DataAccess/ApplicationUser.cs +++ b/DA_DataAccess/ApplicationUser.cs @@ -1,4 +1,5 @@ -using Microsoft.AspNetCore.Identity; +using DA_DataAccess.Chat; +using Microsoft.AspNetCore.Identity; using System; using System.Collections.Generic; using System.Linq; @@ -10,6 +11,13 @@ namespace DA_DataAccess public class ApplicationUser : IdentityUser { public string Name { get; set; } + public virtual ICollection ChatMessagesFromUsers { get; set; } + public virtual ICollection ChatMessagesToUsers { get; set; } + public ApplicationUser() + { + ChatMessagesFromUsers = new HashSet(); + ChatMessagesToUsers = new HashSet(); + } } } diff --git a/DA_DataAccess/CharacterClasses/Equipment.cs b/DA_DataAccess/CharacterClasses/Equipment.cs index f316fa5..2092975 100644 --- a/DA_DataAccess/CharacterClasses/Equipment.cs +++ b/DA_DataAccess/CharacterClasses/Equipment.cs @@ -12,9 +12,9 @@ public class Equipment { [Key] public int Id { get; set; } - public ICollection? Traits { get; set; } + public ICollection? Traits { get; set; } = null; - public ICollection? Characters { get; set; } + public ICollection? Characters { get; set; } = null; public string Name { get; set; } //for example "axe" public int Index { get; set; } diff --git a/DA_DataAccess/Chat/ChatMessage.cs b/DA_DataAccess/Chat/ChatMessage.cs new file mode 100644 index 0000000..51f838d --- /dev/null +++ b/DA_DataAccess/Chat/ChatMessage.cs @@ -0,0 +1,21 @@ +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 ChatMessage + { + public long Id { get; set; } + public string FromUserId { get; set; } + public string ToUserId { get; set; } + public string Message { get; set; } + public DateTime CreatedDate { get; set; } + public virtual ApplicationUser FromUser { get; set; } + public virtual ApplicationUser ToUser { get; set; } + public bool IsNotice => Message.StartsWith("[Notice]"); + } +} diff --git a/DA_DataAccess/Data/ApplicationDbContext.cs b/DA_DataAccess/Data/ApplicationDbContext.cs index 73ca980..05f40a3 100644 --- a/DA_DataAccess/Data/ApplicationDbContext.cs +++ b/DA_DataAccess/Data/ApplicationDbContext.cs @@ -1,4 +1,6 @@ -using DA_DataAccess.CharacterClasses; +using Abp.Domain.Entities; +using DA_DataAccess.CharacterClasses; +using DA_DataAccess.Chat; using Microsoft.AspNetCore.Identity.EntityFrameworkCore; using Microsoft.EntityFrameworkCore; using Newtonsoft.Json; @@ -10,7 +12,7 @@ public class ApplicationDbContext : IdentityDbContext { public ApplicationDbContext(DbContextOptions options) : base(options) { - + AppContext.SetSwitch("Npgsql.EnableLegacyTimestampBehavior", true); } public DbSet Characters { get; set; } public DbSet Attributes { get; set; } @@ -29,6 +31,8 @@ public ApplicationDbContext(DbContextOptions options) : ba public DbSet Professions { get; set; } public DbSet ProfessionSkills { get; set; } + public DbSet ChatMessages { get; set; } + protected override void OnModelCreating(ModelBuilder modelBuilder) { base.OnModelCreating(modelBuilder); @@ -42,6 +46,17 @@ protected override void OnModelCreating(ModelBuilder modelBuilder) .HasOne(a => a.PassiveProfession) .WithMany(y => y.PassiveSkills) .HasForeignKey(a => a.PassiveProfessionId).OnDelete(DeleteBehavior.NoAction); + + modelBuilder.Entity() + .HasOne(d => d.FromUser) + .WithMany(p => p.ChatMessagesFromUsers) + .HasForeignKey(d => d.FromUserId) + .OnDelete(DeleteBehavior.ClientSetNull); + modelBuilder.Entity() + .HasOne(d => d.ToUser) + .WithMany(p => p.ChatMessagesToUsers) + .HasForeignKey(d => d.ToUserId) + .OnDelete(DeleteBehavior.ClientSetNull); } } } diff --git a/DA_DataAccess/Migrations/20240507163528_AddChat.Designer.cs b/DA_DataAccess/Migrations/20240507163528_AddChat.Designer.cs new file mode 100644 index 0000000..15a09e8 --- /dev/null +++ b/DA_DataAccess/Migrations/20240507163528_AddChat.Designer.cs @@ -0,0 +1,1079 @@ +// +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("20240507163528_AddChat")] + partial class AddChat + { + /// + 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 with 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("Name") + .IsRequired() + .HasColumnType("text"); + + 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/20240507163528_AddChat.cs b/DA_DataAccess/Migrations/20240507163528_AddChat.cs new file mode 100644 index 0000000..718cc14 --- /dev/null +++ b/DA_DataAccess/Migrations/20240507163528_AddChat.cs @@ -0,0 +1,59 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; + +#nullable disable + +namespace DA_DataAccess.Migrations +{ + /// + public partial class AddChat : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "ChatMessages", + columns: table => new + { + Id = table.Column(type: "bigint", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + 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 with time zone", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_ChatMessages", x => x.Id); + table.ForeignKey( + name: "FK_ChatMessages_AspNetUsers_FromUserId", + column: x => x.FromUserId, + principalTable: "AspNetUsers", + principalColumn: "Id"); + table.ForeignKey( + name: "FK_ChatMessages_AspNetUsers_ToUserId", + column: x => x.ToUserId, + principalTable: "AspNetUsers", + principalColumn: "Id"); + }); + + migrationBuilder.CreateIndex( + name: "IX_ChatMessages_FromUserId", + table: "ChatMessages", + column: "FromUserId"); + + migrationBuilder.CreateIndex( + name: "IX_ChatMessages_ToUserId", + table: "ChatMessages", + column: "ToUserId"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "ChatMessages"); + } + } +} diff --git a/DA_DataAccess/Migrations/20240507224949_addApplicationUser.Designer.cs b/DA_DataAccess/Migrations/20240507224949_addApplicationUser.Designer.cs new file mode 100644 index 0000000..b0cbbe2 --- /dev/null +++ b/DA_DataAccess/Migrations/20240507224949_addApplicationUser.Designer.cs @@ -0,0 +1,1079 @@ +// +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("20240507224949_addApplicationUser")] + partial class addApplicationUser + { + /// + 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 with 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("Name") + .IsRequired() + .HasColumnType("text"); + + 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/20240507224949_addApplicationUser.cs b/DA_DataAccess/Migrations/20240507224949_addApplicationUser.cs new file mode 100644 index 0000000..d8e40a3 --- /dev/null +++ b/DA_DataAccess/Migrations/20240507224949_addApplicationUser.cs @@ -0,0 +1,22 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace DA_DataAccess.Migrations +{ + /// + public partial class addApplicationUser : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + + } + } +} diff --git a/DA_DataAccess/Migrations/ApplicationDbContextModelSnapshot.cs b/DA_DataAccess/Migrations/ApplicationDbContextModelSnapshot.cs index f9eab20..722d9dd 100644 --- a/DA_DataAccess/Migrations/ApplicationDbContextModelSnapshot.cs +++ b/DA_DataAccess/Migrations/ApplicationDbContextModelSnapshot.cs @@ -511,6 +511,38 @@ protected override void BuildModel(ModelBuilder modelBuilder) 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 with 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") @@ -906,6 +938,23 @@ protected override void BuildModel(ModelBuilder modelBuilder) 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) @@ -1014,6 +1063,13 @@ protected override void BuildModel(ModelBuilder modelBuilder) { b.Navigation("Bonuses"); }); + + modelBuilder.Entity("DA_DataAccess.ApplicationUser", b => + { + b.Navigation("ChatMessagesFromUsers"); + + b.Navigation("ChatMessagesToUsers"); + }); #pragma warning restore 612, 618 } } diff --git a/DA_Models/ChatModels/ChatHub.cs b/DA_Models/ChatModels/ChatHub.cs new file mode 100644 index 0000000..db1287b --- /dev/null +++ b/DA_Models/ChatModels/ChatHub.cs @@ -0,0 +1,34 @@ +using DA_DataAccess.Chat; +using Microsoft.AspNetCore.SignalR; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DA_Models.ChatModels +{ + public class ChatHub : Hub + { + public const string HubUrl = "/ChatHub"; + + public async Task SendMessage(string username, ChatMessage message) + { + // Console.WriteLine($"{username} sent message"); + + await Clients.All.SendAsync("SendMessage", username, message); + } + + public override Task OnConnectedAsync() + { + Console.WriteLine($"{Context.ConnectionId} hub connected"); + return base.OnConnectedAsync(); + } + + public override async Task OnDisconnectedAsync(Exception e) + { + Console.WriteLine($"Disconnected {e?.Message} {Context.ConnectionId}"); + await base.OnDisconnectedAsync(e); + } + } +} diff --git a/DA_Models/ChatModels/SignalRHub .cs b/DA_Models/ChatModels/SignalRHub .cs new file mode 100644 index 0000000..4f80fef --- /dev/null +++ b/DA_Models/ChatModels/SignalRHub .cs @@ -0,0 +1,41 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using DA_DataAccess.Chat; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.SignalR; + +namespace DA_Models.ChatModels +{ + public class SignalRHub : Hub + { + // public const string HubUrl = "/chat"; + + //public async Task Broadcast(string username, string message) + //{ + // await Clients.All.SendAsync("Broadcast", username, message); + //} + + //public override Task OnConnectedAsync() + //{ + // Console.WriteLine($"{Context.ConnectionId} connected"); + // return base.OnConnectedAsync(); + //} + + //public override async Task OnDisconnectedAsync(Exception e) + //{ + // Console.WriteLine($"Disconnected {e?.Message} {Context.ConnectionId}"); + // await base.OnDisconnectedAsync(e); + //} + //public async Task SendMessageAsync( string userName, ChatMessage message) + //{ + // await Clients.All.SendAsync("ReceiveMessage", userName, message); + //} + //public async Task ChatNotificationAsync(string message, string receiverUserId, string senderUserId) + //{ + // await Clients.All.SendAsync("ReceiveChatNotification", message, receiverUserId, senderUserId); + //} + } +} diff --git a/DA_Models/DA_Models.csproj b/DA_Models/DA_Models.csproj index f26e55a..9502b30 100644 --- a/DA_Models/DA_Models.csproj +++ b/DA_Models/DA_Models.csproj @@ -10,6 +10,7 @@ + diff --git a/DagoniteEmpire/Areas/Identity/Pages/Account/ConfirmEmail.cshtml.cs b/DagoniteEmpire/Areas/Identity/Pages/Account/ConfirmEmail.cshtml.cs index 0f745b2..8dbbeff 100644 --- a/DagoniteEmpire/Areas/Identity/Pages/Account/ConfirmEmail.cshtml.cs +++ b/DagoniteEmpire/Areas/Identity/Pages/Account/ConfirmEmail.cshtml.cs @@ -6,6 +6,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; +using DA_DataAccess; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Identity; using Microsoft.AspNetCore.Mvc; @@ -16,9 +17,9 @@ namespace DagoniteEmpire.Areas.Identity.Pages.Account { public class ConfirmEmailModel : PageModel { - private readonly UserManager _userManager; + private readonly UserManager_userManager; - public ConfirmEmailModel(UserManager userManager) + public ConfirmEmailModel(UserManageruserManager) { _userManager = userManager; } diff --git a/DagoniteEmpire/Areas/Identity/Pages/Account/ConfirmEmailChange.cshtml.cs b/DagoniteEmpire/Areas/Identity/Pages/Account/ConfirmEmailChange.cshtml.cs index a92dbb3..5ec465a 100644 --- a/DagoniteEmpire/Areas/Identity/Pages/Account/ConfirmEmailChange.cshtml.cs +++ b/DagoniteEmpire/Areas/Identity/Pages/Account/ConfirmEmailChange.cshtml.cs @@ -5,6 +5,7 @@ using System; using System.Text; using System.Threading.Tasks; +using DA_DataAccess; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Identity; using Microsoft.AspNetCore.Mvc; @@ -15,10 +16,10 @@ namespace DagoniteEmpire.Areas.Identity.Pages.Account { public class ConfirmEmailChangeModel : PageModel { - private readonly UserManager _userManager; - private readonly SignInManager _signInManager; + private readonly UserManager _userManager; + private readonly SignInManager _signInManager; - public ConfirmEmailChangeModel(UserManager userManager, SignInManager signInManager) + public ConfirmEmailChangeModel(UserManager userManager, SignInManager signInManager) { _userManager = userManager; _signInManager = signInManager; diff --git a/DagoniteEmpire/Areas/Identity/Pages/Account/ExternalLogin.cshtml.cs b/DagoniteEmpire/Areas/Identity/Pages/Account/ExternalLogin.cshtml.cs index 835bc93..664b0b5 100644 --- a/DagoniteEmpire/Areas/Identity/Pages/Account/ExternalLogin.cshtml.cs +++ b/DagoniteEmpire/Areas/Identity/Pages/Account/ExternalLogin.cshtml.cs @@ -18,22 +18,24 @@ using Microsoft.AspNetCore.WebUtilities; using Microsoft.Extensions.Logging; +using DA_DataAccess; + namespace DagoniteEmpire.Areas.Identity.Pages.Account { [AllowAnonymous] public class ExternalLoginModel : PageModel { - private readonly SignInManager _signInManager; - private readonly UserManager _userManager; - private readonly IUserStore _userStore; - private readonly IUserEmailStore _emailStore; + private readonly SignInManager_signInManager; + private readonly UserManager_userManager; + private readonly IUserStore _userStore; + private readonly IUserEmailStore _emailStore; private readonly IEmailSender _emailSender; private readonly ILogger _logger; public ExternalLoginModel( - SignInManager signInManager, - UserManager userManager, - IUserStore userStore, + SignInManagersignInManager, + UserManageruserManager, + IUserStore userStore, ILogger logger, IEmailSender emailSender) { @@ -197,27 +199,27 @@ await _emailSender.SendEmailAsync(Input.Email, "Confirm your email", return Page(); } - private IdentityUser CreateUser() + private ApplicationUser CreateUser() { try { - return Activator.CreateInstance(); + return Activator.CreateInstance(); } catch { - throw new InvalidOperationException($"Can't create an instance of '{nameof(IdentityUser)}'. " + - $"Ensure that '{nameof(IdentityUser)}' is not an abstract class and has a parameterless constructor, or alternatively " + + throw new InvalidOperationException($"Can't create an instance of '{nameof(ApplicationUser)}'. " + + $"Ensure that '{nameof(ApplicationUser)}' is not an abstract class and has a parameterless constructor, or alternatively " + $"override the external login page in /Areas/Identity/Pages/Account/ExternalLogin.cshtml"); } } - private IUserEmailStore GetEmailStore() + private IUserEmailStore GetEmailStore() { if (!_userManager.SupportsUserEmail) { throw new NotSupportedException("The default UI requires a user store with email support."); } - return (IUserEmailStore)_userStore; + return (IUserEmailStore)_userStore; } } } diff --git a/DagoniteEmpire/Areas/Identity/Pages/Account/ForgotPassword.cshtml.cs b/DagoniteEmpire/Areas/Identity/Pages/Account/ForgotPassword.cshtml.cs index 3cc6f04..9a8a2ea 100644 --- a/DagoniteEmpire/Areas/Identity/Pages/Account/ForgotPassword.cshtml.cs +++ b/DagoniteEmpire/Areas/Identity/Pages/Account/ForgotPassword.cshtml.cs @@ -14,14 +14,15 @@ using Microsoft.AspNetCore.Mvc.RazorPages; using Microsoft.AspNetCore.WebUtilities; +using DA_DataAccess; namespace DagoniteEmpire.Areas.Identity.Pages.Account { public class ForgotPasswordModel : PageModel { - private readonly UserManager _userManager; + private readonly UserManager_userManager; private readonly IEmailSender _emailSender; - public ForgotPasswordModel(UserManager userManager, IEmailSender emailSender) + public ForgotPasswordModel(UserManageruserManager, IEmailSender emailSender) { _userManager = userManager; _emailSender = emailSender; diff --git a/DagoniteEmpire/Areas/Identity/Pages/Account/Login.cshtml.cs b/DagoniteEmpire/Areas/Identity/Pages/Account/Login.cshtml.cs index c988f99..e2bab35 100644 --- a/DagoniteEmpire/Areas/Identity/Pages/Account/Login.cshtml.cs +++ b/DagoniteEmpire/Areas/Identity/Pages/Account/Login.cshtml.cs @@ -15,15 +15,16 @@ using Microsoft.AspNetCore.Mvc.RazorPages; using Microsoft.Extensions.Logging; +using DA_DataAccess; namespace DagoniteEmpire.Areas.Identity.Pages.Account { public class LoginModel : PageModel { - private readonly SignInManager _signInManager; + private readonly SignInManager_signInManager; private readonly ILogger _logger; - private readonly UserManager _userManager; + private readonly UserManager_userManager; - public LoginModel(SignInManager signInManager, ILogger logger, UserManager userManager) + public LoginModel(SignInManagersignInManager, ILogger logger, UserManageruserManager) { _signInManager = signInManager; _logger = logger; diff --git a/DagoniteEmpire/Areas/Identity/Pages/Account/LoginWith2fa.cshtml.cs b/DagoniteEmpire/Areas/Identity/Pages/Account/LoginWith2fa.cshtml.cs index 42a8b92..22941db 100644 --- a/DagoniteEmpire/Areas/Identity/Pages/Account/LoginWith2fa.cshtml.cs +++ b/DagoniteEmpire/Areas/Identity/Pages/Account/LoginWith2fa.cshtml.cs @@ -12,17 +12,19 @@ using Microsoft.AspNetCore.Identity; using Microsoft.Extensions.Logging; +using DA_DataAccess; + namespace DagoniteEmpire.Areas.Identity.Pages.Account { public class LoginWith2faModel : PageModel { - private readonly SignInManager _signInManager; - private readonly UserManager _userManager; + private readonly SignInManager_signInManager; + private readonly UserManager_userManager; private readonly ILogger _logger; public LoginWith2faModel( - SignInManager signInManager, - UserManager userManager, + SignInManagersignInManager, + UserManageruserManager, ILogger logger) { _signInManager = signInManager; diff --git a/DagoniteEmpire/Areas/Identity/Pages/Account/LoginWithRecoveryCode.cshtml.cs b/DagoniteEmpire/Areas/Identity/Pages/Account/LoginWithRecoveryCode.cshtml.cs index 343a7c6..1b33ea5 100644 --- a/DagoniteEmpire/Areas/Identity/Pages/Account/LoginWithRecoveryCode.cshtml.cs +++ b/DagoniteEmpire/Areas/Identity/Pages/Account/LoginWithRecoveryCode.cshtml.cs @@ -10,17 +10,19 @@ using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.RazorPages; using Microsoft.Extensions.Logging; + +using DA_DataAccess; namespace DagoniteEmpire.Areas.Identity.Pages.Account { public class LoginWithRecoveryCodeModel : PageModel { - private readonly SignInManager _signInManager; - private readonly UserManager _userManager; + private readonly SignInManager_signInManager; + private readonly UserManager_userManager; private readonly ILogger _logger; public LoginWithRecoveryCodeModel( - SignInManager signInManager, - UserManager userManager, + SignInManagersignInManager, + UserManageruserManager, ILogger logger) { _signInManager = signInManager; diff --git a/DagoniteEmpire/Areas/Identity/Pages/Account/Logout.cshtml b/DagoniteEmpire/Areas/Identity/Pages/Account/Logout.cshtml index 1c97791..f504a5e 100644 --- a/DagoniteEmpire/Areas/Identity/Pages/Account/Logout.cshtml +++ b/DagoniteEmpire/Areas/Identity/Pages/Account/Logout.cshtml @@ -1,6 +1,6 @@ @page @using Microsoft.AspNetCore.Identity - @inject SignInManager _signInManager + @inject SignInManager _signInManager @functions{ public async Task OnGet() diff --git a/DagoniteEmpire/Areas/Identity/Pages/Account/Logout.cshtml.cs b/DagoniteEmpire/Areas/Identity/Pages/Account/Logout.cshtml.cs index 73d205c..d588a81 100644 --- a/DagoniteEmpire/Areas/Identity/Pages/Account/Logout.cshtml.cs +++ b/DagoniteEmpire/Areas/Identity/Pages/Account/Logout.cshtml.cs @@ -14,10 +14,10 @@ //{ // public class LogoutModel : PageModel // { -// private readonly SignInManager _signInManager; +// private readonly SignInManager_signInManager; // private readonly ILogger _logger; -// public LogoutModel(SignInManager signInManager, ILogger logger) +// public LogoutModel(SignInManagersignInManager, ILogger logger) // { // _signInManager = signInManager; // _logger = logger; diff --git a/DagoniteEmpire/Areas/Identity/Pages/Account/Manage/ChangePassword.cshtml.cs b/DagoniteEmpire/Areas/Identity/Pages/Account/Manage/ChangePassword.cshtml.cs index 5c535f4..b551104 100644 --- a/DagoniteEmpire/Areas/Identity/Pages/Account/Manage/ChangePassword.cshtml.cs +++ b/DagoniteEmpire/Areas/Identity/Pages/Account/Manage/ChangePassword.cshtml.cs @@ -10,17 +10,19 @@ using Microsoft.AspNetCore.Mvc.RazorPages; using Microsoft.Extensions.Logging; +using DA_DataAccess; + namespace DagoniteEmpire.Areas.Identity.Pages.Account.Manage { public class ChangePasswordModel : PageModel { - private readonly UserManager _userManager; - private readonly SignInManager _signInManager; + private readonly UserManager_userManager; + private readonly SignInManager_signInManager; private readonly ILogger _logger; public ChangePasswordModel( - UserManager userManager, - SignInManager signInManager, + UserManageruserManager, + SignInManagersignInManager, ILogger logger) { _userManager = userManager; diff --git a/DagoniteEmpire/Areas/Identity/Pages/Account/Manage/DeletePersonalData.cshtml.cs b/DagoniteEmpire/Areas/Identity/Pages/Account/Manage/DeletePersonalData.cshtml.cs index 7fc5845..be0d932 100644 --- a/DagoniteEmpire/Areas/Identity/Pages/Account/Manage/DeletePersonalData.cshtml.cs +++ b/DagoniteEmpire/Areas/Identity/Pages/Account/Manage/DeletePersonalData.cshtml.cs @@ -10,17 +10,19 @@ using Microsoft.AspNetCore.Mvc.RazorPages; using Microsoft.Extensions.Logging; +using DA_DataAccess; + namespace DagoniteEmpire.Areas.Identity.Pages.Account.Manage { public class DeletePersonalDataModel : PageModel { - private readonly UserManager _userManager; - private readonly SignInManager _signInManager; + private readonly UserManager_userManager; + private readonly SignInManager_signInManager; private readonly ILogger _logger; public DeletePersonalDataModel( - UserManager userManager, - SignInManager signInManager, + UserManageruserManager, + SignInManagersignInManager, ILogger logger) { _userManager = userManager; diff --git a/DagoniteEmpire/Areas/Identity/Pages/Account/Manage/Disable2fa.cshtml.cs b/DagoniteEmpire/Areas/Identity/Pages/Account/Manage/Disable2fa.cshtml.cs index 5510488..29afa8e 100644 --- a/DagoniteEmpire/Areas/Identity/Pages/Account/Manage/Disable2fa.cshtml.cs +++ b/DagoniteEmpire/Areas/Identity/Pages/Account/Manage/Disable2fa.cshtml.cs @@ -8,16 +8,17 @@ using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.RazorPages; using Microsoft.Extensions.Logging; +using DA_DataAccess; namespace DagoniteEmpire.Areas.Identity.Pages.Account.Manage { public class Disable2faModel : PageModel { - private readonly UserManager _userManager; + private readonly UserManager_userManager; private readonly ILogger _logger; public Disable2faModel( - UserManager userManager, + UserManageruserManager, ILogger logger) { _userManager = userManager; diff --git a/DagoniteEmpire/Areas/Identity/Pages/Account/Manage/DownloadPersonalData.cshtml.cs b/DagoniteEmpire/Areas/Identity/Pages/Account/Manage/DownloadPersonalData.cshtml.cs index 9aac15b..db9f184 100644 --- a/DagoniteEmpire/Areas/Identity/Pages/Account/Manage/DownloadPersonalData.cshtml.cs +++ b/DagoniteEmpire/Areas/Identity/Pages/Account/Manage/DownloadPersonalData.cshtml.cs @@ -12,16 +12,17 @@ using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.RazorPages; using Microsoft.Extensions.Logging; +using DA_DataAccess; namespace DagoniteEmpire.Areas.Identity.Pages.Account.Manage { public class DownloadPersonalDataModel : PageModel { - private readonly UserManager _userManager; + private readonly UserManager_userManager; private readonly ILogger _logger; public DownloadPersonalDataModel( - UserManager userManager, + UserManageruserManager, ILogger logger) { _userManager = userManager; diff --git a/DagoniteEmpire/Areas/Identity/Pages/Account/Manage/Email.cshtml.cs b/DagoniteEmpire/Areas/Identity/Pages/Account/Manage/Email.cshtml.cs index a6e1502..8e6855a 100644 --- a/DagoniteEmpire/Areas/Identity/Pages/Account/Manage/Email.cshtml.cs +++ b/DagoniteEmpire/Areas/Identity/Pages/Account/Manage/Email.cshtml.cs @@ -12,18 +12,19 @@ using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.RazorPages; using Microsoft.AspNetCore.WebUtilities; +using DA_DataAccess; namespace DagoniteEmpire.Areas.Identity.Pages.Account.Manage { public class EmailModel : PageModel { - private readonly UserManager _userManager; - private readonly SignInManager _signInManager; + private readonly UserManager_userManager; + private readonly SignInManager_signInManager; private readonly IEmailSender _emailSender; public EmailModel( - UserManager userManager, - SignInManager signInManager, + UserManageruserManager, + SignInManagersignInManager, IEmailSender emailSender) { _userManager = userManager; @@ -73,7 +74,7 @@ public class InputModel public string NewEmail { get; set; } } - private async Task LoadAsync(IdentityUser user) + private async Task LoadAsync(ApplicationUser user) { var email = await _userManager.GetEmailAsync(user); Email = email; diff --git a/DagoniteEmpire/Areas/Identity/Pages/Account/Manage/EnableAuthenticator.cshtml.cs b/DagoniteEmpire/Areas/Identity/Pages/Account/Manage/EnableAuthenticator.cshtml.cs index 43704db..d479d06 100644 --- a/DagoniteEmpire/Areas/Identity/Pages/Account/Manage/EnableAuthenticator.cshtml.cs +++ b/DagoniteEmpire/Areas/Identity/Pages/Account/Manage/EnableAuthenticator.cshtml.cs @@ -13,19 +13,20 @@ using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.RazorPages; using Microsoft.Extensions.Logging; +using DA_DataAccess; namespace DagoniteEmpire.Areas.Identity.Pages.Account.Manage { public class EnableAuthenticatorModel : PageModel { - private readonly UserManager _userManager; + private readonly UserManager_userManager; private readonly ILogger _logger; private readonly UrlEncoder _urlEncoder; private const string AuthenticatorUriFormat = "otpauth://totp/{0}:{1}?secret={2}&issuer={0}&digits=6"; public EnableAuthenticatorModel( - UserManager userManager, + UserManageruserManager, ILogger logger, UrlEncoder urlEncoder) { @@ -142,7 +143,7 @@ public async Task OnPostAsync() } } - private async Task LoadSharedKeyAndQrCodeUriAsync(IdentityUser user) + private async Task LoadSharedKeyAndQrCodeUriAsync(ApplicationUser user) { // Load the authenticator key & QR code URI to display on the form var unformattedKey = await _userManager.GetAuthenticatorKeyAsync(user); diff --git a/DagoniteEmpire/Areas/Identity/Pages/Account/Manage/ExternalLogins.cshtml.cs b/DagoniteEmpire/Areas/Identity/Pages/Account/Manage/ExternalLogins.cshtml.cs index a92e842..b7a3ab8 100644 --- a/DagoniteEmpire/Areas/Identity/Pages/Account/Manage/ExternalLogins.cshtml.cs +++ b/DagoniteEmpire/Areas/Identity/Pages/Account/Manage/ExternalLogins.cshtml.cs @@ -11,18 +11,19 @@ using Microsoft.AspNetCore.Identity; using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.RazorPages; +using DA_DataAccess; namespace DagoniteEmpire.Areas.Identity.Pages.Account.Manage { public class ExternalLoginsModel : PageModel { - private readonly UserManager _userManager; - private readonly SignInManager _signInManager; + private readonly UserManager_userManager; + private readonly SignInManager_signInManager; private readonly IUserStore _userStore; public ExternalLoginsModel( - UserManager userManager, - SignInManager signInManager, + UserManageruserManager, + SignInManagersignInManager, IUserStore userStore) { _userManager = userManager; diff --git a/DagoniteEmpire/Areas/Identity/Pages/Account/Manage/GenerateRecoveryCodes.cshtml.cs b/DagoniteEmpire/Areas/Identity/Pages/Account/Manage/GenerateRecoveryCodes.cshtml.cs index 1797cca..721ee03 100644 --- a/DagoniteEmpire/Areas/Identity/Pages/Account/Manage/GenerateRecoveryCodes.cshtml.cs +++ b/DagoniteEmpire/Areas/Identity/Pages/Account/Manage/GenerateRecoveryCodes.cshtml.cs @@ -9,16 +9,17 @@ using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.RazorPages; using Microsoft.Extensions.Logging; +using DA_DataAccess; namespace DagoniteEmpire.Areas.Identity.Pages.Account.Manage { public class GenerateRecoveryCodesModel : PageModel { - private readonly UserManager _userManager; + private readonly UserManager_userManager; private readonly ILogger _logger; public GenerateRecoveryCodesModel( - UserManager userManager, + UserManageruserManager, ILogger logger) { _userManager = userManager; diff --git a/DagoniteEmpire/Areas/Identity/Pages/Account/Manage/Index.cshtml.cs b/DagoniteEmpire/Areas/Identity/Pages/Account/Manage/Index.cshtml.cs index d3fb957..959154d 100644 --- a/DagoniteEmpire/Areas/Identity/Pages/Account/Manage/Index.cshtml.cs +++ b/DagoniteEmpire/Areas/Identity/Pages/Account/Manage/Index.cshtml.cs @@ -9,17 +9,18 @@ using Microsoft.AspNetCore.Identity; using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.RazorPages; +using DA_DataAccess; namespace DagoniteEmpire.Areas.Identity.Pages.Account.Manage { public class IndexModel : PageModel { - private readonly UserManager _userManager; - private readonly SignInManager _signInManager; + private readonly UserManager_userManager; + private readonly SignInManager_signInManager; public IndexModel( - UserManager userManager, - SignInManager signInManager) + UserManageruserManager, + SignInManagersignInManager) { _userManager = userManager; _signInManager = signInManager; @@ -60,7 +61,7 @@ public class InputModel public string PhoneNumber { get; set; } } - private async Task LoadAsync(IdentityUser user) + private async Task LoadAsync(ApplicationUser user) { var userName = await _userManager.GetUserNameAsync(user); var phoneNumber = await _userManager.GetPhoneNumberAsync(user); diff --git a/DagoniteEmpire/Areas/Identity/Pages/Account/Manage/PersonalData.cshtml.cs b/DagoniteEmpire/Areas/Identity/Pages/Account/Manage/PersonalData.cshtml.cs index fe07622..52b3521 100644 --- a/DagoniteEmpire/Areas/Identity/Pages/Account/Manage/PersonalData.cshtml.cs +++ b/DagoniteEmpire/Areas/Identity/Pages/Account/Manage/PersonalData.cshtml.cs @@ -6,16 +6,17 @@ using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.RazorPages; using Microsoft.Extensions.Logging; +using DA_DataAccess; namespace DagoniteEmpire.Areas.Identity.Pages.Account.Manage { public class PersonalDataModel : PageModel { - private readonly UserManager _userManager; + private readonly UserManager_userManager; private readonly ILogger _logger; public PersonalDataModel( - UserManager userManager, + UserManageruserManager, ILogger logger) { _userManager = userManager; diff --git a/DagoniteEmpire/Areas/Identity/Pages/Account/Manage/ResetAuthenticator.cshtml.cs b/DagoniteEmpire/Areas/Identity/Pages/Account/Manage/ResetAuthenticator.cshtml.cs index a0aeb6c..d26e74e 100644 --- a/DagoniteEmpire/Areas/Identity/Pages/Account/Manage/ResetAuthenticator.cshtml.cs +++ b/DagoniteEmpire/Areas/Identity/Pages/Account/Manage/ResetAuthenticator.cshtml.cs @@ -8,18 +8,19 @@ using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.RazorPages; using Microsoft.Extensions.Logging; +using DA_DataAccess; namespace DagoniteEmpire.Areas.Identity.Pages.Account.Manage { public class ResetAuthenticatorModel : PageModel { - private readonly UserManager _userManager; - private readonly SignInManager _signInManager; + private readonly UserManager_userManager; + private readonly SignInManager_signInManager; private readonly ILogger _logger; public ResetAuthenticatorModel( - UserManager userManager, - SignInManager signInManager, + UserManageruserManager, + SignInManagersignInManager, ILogger logger) { _userManager = userManager; diff --git a/DagoniteEmpire/Areas/Identity/Pages/Account/Manage/SetPassword.cshtml.cs b/DagoniteEmpire/Areas/Identity/Pages/Account/Manage/SetPassword.cshtml.cs index deeaa6a..59e9c8e 100644 --- a/DagoniteEmpire/Areas/Identity/Pages/Account/Manage/SetPassword.cshtml.cs +++ b/DagoniteEmpire/Areas/Identity/Pages/Account/Manage/SetPassword.cshtml.cs @@ -8,17 +8,18 @@ using Microsoft.AspNetCore.Identity; using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.RazorPages; +using DA_DataAccess; namespace DagoniteEmpire.Areas.Identity.Pages.Account.Manage { public class SetPasswordModel : PageModel { - private readonly UserManager _userManager; - private readonly SignInManager _signInManager; + private readonly UserManager_userManager; + private readonly SignInManager_signInManager; public SetPasswordModel( - UserManager userManager, - SignInManager signInManager) + UserManageruserManager, + SignInManagersignInManager) { _userManager = userManager; _signInManager = signInManager; diff --git a/DagoniteEmpire/Areas/Identity/Pages/Account/Manage/TwoFactorAuthentication.cshtml.cs b/DagoniteEmpire/Areas/Identity/Pages/Account/Manage/TwoFactorAuthentication.cshtml.cs index 7b2ff13..86d132d 100644 --- a/DagoniteEmpire/Areas/Identity/Pages/Account/Manage/TwoFactorAuthentication.cshtml.cs +++ b/DagoniteEmpire/Areas/Identity/Pages/Account/Manage/TwoFactorAuthentication.cshtml.cs @@ -8,17 +8,18 @@ using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.RazorPages; using Microsoft.Extensions.Logging; +using DA_DataAccess; namespace DagoniteEmpire.Areas.Identity.Pages.Account.Manage { public class TwoFactorAuthenticationModel : PageModel { - private readonly UserManager _userManager; - private readonly SignInManager _signInManager; + private readonly UserManager_userManager; + private readonly SignInManager_signInManager; private readonly ILogger _logger; public TwoFactorAuthenticationModel( - UserManager userManager, SignInManager signInManager, ILogger logger) + UserManageruserManager, SignInManagersignInManager, ILogger logger) { _userManager = userManager; _signInManager = signInManager; diff --git a/DagoniteEmpire/Areas/Identity/Pages/Account/Manage/_ManageNav.cshtml b/DagoniteEmpire/Areas/Identity/Pages/Account/Manage/_ManageNav.cshtml index 59b1bb1..d58ebc4 100644 --- a/DagoniteEmpire/Areas/Identity/Pages/Account/Manage/_ManageNav.cshtml +++ b/DagoniteEmpire/Areas/Identity/Pages/Account/Manage/_ManageNav.cshtml @@ -1,4 +1,4 @@ -@inject SignInManager SignInManager +@inject SignInManager SignInManager @{ var hasExternalLogins = (await SignInManager.GetExternalAuthenticationSchemesAsync()).Any(); } diff --git a/DagoniteEmpire/Areas/Identity/Pages/Account/Register.cshtml.cs b/DagoniteEmpire/Areas/Identity/Pages/Account/Register.cshtml.cs index 6f1237f..5588503 100644 --- a/DagoniteEmpire/Areas/Identity/Pages/Account/Register.cshtml.cs +++ b/DagoniteEmpire/Areas/Identity/Pages/Account/Register.cshtml.cs @@ -21,24 +21,25 @@ using Microsoft.AspNetCore.WebUtilities; using Microsoft.Extensions.Logging; using static System.Runtime.InteropServices.JavaScript.JSType; +using DA_DataAccess; namespace DagoniteEmpire.Areas.Identity.Pages.Account { public class RegisterModel : PageModel { - private readonly SignInManager _signInManager; - private readonly UserManager _userManager; - private readonly IUserStore _userStore; - private readonly IUserEmailStore _emailStore; + private readonly SignInManager_signInManager; + private readonly UserManager_userManager; + private readonly IUserStore _userStore; + private readonly IUserEmailStore _emailStore; private readonly ILogger _logger; private readonly IEmailSender _emailSender; private readonly RoleManager _roleManager; public RegisterModel( - UserManager userManager, - IUserStore userStore, - SignInManager signInManager, + UserManageruserManager, + IUserStore userStore, + SignInManagersignInManager, ILogger logger, IEmailSender emailSender, RoleManager roleManager) @@ -182,27 +183,27 @@ await _emailSender.SendEmailAsync(Input.Email, "Confirm your email", return Page(); } - private IdentityUser CreateUser() + private ApplicationUser CreateUser() { try { - return Activator.CreateInstance(); + return Activator.CreateInstance(); } catch { - throw new InvalidOperationException($"Can't create an instance of '{nameof(IdentityUser)}'. " + - $"Ensure that '{nameof(IdentityUser)}' is not an abstract class and has a parameterless constructor, or alternatively " + + throw new InvalidOperationException($"Can't create an instance of '{nameof(ApplicationUser)}'. " + + $"Ensure that '{nameof(ApplicationUser)}' is not an abstract class and has a parameterless constructor, or alternatively " + $"override the register page in /Areas/Identity/Pages/Account/Register.cshtml"); } } - private IUserEmailStore GetEmailStore() + private IUserEmailStore GetEmailStore() { if (!_userManager.SupportsUserEmail) { throw new NotSupportedException("The default UI requires a user store with email support."); } - return (IUserEmailStore)_userStore; + return (IUserEmailStore)_userStore; } } } diff --git a/DagoniteEmpire/Areas/Identity/Pages/Account/RegisterConfirmation.cshtml.cs b/DagoniteEmpire/Areas/Identity/Pages/Account/RegisterConfirmation.cshtml.cs index b9ad89c..09c5428 100644 --- a/DagoniteEmpire/Areas/Identity/Pages/Account/RegisterConfirmation.cshtml.cs +++ b/DagoniteEmpire/Areas/Identity/Pages/Account/RegisterConfirmation.cshtml.cs @@ -11,16 +11,17 @@ using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.RazorPages; using Microsoft.AspNetCore.WebUtilities; +using DA_DataAccess; namespace DagoniteEmpire.Areas.Identity.Pages.Account { [AllowAnonymous] public class RegisterConfirmationModel : PageModel { - private readonly UserManager _userManager; + private readonly UserManager_userManager; private readonly IEmailSender _sender; - public RegisterConfirmationModel(UserManager userManager, IEmailSender sender) + public RegisterConfirmationModel(UserManageruserManager, IEmailSender sender) { _userManager = userManager; _sender = sender; diff --git a/DagoniteEmpire/Areas/Identity/Pages/Account/ResendEmailConfirmation.cshtml.cs b/DagoniteEmpire/Areas/Identity/Pages/Account/ResendEmailConfirmation.cshtml.cs index 899d002..5cdb65e 100644 --- a/DagoniteEmpire/Areas/Identity/Pages/Account/ResendEmailConfirmation.cshtml.cs +++ b/DagoniteEmpire/Areas/Identity/Pages/Account/ResendEmailConfirmation.cshtml.cs @@ -13,16 +13,17 @@ using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.RazorPages; using Microsoft.AspNetCore.WebUtilities; +using DA_DataAccess; namespace DagoniteEmpire.Areas.Identity.Pages.Account { [AllowAnonymous] public class ResendEmailConfirmationModel : PageModel { - private readonly UserManager _userManager; + private readonly UserManager_userManager; private readonly IEmailSender _emailSender; - public ResendEmailConfirmationModel(UserManager userManager, IEmailSender emailSender) + public ResendEmailConfirmationModel(UserManageruserManager, IEmailSender emailSender) { _userManager = userManager; _emailSender = emailSender; diff --git a/DagoniteEmpire/Areas/Identity/Pages/Account/ResetPassword.cshtml.cs b/DagoniteEmpire/Areas/Identity/Pages/Account/ResetPassword.cshtml.cs index 9735d61..717c3d7 100644 --- a/DagoniteEmpire/Areas/Identity/Pages/Account/ResetPassword.cshtml.cs +++ b/DagoniteEmpire/Areas/Identity/Pages/Account/ResetPassword.cshtml.cs @@ -11,14 +11,15 @@ using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.RazorPages; using Microsoft.AspNetCore.WebUtilities; +using DA_DataAccess; namespace DagoniteEmpire.Areas.Identity.Pages.Account { public class ResetPasswordModel : PageModel { - private readonly UserManager _userManager; + private readonly UserManager_userManager; - public ResetPasswordModel(UserManager userManager) + public ResetPasswordModel(UserManageruserManager) { _userManager = userManager; } diff --git a/DagoniteEmpire/Areas/Identity/Pages/_ViewImports.cshtml b/DagoniteEmpire/Areas/Identity/Pages/_ViewImports.cshtml index 1e192ab..be2d8aa 100644 --- a/DagoniteEmpire/Areas/Identity/Pages/_ViewImports.cshtml +++ b/DagoniteEmpire/Areas/Identity/Pages/_ViewImports.cshtml @@ -1,4 +1,5 @@ @using Microsoft.AspNetCore.Identity @using DagoniteEmpire.Areas.Identity @using DagoniteEmpire.Areas.Identity.Pages +@using DA_DataAccess @addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers diff --git a/DagoniteEmpire/DagoniteEmpire.csproj b/DagoniteEmpire/DagoniteEmpire.csproj index d370b0b..8015f7a 100644 --- a/DagoniteEmpire/DagoniteEmpire.csproj +++ b/DagoniteEmpire/DagoniteEmpire.csproj @@ -29,6 +29,7 @@ + all diff --git a/DagoniteEmpire/Helper/IJSRuntimeExtension.cs b/DagoniteEmpire/Helper/IJSRuntimeExtension.cs index 96a80c0..ecc57b0 100644 --- a/DagoniteEmpire/Helper/IJSRuntimeExtension.cs +++ b/DagoniteEmpire/Helper/IJSRuntimeExtension.cs @@ -39,6 +39,11 @@ public static async ValueTask SweetAlertFailure(this IJSRuntime jsRuntime, strin await jsRuntime.InvokeVoidAsync("ShowSweetAlert", "error", message); } + public static async ValueTask ScrollToBottom(this IJSRuntime jsRuntime, string container) + { + await jsRuntime.InvokeVoidAsync("ScrollToBottom", container); + } + } } diff --git a/DagoniteEmpire/Pages/Chat/Chat.razor b/DagoniteEmpire/Pages/Chat/Chat.razor new file mode 100644 index 0000000..52b39b6 --- /dev/null +++ b/DagoniteEmpire/Pages/Chat/Chat.razor @@ -0,0 +1,226 @@ +@page "/chat/{ContactId}" +@page "/chat" +@using Microsoft.AspNetCore.SignalR.Client +@inject IChatManager _chatManager +@inject IJSRuntime _jsRuntime +@inject NavigationManager _navigationManager +@inject AuthenticationStateProvider _stateProvider + +@attribute [Authorize(Roles = SD.Role_Admin + "," + SD.Role_HeroPlayer + "," + SD.Role_DukePlayer + "," + SD.Role_GameMaster)] + +
+ + + @if (string.IsNullOrEmpty(ContactId)) + { + + chat + } + else + { + + @ContactEmail + } + +
+ @foreach (var message in messages) + { + @if (message.FromUser.Email == CurrentUserEmail) + { +
+
+ @message.FromUser.Email.ToUpper().FirstOrDefault() +
+
+ @message.FromUser.Email + @message.CreatedDate.ToString("dd MMM, yyyy hh:mm tt") + @message.Message +
+
+ } + else + { +
+
+ @message.FromUser.Email.ToUpper().FirstOrDefault() +
+
+ @message.FromUser.Email + @message.CreatedDate.ToString("dd MMM, yyyy hh:mm tt") + @message.Message +
+
+ } + + + } +
+ + + Send + +
+ + + # + contacts + +
+ + @foreach (var user in ChatUsers) + { + +
+
+ + @if (user.Id == ContactId) + { + @user.Email.ToUpper().FirstOrDefault() + } + else + { + @user.Email.ToUpper().FirstOrDefault() + } + +
+
+ @user.Email@* + @user.Id *@ +
+
+
+ } +
+
+
+
+ +@code{ + [CascadingParameter] public HubConnection hubConnection { get; set; } + [Parameter] public string CurrentMessage { get; set; } + [Parameter] public string CurrentUserId { get; set; } + [Parameter] public string CurrentUserEmail { get; set; } + + MudTextField ChatTextField = new(); + private string HubUrl; + private List messages = new List(); + private async Task SubmitAsync() + { + if(IsUserChosen==false) + return; + if (!string.IsNullOrEmpty(CurrentMessage) && !string.IsNullOrEmpty(ContactId)) + { + //Save Message to DB + + var chatHistory = new ChatMessage() + { + Message = CurrentMessage, + ToUserId = ContactId, + CreatedDate = DateTime.Now + + }; + + chatHistory.FromUserId = CurrentUserId; + await hubConnection.SendAsync("SendMessage", CurrentUserEmail, chatHistory); + CurrentMessage = string.Empty; + await _chatManager.SaveMessageAsync(chatHistory); + + } + } + protected override async Task OnAfterRenderAsync(bool firstRender) + { + await _jsRuntime.ScrollToBottom("chatContainer"); + } + protected override async Task OnInitializedAsync() + { + try + { + if (hubConnection == null) + { + hubConnection = new HubConnectionBuilder().WithUrl(_navigationManager.ToAbsoluteUri(ChatHub.HubUrl)).Build(); + } + if (hubConnection.State == HubConnectionState.Disconnected) + { + await hubConnection.StartAsync(); + } + + hubConnection.On("SendMessage", ReceiveMessage); + + await GetUsersAsync(); + var state = await _stateProvider.GetAuthenticationStateAsync(); + var user = state.User; + CurrentUserId = user.FindFirst(u => u.Type.Contains("nameidentifier"))?.Value; + CurrentUserEmail = user.FindFirst(u => u.Type.Contains("emailaddress"))?.Value; + if (!string.IsNullOrEmpty(ContactId)) + { + await LoadUserChat(ContactId); + } + + // await SendAsync($"[Notice] {_username} joined chat room."); + } + catch (Exception e) + { + ; + // _message = $"ERROR: Failed to start chat client: {e.Message}"; + // _isChatting = false; + } + + } + + private async Task ReceiveMessage(string name, ChatMessage message) + { + if ((ContactId == message.ToUserId && CurrentUserId == message.FromUserId) || (ContactId == message.FromUserId && CurrentUserId == message.ToUserId)) + { + + if ((ContactId == message.ToUserId && CurrentUserId == message.FromUserId)) + { + messages.Add(new ChatMessage { Message = message.Message, CreatedDate = message.CreatedDate, FromUser = new ApplicationUser() { Email = CurrentUserEmail } }); + //await hubConnection.SendAsync("ChatNotificationAsync", $"New Message From {name}", ContactId, CurrentUserId); + } + else if ((ContactId == message.FromUserId && CurrentUserId == message.ToUserId)) + { + messages.Add(new ChatMessage { Message = message.Message, CreatedDate = message.CreatedDate, FromUser = new ApplicationUser() { Email = ContactEmail } }); + } + await _jsRuntime.ScrollToBottom("chatContainer"); + // Inform blazor the UI needs updating + InvokeAsync(StateHasChanged); + } + } + + public async Task Enter(KeyboardEventArgs e) + { + if (e.Code == "Enter" || e.Code == "NumpadEnter") + { + ChatTextField.TextUpdateSuppression = false; + await SubmitAsync(); + CurrentMessage = string.Empty; + StateHasChanged(); + await Task.Run(async () => + { + await Task.Delay(150); + ChatTextField.TextUpdateSuppression = true; + }); + } + } + + public List ChatUsers = new List(); + [Parameter] public string ContactEmail { get; set; } + [Parameter] public string ContactId { get; set; } + private bool IsUserChosen { get; set; } = false; + async Task LoadUserChat(string userId) + { + var contact = await _chatManager.GetUserDetailsAsync(userId); + ContactId = contact.Id; + ContactEmail = contact.Email; + _navigationManager.NavigateTo($"chat/{ContactId}"); + messages = new List(); + messages = await _chatManager.GetConversationAsync(ContactId); + IsUserChosen = true; + } + private async Task GetUsersAsync() + { + ChatUsers = await _chatManager.GetUsersAsync(); + } + + } \ No newline at end of file diff --git a/DagoniteEmpire/Pages/Chat/ChatRoom.Razor.css b/DagoniteEmpire/Pages/Chat/ChatRoom.Razor.css new file mode 100644 index 0000000..59d3f92 --- /dev/null +++ b/DagoniteEmpire/Pages/Chat/ChatRoom.Razor.css @@ -0,0 +1,63 @@ +/* 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 new file mode 100644 index 0000000..70788db --- /dev/null +++ b/DagoniteEmpire/Pages/Chat/ChatRoom.razor @@ -0,0 +1,173 @@ +@* +@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/EquipmentComponent.razor.css b/DagoniteEmpire/Pages/Components/EquipmentComponent.razor.css index c528092..c4cba54 100644 --- a/DagoniteEmpire/Pages/Components/EquipmentComponent.razor.css +++ b/DagoniteEmpire/Pages/Components/EquipmentComponent.razor.css @@ -69,6 +69,7 @@ h3 { .table-container { width: 100%; flex: 2; + min-height: 400px; } .carret { diff --git a/DagoniteEmpire/Pages/Components/TraitsComponent.razor b/DagoniteEmpire/Pages/Components/TraitsComponent.razor index 711422e..a6e095c 100644 --- a/DagoniteEmpire/Pages/Components/TraitsComponent.razor +++ b/DagoniteEmpire/Pages/Components/TraitsComponent.razor @@ -100,6 +100,7 @@ TraitsChanged.InvokeAsync(Traits); OnTraitsChange.InvokeAsync(); + CalculateTraitBalance(); } if (_customTraitComponent == value) return; _customTraitComponent = value; @@ -123,6 +124,7 @@ } TraitsChanged.InvokeAsync(Traits); OnTraitsChange.InvokeAsync(); + CalculateTraitBalance(); } if (_traitsChosen == value) return; _traitsChosen = value; @@ -134,14 +136,14 @@ CustomTraitComponent.TraitDTO = new(); CustomTraitComponent.IsVisible = true; CustomTraitComponent.IsEditMode = false; - StateHasChanged(); + //CalculateTraitBalance(); } private async Task AddExistingTrait() { TraitsChosen = new(); TraitsChosen.IsVisible = true; TraitsChosen.TraitType = TraitType; - StateHasChanged(); + //CalculateTraitBalance(); } private async Task EditTrait(TraitDTO trait) @@ -149,9 +151,18 @@ CustomTraitComponent.TraitDTO = trait; CustomTraitComponent.IsVisible = true; CustomTraitComponent.IsEditMode = true; - StateHasChanged(); + CalculateTraitBalance(); } + private async Task CalculateTraitBalance() + { + AllParams.Character.TraitBalance = 0; + foreach (var trait in Traits) + { + AllParams.Character.TraitBalance += trait.TraitValue; + } + StateHasChanged(); + } private async Task DeleteTrait(TraitDTO trait) { @@ -171,6 +182,6 @@ } Traits = Traits.Where(u => u.Name != trait.Name).ToList(); await TraitsChanged.InvokeAsync(Traits); - StateHasChanged(); + CalculateTraitBalance(); } } diff --git a/DagoniteEmpire/Pages/Dialogs/CharDescriptionDialog.razor.css b/DagoniteEmpire/Pages/Dialogs/CharDescriptionDialog.razor.css index 11745e2..4492616 100644 --- a/DagoniteEmpire/Pages/Dialogs/CharDescriptionDialog.razor.css +++ b/DagoniteEmpire/Pages/Dialogs/CharDescriptionDialog.razor.css @@ -22,6 +22,7 @@ flex: 2; padding: 0; margin: 0; + min-height: 400px; } h3 { diff --git a/DagoniteEmpire/Pages/Shared/_LoginPartial.cshtml b/DagoniteEmpire/Pages/Shared/_LoginPartial.cshtml index 4131f9a..e4324ce 100644 --- a/DagoniteEmpire/Pages/Shared/_LoginPartial.cshtml +++ b/DagoniteEmpire/Pages/Shared/_LoginPartial.cshtml @@ -1,7 +1,8 @@ -@using Microsoft.AspNetCore.Identity +@using DA_DataAccess +@using Microsoft.AspNetCore.Identity -@inject SignInManager SignInManager -@inject UserManager UserManager +@inject SignInManager SignInManager +@inject UserManager UserManager