From b377937f37ac13975c47b1aa42718c82c7676bfe Mon Sep 17 00:00:00 2001 From: krystian kempski Date: Mon, 20 May 2024 22:50:39 +0200 Subject: [PATCH] Update of chat --- .../Repository/ChatRepos/ChatManager.cs | 49 +- .../ChatRepos/IRepository/IChatManager.cs | 4 + DA_DataAccess/ApplicationUser.cs | 3 +- DA_DataAccess/Chat/ChatMessage.cs | 2 + .../20240501195333_addEquipment.Designer.cs | 1010 ---------------- .../20240502004056_addEquipment2.Designer.cs | 1016 ---------------- .../20240502004056_addEquipment2.cs | 40 - .../20240505205317_addItemCount.Designer.cs | 1019 ---------------- ...6142843_addEquipmentShortDescr.Designer.cs | 1023 ----------------- .../20240506142843_addEquipmentShortDescr.cs | 29 - .../Migrations/20240507163528_AddChat.cs | 59 - .../20240507224949_addApplicationUser.cs | 22 - ...517125003_addchatnotification.Designer.cs} | 12 +- ... => 20240517125003_addchatnotification.cs} | 47 +- ... => 20240519204653_chatupdate.Designer.cs} | 15 +- ...mCount.cs => 20240519204653_chatupdate.cs} | 16 +- .../ApplicationDbContextModelSnapshot.cs | 11 +- .../Pages/CharacterPages/CharacterList.razor | 23 +- .../CharacterPages/CharacterUpsert.razor | 14 +- DagoniteEmpire/Pages/Chat/Chat.razor | 12 +- DagoniteEmpire/Shared/Chat.Razor.css | 51 + DagoniteEmpire/Shared/Chat.razor | 434 ++++--- DagoniteEmpire/Shared/MainLayout.razor | 322 +----- 23 files changed, 534 insertions(+), 4699 deletions(-) delete mode 100644 DA_DataAccess/Migrations/20240501195333_addEquipment.Designer.cs delete mode 100644 DA_DataAccess/Migrations/20240502004056_addEquipment2.Designer.cs delete mode 100644 DA_DataAccess/Migrations/20240502004056_addEquipment2.cs delete mode 100644 DA_DataAccess/Migrations/20240505205317_addItemCount.Designer.cs delete mode 100644 DA_DataAccess/Migrations/20240506142843_addEquipmentShortDescr.Designer.cs delete mode 100644 DA_DataAccess/Migrations/20240506142843_addEquipmentShortDescr.cs delete mode 100644 DA_DataAccess/Migrations/20240507163528_AddChat.cs delete mode 100644 DA_DataAccess/Migrations/20240507224949_addApplicationUser.cs rename DA_DataAccess/Migrations/{20240507163528_AddChat.Designer.cs => 20240517125003_addchatnotification.Designer.cs} (99%) rename DA_DataAccess/Migrations/{20240501195333_addEquipment.cs => 20240517125003_addchatnotification.cs} (93%) rename DA_DataAccess/Migrations/{20240507224949_addApplicationUser.Designer.cs => 20240519204653_chatupdate.Designer.cs} (98%) rename DA_DataAccess/Migrations/{20240505205317_addItemCount.cs => 20240519204653_chatupdate.cs} (59%) create mode 100644 DagoniteEmpire/Shared/Chat.Razor.css diff --git a/DA_Business/Repository/ChatRepos/ChatManager.cs b/DA_Business/Repository/ChatRepos/ChatManager.cs index 72575d8..319f4f8 100644 --- a/DA_Business/Repository/ChatRepos/ChatManager.cs +++ b/DA_Business/Repository/ChatRepos/ChatManager.cs @@ -49,26 +49,41 @@ public async Task> GetConversationAsync(string contactId) Id = x.Id, ToUserId = x.ToUserId, ToUser = x.ToUser, - FromUser = x.FromUser + FromUser = x.FromUser, + IsRead = x.IsRead }).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 UpdateUserDetailsAsync(ApplicationUser updatedUser) + { + using var contex = await _db.CreateDbContextAsync(); + var user = await contex.ApplicationUsers.Include(c=>c.ChatMessagesFromUsers).Include(u=>u.ChatMessagesToUsers).FirstOrDefaultAsync(u => u.Id == updatedUser.Id); + + // Update built-in type members + if (user is not null) + { + contex.Entry(user).CurrentValues.SetValues(updatedUser); + var addedObj = contex.ApplicationUsers.Update(user); + await contex.SaveChangesAsync(); + } + + return 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(); + var allUsers = _userManager.Users.Include(t=>t.ChatMessagesFromUsers).Include(t=>t.ChatMessagesToUsers).Where(user => user.Id != userId).ToListAsync(); return await allUsers; } @@ -93,5 +108,31 @@ public async Task SaveMessageAsync(ChatMessage message) } } + + public async Task MakeMessageRedAsync(string contactId) + { + 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(); + + var messages = await contex.ChatMessages + .Where(h => ((h.FromUserId == contactId && h.ToUserId == userId) || (h.FromUserId == userId && h.ToUserId == contactId) && h.IsRead == false)).ToListAsync(); + + foreach (var item in messages) + { + item.IsRead = true; + contex.ChatMessages.Update(item); + } + await contex.SaveChangesAsync(); + + } + catch (Exception ex) + { + ; + } + + } } } diff --git a/DA_Business/Repository/ChatRepos/IRepository/IChatManager.cs b/DA_Business/Repository/ChatRepos/IRepository/IChatManager.cs index 28d0975..4998ebf 100644 --- a/DA_Business/Repository/ChatRepos/IRepository/IChatManager.cs +++ b/DA_Business/Repository/ChatRepos/IRepository/IChatManager.cs @@ -15,5 +15,9 @@ public interface IChatManager Task SaveMessageAsync(ChatMessage message); Task> GetConversationAsync(string contactId); Task GetUserDetailsAsync(string userId); + + Task UpdateUserDetailsAsync(ApplicationUser updatedUser); + + Task MakeMessageRedAsync(string contactId); } } diff --git a/DA_DataAccess/ApplicationUser.cs b/DA_DataAccess/ApplicationUser.cs index 2c87778..2f339b3 100644 --- a/DA_DataAccess/ApplicationUser.cs +++ b/DA_DataAccess/ApplicationUser.cs @@ -18,6 +18,7 @@ public ApplicationUser() ChatMessagesFromUsers = new HashSet(); ChatMessagesToUsers = new HashSet(); } - + public bool ShowBadge { get; set; } = false; + public int? BadgeContent { get; set; } = null; } } diff --git a/DA_DataAccess/Chat/ChatMessage.cs b/DA_DataAccess/Chat/ChatMessage.cs index 51f838d..87061c2 100644 --- a/DA_DataAccess/Chat/ChatMessage.cs +++ b/DA_DataAccess/Chat/ChatMessage.cs @@ -17,5 +17,7 @@ public class ChatMessage public virtual ApplicationUser FromUser { get; set; } public virtual ApplicationUser ToUser { get; set; } public bool IsNotice => Message.StartsWith("[Notice]"); + + public bool IsRead { get; set; } = false; } } diff --git a/DA_DataAccess/Migrations/20240501195333_addEquipment.Designer.cs b/DA_DataAccess/Migrations/20240501195333_addEquipment.Designer.cs deleted file mode 100644 index b6d2705..0000000 --- a/DA_DataAccess/Migrations/20240501195333_addEquipment.Designer.cs +++ /dev/null @@ -1,1010 +0,0 @@ -// -using System; -using DA_DataAccess.Data; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; - -#nullable disable - -namespace DA_DataAccess.Migrations -{ - [DbContext(typeof(ApplicationDbContext))] - [Migration("20240501195333_addEquipment")] - partial class addEquipment - { - /// - 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("Description") - .IsRequired() - .HasColumnType("text"); - - b.Property("Index") - .HasColumnType("integer"); - - b.Property("IsApproved") - .HasColumnType("boolean"); - - b.Property("Name") - .IsRequired() - .HasColumnType("text"); - - 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.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("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"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/DA_DataAccess/Migrations/20240502004056_addEquipment2.Designer.cs b/DA_DataAccess/Migrations/20240502004056_addEquipment2.Designer.cs deleted file mode 100644 index 72c7588..0000000 --- a/DA_DataAccess/Migrations/20240502004056_addEquipment2.Designer.cs +++ /dev/null @@ -1,1016 +0,0 @@ -// -using System; -using DA_DataAccess.Data; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; - -#nullable disable - -namespace DA_DataAccess.Migrations -{ - [DbContext(typeof(ApplicationDbContext))] - [Migration("20240502004056_addEquipment2")] - partial class addEquipment2 - { - /// - 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("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("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.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("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"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/DA_DataAccess/Migrations/20240502004056_addEquipment2.cs b/DA_DataAccess/Migrations/20240502004056_addEquipment2.cs deleted file mode 100644 index 19dbd0d..0000000 --- a/DA_DataAccess/Migrations/20240502004056_addEquipment2.cs +++ /dev/null @@ -1,40 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace DA_DataAccess.Migrations -{ - /// - public partial class addEquipment2 : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.AddColumn( - name: "Price", - table: "Equipment", - type: "numeric", - nullable: false, - defaultValue: 0m); - - migrationBuilder.AddColumn( - name: "Weight", - table: "Equipment", - type: "numeric", - nullable: false, - defaultValue: 0m); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropColumn( - name: "Price", - table: "Equipment"); - - migrationBuilder.DropColumn( - name: "Weight", - table: "Equipment"); - } - } -} diff --git a/DA_DataAccess/Migrations/20240505205317_addItemCount.Designer.cs b/DA_DataAccess/Migrations/20240505205317_addItemCount.Designer.cs deleted file mode 100644 index d2b1381..0000000 --- a/DA_DataAccess/Migrations/20240505205317_addItemCount.Designer.cs +++ /dev/null @@ -1,1019 +0,0 @@ -// -using System; -using DA_DataAccess.Data; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; - -#nullable disable - -namespace DA_DataAccess.Migrations -{ - [DbContext(typeof(ApplicationDbContext))] - [Migration("20240505205317_addItemCount")] - partial class addItemCount - { - /// - 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("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.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("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"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/DA_DataAccess/Migrations/20240506142843_addEquipmentShortDescr.Designer.cs b/DA_DataAccess/Migrations/20240506142843_addEquipmentShortDescr.Designer.cs deleted file mode 100644 index 760a968..0000000 --- a/DA_DataAccess/Migrations/20240506142843_addEquipmentShortDescr.Designer.cs +++ /dev/null @@ -1,1023 +0,0 @@ -// -using System; -using DA_DataAccess.Data; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; - -#nullable disable - -namespace DA_DataAccess.Migrations -{ - [DbContext(typeof(ApplicationDbContext))] - [Migration("20240506142843_addEquipmentShortDescr")] - partial class addEquipmentShortDescr - { - /// - 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.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("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"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/DA_DataAccess/Migrations/20240506142843_addEquipmentShortDescr.cs b/DA_DataAccess/Migrations/20240506142843_addEquipmentShortDescr.cs deleted file mode 100644 index 8f2690a..0000000 --- a/DA_DataAccess/Migrations/20240506142843_addEquipmentShortDescr.cs +++ /dev/null @@ -1,29 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace DA_DataAccess.Migrations -{ - /// - public partial class addEquipmentShortDescr : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.AddColumn( - name: "ShortDescr", - table: "Equipment", - type: "text", - nullable: false, - defaultValue: ""); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropColumn( - name: "ShortDescr", - table: "Equipment"); - } - } -} diff --git a/DA_DataAccess/Migrations/20240507163528_AddChat.cs b/DA_DataAccess/Migrations/20240507163528_AddChat.cs deleted file mode 100644 index 718cc14..0000000 --- a/DA_DataAccess/Migrations/20240507163528_AddChat.cs +++ /dev/null @@ -1,59 +0,0 @@ -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.cs b/DA_DataAccess/Migrations/20240507224949_addApplicationUser.cs deleted file mode 100644 index d8e40a3..0000000 --- a/DA_DataAccess/Migrations/20240507224949_addApplicationUser.cs +++ /dev/null @@ -1,22 +0,0 @@ -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/20240507163528_AddChat.Designer.cs b/DA_DataAccess/Migrations/20240517125003_addchatnotification.Designer.cs similarity index 99% rename from DA_DataAccess/Migrations/20240507163528_AddChat.Designer.cs rename to DA_DataAccess/Migrations/20240517125003_addchatnotification.Designer.cs index 15a09e8..7d02875 100644 --- a/DA_DataAccess/Migrations/20240507163528_AddChat.Designer.cs +++ b/DA_DataAccess/Migrations/20240517125003_addchatnotification.Designer.cs @@ -12,8 +12,8 @@ namespace DA_DataAccess.Migrations { [DbContext(typeof(ApplicationDbContext))] - [Migration("20240507163528_AddChat")] - partial class AddChat + [Migration("20240517125003_addchatnotification")] + partial class addchatnotification { /// protected override void BuildTargetModel(ModelBuilder modelBuilder) @@ -523,7 +523,7 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); b.Property("CreatedDate") - .HasColumnType("timestamp with time zone"); + .HasColumnType("timestamp without time zone"); b.Property("FromUserId") .IsRequired() @@ -826,10 +826,16 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) { b.HasBaseType("Microsoft.AspNetCore.Identity.IdentityUser"); + b.Property("BadgeContent") + .HasColumnType("integer"); + b.Property("Name") .IsRequired() .HasColumnType("text"); + b.Property("ShowBadge") + .HasColumnType("boolean"); + b.HasDiscriminator().HasValue("ApplicationUser"); }); diff --git a/DA_DataAccess/Migrations/20240501195333_addEquipment.cs b/DA_DataAccess/Migrations/20240517125003_addchatnotification.cs similarity index 93% rename from DA_DataAccess/Migrations/20240501195333_addEquipment.cs rename to DA_DataAccess/Migrations/20240517125003_addchatnotification.cs index ecdceac..ff4ff69 100644 --- a/DA_DataAccess/Migrations/20240501195333_addEquipment.cs +++ b/DA_DataAccess/Migrations/20240517125003_addchatnotification.cs @@ -7,7 +7,7 @@ namespace DA_DataAccess.Migrations { /// - public partial class addEquipment : Migration + public partial class addchatnotification : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) @@ -33,6 +33,8 @@ protected override void Up(MigrationBuilder migrationBuilder) Id = table.Column(type: "text", nullable: false), Discriminator = table.Column(type: "text", nullable: false), Name = table.Column(type: "text", nullable: true), + ShowBadge = table.Column(type: "boolean", nullable: true), + BadgeContent = table.Column(type: "integer", nullable: true), UserName = table.Column(type: "character varying(256)", maxLength: 256, nullable: true), NormalizedUserName = table.Column(type: "character varying(256)", maxLength: 256, nullable: true), Email = table.Column(type: "character varying(256)", maxLength: 256, nullable: true), @@ -62,6 +64,10 @@ protected override void Up(MigrationBuilder migrationBuilder) Name = table.Column(type: "text", nullable: false), Index = table.Column(type: "integer", nullable: false), Description = table.Column(type: "text", nullable: false), + ShortDescr = table.Column(type: "text", nullable: false), + Price = table.Column(type: "numeric", nullable: false), + Weight = table.Column(type: "numeric", nullable: false), + Count = table.Column(type: "integer", nullable: false), IsApproved = table.Column(type: "boolean", nullable: false) }, constraints: table => @@ -246,6 +252,32 @@ protected override void Up(MigrationBuilder migrationBuilder) onDelete: ReferentialAction.Cascade); }); + 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 without 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.CreateTable( name: "ProfessionSkills", columns: table => new @@ -599,6 +631,16 @@ protected override void Up(MigrationBuilder migrationBuilder) table: "CharacterTraitAdv", column: "TraitsAdvId"); + migrationBuilder.CreateIndex( + name: "IX_ChatMessages_FromUserId", + table: "ChatMessages", + column: "FromUserId"); + + migrationBuilder.CreateIndex( + name: "IX_ChatMessages_ToUserId", + table: "ChatMessages", + column: "ToUserId"); + migrationBuilder.CreateIndex( name: "IX_EquipmentTraitEquipment_TraitsId", table: "EquipmentTraitEquipment", @@ -658,6 +700,9 @@ protected override void Down(MigrationBuilder migrationBuilder) migrationBuilder.DropTable( name: "CharacterTraitAdv"); + migrationBuilder.DropTable( + name: "ChatMessages"); + migrationBuilder.DropTable( name: "EquipmentTraitEquipment"); diff --git a/DA_DataAccess/Migrations/20240507224949_addApplicationUser.Designer.cs b/DA_DataAccess/Migrations/20240519204653_chatupdate.Designer.cs similarity index 98% rename from DA_DataAccess/Migrations/20240507224949_addApplicationUser.Designer.cs rename to DA_DataAccess/Migrations/20240519204653_chatupdate.Designer.cs index b0cbbe2..1212e10 100644 --- a/DA_DataAccess/Migrations/20240507224949_addApplicationUser.Designer.cs +++ b/DA_DataAccess/Migrations/20240519204653_chatupdate.Designer.cs @@ -12,8 +12,8 @@ namespace DA_DataAccess.Migrations { [DbContext(typeof(ApplicationDbContext))] - [Migration("20240507224949_addApplicationUser")] - partial class addApplicationUser + [Migration("20240519204653_chatupdate")] + partial class chatupdate { /// protected override void BuildTargetModel(ModelBuilder modelBuilder) @@ -523,12 +523,15 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); b.Property("CreatedDate") - .HasColumnType("timestamp with time zone"); + .HasColumnType("timestamp without time zone"); b.Property("FromUserId") .IsRequired() .HasColumnType("text"); + b.Property("IsRead") + .HasColumnType("boolean"); + b.Property("Message") .IsRequired() .HasColumnType("text"); @@ -826,10 +829,16 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) { b.HasBaseType("Microsoft.AspNetCore.Identity.IdentityUser"); + b.Property("BadgeContent") + .HasColumnType("integer"); + b.Property("Name") .IsRequired() .HasColumnType("text"); + b.Property("ShowBadge") + .HasColumnType("boolean"); + b.HasDiscriminator().HasValue("ApplicationUser"); }); diff --git a/DA_DataAccess/Migrations/20240505205317_addItemCount.cs b/DA_DataAccess/Migrations/20240519204653_chatupdate.cs similarity index 59% rename from DA_DataAccess/Migrations/20240505205317_addItemCount.cs rename to DA_DataAccess/Migrations/20240519204653_chatupdate.cs index 32e17e7..f0a9e5f 100644 --- a/DA_DataAccess/Migrations/20240505205317_addItemCount.cs +++ b/DA_DataAccess/Migrations/20240519204653_chatupdate.cs @@ -5,25 +5,25 @@ namespace DA_DataAccess.Migrations { /// - public partial class addItemCount : Migration + public partial class chatupdate : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { - migrationBuilder.AddColumn( - name: "Count", - table: "Equipment", - type: "integer", + migrationBuilder.AddColumn( + name: "IsRead", + table: "ChatMessages", + type: "boolean", nullable: false, - defaultValue: 0); + defaultValue: false); } /// protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropColumn( - name: "Count", - table: "Equipment"); + name: "IsRead", + table: "ChatMessages"); } } } diff --git a/DA_DataAccess/Migrations/ApplicationDbContextModelSnapshot.cs b/DA_DataAccess/Migrations/ApplicationDbContextModelSnapshot.cs index 722d9dd..2f26830 100644 --- a/DA_DataAccess/Migrations/ApplicationDbContextModelSnapshot.cs +++ b/DA_DataAccess/Migrations/ApplicationDbContextModelSnapshot.cs @@ -520,12 +520,15 @@ protected override void BuildModel(ModelBuilder modelBuilder) NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); b.Property("CreatedDate") - .HasColumnType("timestamp with time zone"); + .HasColumnType("timestamp without time zone"); b.Property("FromUserId") .IsRequired() .HasColumnType("text"); + b.Property("IsRead") + .HasColumnType("boolean"); + b.Property("Message") .IsRequired() .HasColumnType("text"); @@ -823,10 +826,16 @@ protected override void BuildModel(ModelBuilder modelBuilder) { b.HasBaseType("Microsoft.AspNetCore.Identity.IdentityUser"); + b.Property("BadgeContent") + .HasColumnType("integer"); + b.Property("Name") .IsRequired() .HasColumnType("text"); + b.Property("ShowBadge") + .HasColumnType("boolean"); + b.HasDiscriminator().HasValue("ApplicationUser"); }); diff --git a/DagoniteEmpire/Pages/CharacterPages/CharacterList.razor b/DagoniteEmpire/Pages/CharacterPages/CharacterList.razor index 96c4e78..20bd1fc 100644 --- a/DagoniteEmpire/Pages/CharacterPages/CharacterList.razor +++ b/DagoniteEmpire/Pages/CharacterPages/CharacterList.razor @@ -5,7 +5,7 @@ @inject AuthenticationStateProvider GetAuthenticationStateAsync @inject NavigationManager _navigationManager @inject IJSRuntime _jsRuntime -@attribute [Authorize(Roles = SD.Role_Admin + "," + SD.Role_HeroPlayer + "," + SD.Role_DukePlayer + "," + SD.Role_GameMaster)] + <_DeleteConfirmation IsParentComponentProcessing=IsLoading DeleteConfirmation="ConfirmDelete_Click" DeletingComponentName="this character"> @if (IsLoading) @@ -50,17 +50,18 @@ private int DeleteCharacterId { get; set; } = 0; private string Title { get; set; } = "Your characters"; - // [CascadingParameter] - // public Task AuthenticationState { get; set; } + [CascadingParameter] + public Task AuthenticationState { get; set; } - // protected override async Task OnInitializedAsync() - // { - // var authState = await AuthenticationState; - // if (!authState.User.Identity.IsAuthenticated) - // { - // _navigationManager.NavigateTo("/identity/account/login",forceLoad:true); - // } - // } + protected override async Task OnInitializedAsync() + { + var authState = await AuthenticationState; + if (!authState.User.Identity.IsAuthenticated) + { + var uri = new Uri(_navigationManager.Uri); + _navigationManager.NavigateTo($"/identity/account/login?returnUrl={uri.LocalPath}",forceLoad:true); + } + } protected override async Task OnAfterRenderAsync(bool firstRender) { diff --git a/DagoniteEmpire/Pages/CharacterPages/CharacterUpsert.razor b/DagoniteEmpire/Pages/CharacterPages/CharacterUpsert.razor index 42f297f..6da15b2 100644 --- a/DagoniteEmpire/Pages/CharacterPages/CharacterUpsert.razor +++ b/DagoniteEmpire/Pages/CharacterPages/CharacterUpsert.razor @@ -17,7 +17,6 @@ @using DA_Models @using Syncfusion.Blazor.Navigations -@attribute [Authorize(Roles = SD.Role_Admin + "," + SD.Role_HeroPlayer + "," + SD.Role_DukePlayer + "," + SD.Role_GameMaster)] @inject NavigationManager _navigationManager <_LeavePage IsParentComponentProcessing=IsLoading LeaveConfirmation="ConfirmLeave_Click" > @@ -450,6 +449,19 @@ new ItemModel(){ Text = "Delete", PrefixIcon= "e-delete", Id="Grid_delete"}, }; + [CascadingParameter] + public Task AuthenticationState { get; set; } + + protected override async Task OnInitializedAsync() + { + var authState = await AuthenticationState; + if (!authState.User.Identity.IsAuthenticated) + { + var uri = new Uri(_navigationManager.Uri); + _navigationManager.NavigateTo($"/identity/account/login?returnUrl={uri.LocalPath}", forceLoad: true); + } + } + protected override async Task OnAfterRenderAsync(bool firstRender) { if (firstRender) diff --git a/DagoniteEmpire/Pages/Chat/Chat.razor b/DagoniteEmpire/Pages/Chat/Chat.razor index 8d55f8e..b9d78d1 100644 --- a/DagoniteEmpire/Pages/Chat/Chat.razor +++ b/DagoniteEmpire/Pages/Chat/Chat.razor @@ -6,7 +6,6 @@ @inject NavigationManager _navigationManager @inject AuthenticationStateProvider _stateProvider -@attribute [Authorize(Roles = SD.Role_Admin + "," + SD.Role_HeroPlayer + "," + SD.Role_DukePlayer + "," + SD.Role_GameMaster)]
@@ -101,7 +100,8 @@ [Parameter] public string CurrentMessage { get; set; } [Parameter] public string CurrentUserId { get; set; } [Parameter] public string CurrentUserEmail { get; set; } - + [CascadingParameter] + public Task AuthenticationState { get; set; } MudTextField ChatTextField = new(); private string HubUrl; private List messages = new List(); @@ -132,8 +132,16 @@ { await _jsRuntime.ScrollToBottom("chatContainer"); } + protected override async Task OnInitializedAsync() { + var authState = await AuthenticationState; + if (!authState.User.Identity.IsAuthenticated) + { + var uri = new Uri(_navigationManager.Uri); + _navigationManager.NavigateTo($"/identity/account/login?returnUrl={uri.LocalPath}", forceLoad: true); + } + try { if (hubConnection == null) diff --git a/DagoniteEmpire/Shared/Chat.Razor.css b/DagoniteEmpire/Shared/Chat.Razor.css new file mode 100644 index 0000000..340817e --- /dev/null +++ b/DagoniteEmpire/Shared/Chat.Razor.css @@ -0,0 +1,51 @@ + +.big-screen { + padding: 0; + margin: 0; +} + +.small-screen { + padding: 0; + margin: 0; + display: none; +} + + +.chatboxes { + display: flex; + flex-direction: row-reverse; + position: fixed; + bottom: 0; + right: 0; + width: 100%; + height: 600px; + z-index: 6000; +} + +.chatbox { + width: 310px; + height: 600px; + margin: 0 4px 0 4px; + padding: 0; +} + + +@media (max-width: 400px) { + + + .chatboxes { + display: none; + } + + .small-screen { + display: flex; + flex-direction: row; + position: fixed; + top: 56px; + right: 0px; + width: calc(100% - 56px); + height: 100vh; + z-index: 6000; + } +} + diff --git a/DagoniteEmpire/Shared/Chat.razor b/DagoniteEmpire/Shared/Chat.razor index 153f422..5fa0d64 100644 --- a/DagoniteEmpire/Shared/Chat.razor +++ b/DagoniteEmpire/Shared/Chat.razor @@ -6,130 +6,254 @@ @attribute [Authorize(Roles = SD.Role_Admin + "," + SD.Role_HeroPlayer + "," + SD.Role_DukePlayer + "," + SD.Role_GameMaster)] -
- - - @if (string.IsNullOrEmpty(ContactId)) + + + Chat + + +
+ + @foreach (var user in ChatUsers) { - - chat + +
+
+ + @if (ChosenUser != null && user.Id == ChosenUser.ContactId) + { + @user.UserName.ToUpper().FirstOrDefault() + } + else + { + @user.UserName.ToUpper().FirstOrDefault() + } + +
+
+ @user.UserName + @*@user.Id *@ +
+
+
} - else +
+
+ @if (openEnd) { - - @ContactEmail + } - -
- @foreach (var message in messages) + else { - @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 + + } +
+
+ + + +
+ @foreach (var userbox in UserBoxes) + { +
+ + + @userbox.UserName.ToUpper().FirstOrDefault() + @userbox.UserName + + +
+ @foreach (var message in userbox.messages) { -
-
- @message.FromUser.Email.ToUpper().FirstOrDefault() + @if (message.FromUser.UserName == CurrentUserName) + { +
+
+ @message.FromUser.UserName + @message.CreatedDate.ToString("dd MMM, yyyy hh:mm tt") + @message.Message +
-
- @message.FromUser.Email - @message.CreatedDate.ToString("dd MMM, yyyy hh:mm tt") - @message.Message + } + else + { +
+
+ @message.FromUser.UserName + @message.CreatedDate.ToString("dd MMM, yyyy hh:mm tt") + @message.Message +
-
+ } } - - - } -
- - - Send +
+ + + Send + - - - - # - contacts +
+ } +
+ @if (ChosenUser is not null){ +
+ + + @ChosenUser.UserName.ToUpper().FirstOrDefault() + @ChosenUser.UserName + -
- - @foreach (var user in ChatUsers) +
+ @foreach (var message in ChosenUser.messages) + { + @if (message.FromUser.UserName == CurrentUserName) + { +
+
+ @message.FromUser.UserName + @message.CreatedDate.ToString("dd MMM, yyyy hh:mm tt") + @message.Message +
+
+ } + else { - -
-
- - @if (user.Id == ContactId) - { - @user.Email.ToUpper().FirstOrDefault() - } - else - { - @user.Email.ToUpper().FirstOrDefault() - } - -
-
- @user.Email@* - @user.Id *@ -
+
+
+ @message.FromUser.UserName + @message.CreatedDate.ToString("dd MMM, yyyy hh:mm tt") + @message.Message
- +
} - + } +
+
+ + + Send +
-
+
+} @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; } + bool openEnd = false; + + void ToggleEndDrawer() + { + openEnd = !openEnd; + } - MudTextField ChatTextField = new(); - private string HubUrl; + + private HubConnection hubConnection; + public bool IsConnected => hubConnection.State == HubConnectionState.Connected; + // protected override async Task OnInitializedAsync() + // { + // string baseUrl = _navigationManager.BaseUri; + // string HubUrl = baseUrl.TrimEnd('/') + ChatHub.HubUrl; + + // hubConnection = new HubConnectionBuilder() + // .WithUrl(_navigationManager.ToAbsoluteUri(ChatHub.HubUrl)) + // .Build(); + + // // hubConnection = new HubConnectionBuilder().WithUrl(_navigationManager.ToAbsoluteUri("/signalRHub")).Build(); + // await hubConnection.StartAsync(); + // hubConnection.On("ReceiveChatNotification", (message, receiverUserId, senderUserId) => + // { + // if (CurrentUserId == receiverUserId) + // { + // _snackBar.Add(message, Severity.Info, config => + // { + // config.VisibleStateDuration = 10000; + // config.HideTransitionDuration = 500; + // config.ShowTransitionDuration = 500; + // config.Action = "Chat?"; + // config.ActionColor = Color.Info; + // config.Onclick = snackbar => + // { + // _navigationManager.NavigateTo($"chat/{senderUserId}"); + // return Task.CompletedTask; + // }; + // }); + // } + // }); + // var state = await _stateProvider.GetAuthenticationStateAsync(); + // var user = state.User; + // CurrentUserId = user.FindFirst(u => u.Type.Contains("nameidentifier"))?.Value; + // } + + private string CurrentUserId { get; set; } + private string CurrentUserName { get; set; } + private bool ScrollToBottom = false; private List messages = new List(); - private async Task SubmitAsync() + + private class UserBox + { + public string CurrentMessage { get; set; } + public MudTextField ChatTextField = new(); + public List messages = new List(); + public string UserName { get; set; } = string.Empty; + public string ContactId { get; set; } = string.Empty; + public bool IsUserChosen { get; set; } = false; + } + + private List UserBoxes { get; set; } = new List(); + private UserBox? ChosenUser { get; set; } = null; + public List ChatUsers = new List(); + + + private async Task SubmitAsync(UserBox user) { - if(IsUserChosen==false) - return; - if (!string.IsNullOrEmpty(CurrentMessage) && !string.IsNullOrEmpty(ContactId)) + ChosenUser = user; + ChosenUser.IsUserChosen = true; + + if (!string.IsNullOrEmpty(ChosenUser.CurrentMessage) && !string.IsNullOrEmpty(ChosenUser.ContactId)) { //Save Message to DB - var chatHistory = new ChatMessage() - { - Message = CurrentMessage, - ToUserId = ContactId, - CreatedDate = DateTime.Now - - }; + { + Message = ChosenUser.CurrentMessage, + ToUserId = ChosenUser.ContactId, + CreatedDate = DateTime.Now + }; chatHistory.FromUserId = CurrentUserId; - await hubConnection.SendAsync("SendMessage", CurrentUserEmail, chatHistory); - CurrentMessage = string.Empty; + await hubConnection.SendAsync("SendMessage", CurrentUserName, chatHistory); + ChosenUser.CurrentMessage = string.Empty; await _chatManager.SaveMessageAsync(chatHistory); + } + } + private async Task OnMessageFocus(UserBox user) + { + if (ChosenUser is null) + ChosenUser = user; + + + if (ChosenUser.ContactId != user.ContactId) + { + ChosenUser = user; + ChosenUser.IsUserChosen = true; + InvokeAsync(StateHasChanged); } + + ClearBadgeContent(); } protected override async Task OnAfterRenderAsync(bool firstRender) { - await _jsRuntime.ScrollToBottom("chatContainer"); + if (ScrollToBottom || firstRender) + { + if (ChosenUser is not null) + { + await _jsRuntime.ScrollToBottom($"{ChosenUser.ContactId}"); + ScrollToBottom = false; + } + } } + protected override async Task OnInitializedAsync() { try @@ -149,13 +273,7 @@ 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."); + CurrentUserName = user.FindFirst(u => u.Type.Contains("name") && !u.Type.Contains("nameidentifier"))?.Value; } catch (Exception e) { @@ -168,61 +286,121 @@ private async Task ReceiveMessage(string name, ChatMessage message) { - if ((ContactId == message.ToUserId && CurrentUserId == message.FromUserId) || (ContactId == message.FromUserId && CurrentUserId == message.ToUserId)) + if(ChosenUser is not null) { - - if ((ContactId == message.ToUserId && CurrentUserId == message.FromUserId)) + if (ChosenUser.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); + ChosenUser.messages.Add(new ChatMessage { Message = message.Message, CreatedDate = message.CreatedDate, FromUser = new ApplicationUser() { UserName = CurrentUserName } }); } - else if ((ContactId == message.FromUserId && CurrentUserId == message.ToUserId)) + else if ((ChosenUser.ContactId == message.FromUserId && CurrentUserId == message.ToUserId)) { - messages.Add(new ChatMessage { Message = message.Message, CreatedDate = message.CreatedDate, FromUser = new ApplicationUser() { Email = ContactEmail } }); + ChosenUser.messages.Add(new ChatMessage { Message = message.Message, CreatedDate = message.CreatedDate, FromUser = new ApplicationUser() { UserName = ChosenUser.UserName } }); + ClearBadgeContent(); } - - // Inform blazor the UI needs updating - InvokeAsync(StateHasChanged); - - await Task.Delay(1000); - - await _jsRuntime.ScrollToBottom("chatContainer"); } + else + { + if (CurrentUserId == message.ToUserId) + { + GetBadgeValue(message.FromUserId); + } + } + // Inform blazor the UI needs updating + InvokeAsync(StateHasChanged); + ScrollToBottom = true; } public async Task Enter(KeyboardEventArgs e) { if (e.Code == "Enter" || e.Code == "NumpadEnter") { - ChatTextField.TextUpdateSuppression = false; - await SubmitAsync(); - CurrentMessage = string.Empty; + ChosenUser.ChatTextField.TextUpdateSuppression = false; + await SubmitAsync(ChosenUser); + ChosenUser.CurrentMessage = string.Empty; StateHasChanged(); await Task.Run(async () => { await Task.Delay(150); - ChatTextField.TextUpdateSuppression = true; + ChosenUser.ChatTextField.TextUpdateSuppression = true; }); } } - public List ChatUsers = new List(); - public string ContactEmail { get; set; } - public string ContactId { get; set; } - private bool IsUserChosen { get; set; } = false; - async Task LoadUserChat(string userId) + async Task AddUserChat(string userId) { + var width = await _jsRuntime.GetWindowWidth(); 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; + ChosenUser = UserBoxes.FirstOrDefault(u => u.ContactId == userId); + if (ChosenUser == null) + { + ChosenUser = new UserBox() + { + ContactId = contact.Id, + UserName = contact.UserName, + messages = await _chatManager.GetConversationAsync(contact.Id), + IsUserChosen = true, + }; + UserBoxes.Add(ChosenUser); + if (width - UserBoxes.Count * 320 < 320) + { + if(UserBoxes.Count>0) + UserBoxes.RemoveAt(0); + } + } + ClearBadgeContent(); + StateHasChanged(); + await _jsRuntime.ScrollToBottom($"{ChosenUser.ContactId}"); + + } + private async Task CloseChatbox(UserBox user) + { + UserBoxes.Remove(user); + ChosenUser = null; + + StateHasChanged(); } + private async Task GetUsersAsync() { ChatUsers = await _chatManager.GetUsersAsync(); + foreach(var user in ChatUsers) + { + var notifications = user.ChatMessagesFromUsers.Where(u=>u.IsRead == false).Count(); + if(notifications>0){ + user.BadgeContent = notifications; + user.ShowBadge = true; + } + } + + } + + public async Task GetBadgeValue(string Id) + { + + var user = ChatUsers.FirstOrDefault(u => u.Id == Id); + var messages = await _chatManager.GetConversationAsync(Id); + + int unreadMessages = messages.Where(u => u.IsRead == false).Count(); + + if (unreadMessages > 0) + { + user.ShowBadge = true; + user.BadgeContent = unreadMessages; + } } - } \ No newline at end of file + public async Task ClearBadgeContent() + { + + ChosenUser.messages.ForEach(u => u.IsRead = true); + + var user = ChatUsers.FirstOrDefault(u => u.Id == ChosenUser.ContactId); + if (user is not null && user.ShowBadge == true) + { + user.ShowBadge = false; + user.BadgeContent = null; + + await _chatManager.MakeMessageRedAsync(user.Id); + } + } +} diff --git a/DagoniteEmpire/Shared/MainLayout.razor b/DagoniteEmpire/Shared/MainLayout.razor index 5af61ea..3fab880 100644 --- a/DagoniteEmpire/Shared/MainLayout.razor +++ b/DagoniteEmpire/Shared/MainLayout.razor @@ -40,118 +40,16 @@ - - - Chat - - -
- - @foreach (var user in ChatUsers) - { - -
-
- - @if (user.Id == ChosenUser.ContactId) - { - @user.UserName.ToUpper().FirstOrDefault() - } - else - { - @user.UserName.ToUpper().FirstOrDefault() - } - -
-
- @user.UserName@* - @user.Id *@ -
-
-
- } -
-
- @if (openEnd) - { - - } - else - { - - } -
-
-
- -
- @foreach (var userbox in UserBoxes) - { -
- - - - @userbox.UserName - - -
- @foreach (var message in userbox.messages) - { - @if (message.FromUser.UserName == CurrentUserName) - { -
-
- @message.FromUser.UserName.ToUpper().FirstOrDefault() -
-
- @message.FromUser.UserName - @message.CreatedDate.ToString("dd MMM, yyyy hh:mm tt") - @message.Message -
-
- } - else - { -
-
- @message.FromUser.UserName.ToUpper().FirstOrDefault() -
-
- @message.FromUser.UserName - @message.CreatedDate.ToString("dd MMM, yyyy hh:mm tt") - @message.Message -
-
- } - } -
- - - Send - -
-
- } -
- +
- - - @Body - - -
- @Body - @@ -159,17 +57,9 @@ @code { - [CascadingParameter] - public bool Rtl { get; set; } private MudTheme Theme = new MudTheme(); - bool openEnd = false; - - void ToggleEndDrawer() - { - openEnd = !openEnd; - } void DrawerStartToggle() { @@ -178,213 +68,9 @@ bool _drawerOpen = false; - private HubConnection hubConnection; - public bool IsConnected => hubConnection.State == HubConnectionState.Connected; - // protected override async Task OnInitializedAsync() - // { - // string baseUrl = _navigationManager.BaseUri; - // string HubUrl = baseUrl.TrimEnd('/') + ChatHub.HubUrl; - - // hubConnection = new HubConnectionBuilder() - // .WithUrl(_navigationManager.ToAbsoluteUri(ChatHub.HubUrl)) - // .Build(); - - // // hubConnection = new HubConnectionBuilder().WithUrl(_navigationManager.ToAbsoluteUri("/signalRHub")).Build(); - // await hubConnection.StartAsync(); - // hubConnection.On("ReceiveChatNotification", (message, receiverUserId, senderUserId) => - // { - // if (CurrentUserId == receiverUserId) - // { - // _snackBar.Add(message, Severity.Info, config => - // { - // config.VisibleStateDuration = 10000; - // config.HideTransitionDuration = 500; - // config.ShowTransitionDuration = 500; - // config.Action = "Chat?"; - // config.ActionColor = Color.Info; - // config.Onclick = snackbar => - // { - // _navigationManager.NavigateTo($"chat/{senderUserId}"); - // return Task.CompletedTask; - // }; - // }); - // } - // }); - // var state = await _stateProvider.GetAuthenticationStateAsync(); - // var user = state.User; - // CurrentUserId = user.FindFirst(u => u.Type.Contains("nameidentifier"))?.Value; - // } - - private string CurrentUserId { get; set; } - private string CurrentUserName {get; set; } - private bool ScrollToBottom = false; - - - private class UserBox - { - - public string CurrentMessage { get; set; } - public MudTextField ChatTextField = new(); - public List messages = new List(); - public string UserName { get; set; } = string.Empty; - public string ContactId { get; set; } = string.Empty; - public bool IsUserChosen { get; set; } = false; - } - - private List UserBoxes { get; set; } = new List(); - private UserBox ChosenUser { get; set; } = new(); - public List ChatUsers = new List(); - - private async Task SubmitAsync(UserBox user) - { - ChosenUser = user; - ChosenUser.IsUserChosen = true; - - if (!string.IsNullOrEmpty(ChosenUser.CurrentMessage) && !string.IsNullOrEmpty(ChosenUser.ContactId)) - { - //Save Message to DB - var chatHistory = new ChatMessage() - { - Message = ChosenUser.CurrentMessage, - ToUserId = ChosenUser.ContactId, - CreatedDate = DateTime.Now - }; - - chatHistory.FromUserId = CurrentUserId; - await hubConnection.SendAsync("SendMessage", CurrentUserName, chatHistory); - ChosenUser.CurrentMessage = string.Empty; - await _chatManager.SaveMessageAsync(chatHistory); - } - } - private async Task OnMessageFocus(UserBox user) - { - if (ChosenUser.ContactId != user.ContactId) - { - - ChosenUser = user; - ChosenUser.IsUserChosen = true; - InvokeAsync(StateHasChanged); - } - } - protected override async Task OnAfterRenderAsync(bool firstRender) - { - if (ScrollToBottom) - { - await _jsRuntime.ScrollToBottom($"{ChosenUser.ContactId}"); - ScrollToBottom = false; - } - } - - - + 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; - CurrentUserName = user.FindFirst(u => u.Type.Contains("name") && !u.Type.Contains("nameidentifier"))?.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 ((ChosenUser.ContactId == message.ToUserId && CurrentUserId == message.FromUserId) || (ChosenUser.ContactId == message.FromUserId && CurrentUserId == message.ToUserId)) - { - - if ((ChosenUser.ContactId == message.ToUserId && CurrentUserId == message.FromUserId)) - { - ChosenUser.messages.Add(new ChatMessage { Message = message.Message, CreatedDate = message.CreatedDate, FromUser = new ApplicationUser() { UserName = CurrentUserName } }); - //await hubConnection.SendAsync("ChatNotificationAsync", $"New Message From {name}", ContactId, CurrentUserId); - } - else if ((ChosenUser.ContactId == message.FromUserId && CurrentUserId == message.ToUserId)) - { - ChosenUser.messages.Add(new ChatMessage { Message = message.Message, CreatedDate = message.CreatedDate, FromUser = new ApplicationUser() { UserName = ChosenUser.UserName } }); - } - - // Inform blazor the UI needs updating - InvokeAsync(StateHasChanged); - - } - ScrollToBottom = true; - } - - public async Task Enter(KeyboardEventArgs e) - { - if (e.Code == "Enter" || e.Code == "NumpadEnter") - { - ChosenUser.ChatTextField.TextUpdateSuppression = false; - await SubmitAsync(ChosenUser); - ChosenUser.CurrentMessage = string.Empty; - StateHasChanged(); - await Task.Run(async () => - { - await Task.Delay(150); - ChosenUser.ChatTextField.TextUpdateSuppression = true; - }); - } - } - - async Task AddUserChat(string userId) - { - var width = await _jsRuntime.GetWindowWidth(); - var contact = await _chatManager.GetUserDetailsAsync(userId); - ChosenUser = UserBoxes.FirstOrDefault(u => u.ContactId == userId); - if (ChosenUser == null) - { - ChosenUser = new UserBox() - { - ContactId = contact.Id, - UserName = contact.UserName, - messages = await _chatManager.GetConversationAsync(contact.Id), - IsUserChosen = true, - }; - UserBoxes.Add(ChosenUser); - if (width - UserBoxes.Count * 320 < 320 ) - { - UserBoxes.RemoveAt(0); - } - } - StateHasChanged(); - await _jsRuntime.ScrollToBottom($"{ChosenUser.ContactId}"); - - } - private async Task CloseChatbox(UserBox user) - { - UserBoxes.Remove(user); - - StateHasChanged(); - } - - private async Task GetUsersAsync() - { - ChatUsers = await _chatManager.GetUsersAsync(); - } + + } } \ No newline at end of file