diff --git a/Dynamics.DataAccess/Migrations/20241106220416_initial.Designer.cs b/Dynamics.DataAccess/Migrations/20241106220416_initial.Designer.cs new file mode 100644 index 00000000..8dff9e0d --- /dev/null +++ b/Dynamics.DataAccess/Migrations/20241106220416_initial.Designer.cs @@ -0,0 +1,1116 @@ +// +using System; +using Dynamics.DataAccess; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace Dynamics.DataAccess.Migrations +{ + [DbContext(typeof(ApplicationDbContext))] + [Migration("20241106220416_initial")] + partial class initial + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "8.0.8") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + + modelBuilder.Entity("Dynamics.Models.Models.History", b => + { + b.Property("HistoryID") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("Attachment") + .HasColumnType("nvarchar(max)"); + + b.Property("Content") + .IsRequired() + .HasMaxLength(1000) + .HasColumnType("nvarchar(1000)"); + + b.Property("Date") + .HasColumnType("date"); + + b.Property("Phase") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("ProjectID") + .HasColumnType("uniqueidentifier"); + + b.HasKey("HistoryID"); + + b.HasIndex("ProjectID"); + + b.ToTable("Histories"); + }); + + modelBuilder.Entity("Dynamics.Models.Models.Notification", b => + { + b.Property("NotificationID") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("Date") + .HasColumnType("datetime2"); + + b.Property("Link") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Message") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("UserID") + .HasColumnType("uniqueidentifier"); + + b.HasKey("NotificationID"); + + b.HasIndex("UserID"); + + b.ToTable("Notifications"); + }); + + modelBuilder.Entity("Dynamics.Models.Models.Organization", b => + { + b.Property("OrganizationID") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("OrganizationAddress") + .HasColumnType("nvarchar(max)"); + + b.Property("OrganizationDescription") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("OrganizationEmail") + .HasColumnType("nvarchar(450)"); + + b.Property("OrganizationName") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("OrganizationPhoneNumber") + .HasColumnType("nvarchar(max)"); + + b.Property("OrganizationPictures") + .HasColumnType("nvarchar(max)"); + + b.Property("OrganizationStatus") + .HasColumnType("int"); + + b.Property("ShutdownDay") + .HasColumnType("date"); + + b.Property("StartTime") + .HasColumnType("date"); + + b.HasKey("OrganizationID"); + + b.HasIndex("OrganizationEmail") + .IsUnique() + .HasFilter("[OrganizationEmail] IS NOT NULL"); + + b.HasIndex("OrganizationName") + .IsUnique(); + + b.ToTable("Organizations"); + }); + + modelBuilder.Entity("Dynamics.Models.Models.OrganizationMember", b => + { + b.Property("OrganizationID") + .HasColumnType("uniqueidentifier"); + + b.Property("UserID") + .HasColumnType("uniqueidentifier"); + + b.Property("Status") + .HasColumnType("int"); + + b.HasKey("OrganizationID", "UserID"); + + b.HasIndex("UserID"); + + b.ToTable("OrganizationMember"); + }); + + modelBuilder.Entity("Dynamics.Models.Models.OrganizationResource", b => + { + b.Property("ResourceID") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("OrganizationID") + .HasColumnType("uniqueidentifier"); + + b.Property("Quantity") + .HasColumnType("int"); + + b.Property("ResourceName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Unit") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("ResourceID"); + + b.HasIndex("OrganizationID"); + + b.ToTable("OrganizationResources"); + }); + + modelBuilder.Entity("Dynamics.Models.Models.OrganizationToProjectHistory", b => + { + b.Property("TransactionID") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("Amount") + .HasColumnType("int"); + + b.Property("Attachments") + .HasColumnType("nvarchar(max)"); + + b.Property("Message") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("OrganizationResourceID") + .HasColumnType("uniqueidentifier"); + + b.Property("ProjectResourceID") + .HasColumnType("uniqueidentifier"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("Time") + .HasColumnType("date"); + + b.HasKey("TransactionID"); + + b.HasIndex("OrganizationResourceID"); + + b.HasIndex("ProjectResourceID"); + + b.ToTable("OrganizationToProjectTransactionHistory"); + }); + + modelBuilder.Entity("Dynamics.Models.Models.Project", b => + { + b.Property("ProjectID") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("Attachment") + .HasColumnType("nvarchar(max)"); + + b.Property("EndTime") + .HasColumnType("date"); + + b.Property("OrganizationID") + .HasColumnType("uniqueidentifier"); + + b.Property("ProjectAddress") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ProjectDescription") + .IsRequired() + .HasMaxLength(1000) + .HasColumnType("nvarchar(1000)"); + + b.Property("ProjectEmail") + .HasColumnType("nvarchar(max)"); + + b.Property("ProjectName") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("ProjectPhoneNumber") + .HasColumnType("nvarchar(max)"); + + b.Property("ProjectStatus") + .HasColumnType("int"); + + b.Property("ReportFile") + .HasColumnType("nvarchar(max)"); + + b.Property("RequestID") + .HasColumnType("uniqueidentifier"); + + b.Property("ShutdownReason") + .HasColumnType("nvarchar(max)"); + + b.Property("StartTime") + .HasColumnType("date"); + + b.Property("isBanned") + .HasColumnType("bit"); + + b.HasKey("ProjectID"); + + b.HasIndex("OrganizationID"); + + b.HasIndex("RequestID") + .IsUnique() + .HasFilter("[RequestID] IS NOT NULL"); + + b.ToTable("Projects"); + }); + + modelBuilder.Entity("Dynamics.Models.Models.ProjectMember", b => + { + b.Property("ProjectID") + .HasColumnType("uniqueidentifier"); + + b.Property("UserID") + .HasColumnType("uniqueidentifier"); + + b.Property("Status") + .HasColumnType("int"); + + b.HasKey("ProjectID", "UserID"); + + b.HasIndex("UserID"); + + b.ToTable("ProjectMembers"); + }); + + modelBuilder.Entity("Dynamics.Models.Models.ProjectResource", b => + { + b.Property("ResourceID") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("ExpectedQuantity") + .HasColumnType("int"); + + b.Property("ProjectID") + .HasColumnType("uniqueidentifier"); + + b.Property("Quantity") + .HasColumnType("int"); + + b.Property("ResourceName") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("Unit") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.HasKey("ResourceID"); + + b.HasIndex("ProjectID"); + + b.ToTable("ProjectResources"); + }); + + modelBuilder.Entity("Dynamics.Models.Models.Report", b => + { + b.Property("ReportID") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("ObjectID") + .HasColumnType("uniqueidentifier"); + + b.Property("Reason") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("ReportDate") + .HasColumnType("datetime2"); + + b.Property("ReporterID") + .HasColumnType("uniqueidentifier"); + + b.Property("Type") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("ReportID"); + + b.HasIndex("ReporterID"); + + b.ToTable("Reports"); + }); + + modelBuilder.Entity("Dynamics.Models.Models.Request", b => + { + b.Property("RequestID") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("Attachment") + .HasColumnType("nvarchar(max)"); + + b.Property("Content") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("CreationDate") + .HasColumnType("datetime2"); + + b.Property("Location") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("RequestEmail") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("RequestPhoneNumber") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("RequestTitle") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("UserID") + .HasColumnType("uniqueidentifier"); + + b.Property("isEmergency") + .HasColumnType("int"); + + b.HasKey("RequestID"); + + b.HasIndex("UserID"); + + b.ToTable("Requests"); + }); + + modelBuilder.Entity("Dynamics.Models.Models.User", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("AccessFailedCount") + .HasColumnType("int"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasColumnType("nvarchar(max)"); + + b.Property("CreatedDate") + .HasColumnType("datetime2"); + + b.Property("Email") + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); + + b.Property("EmailConfirmed") + .HasColumnType("bit"); + + b.Property("LockoutEnabled") + .HasColumnType("bit"); + + b.Property("LockoutEnd") + .HasColumnType("datetimeoffset"); + + b.Property("NormalizedEmail") + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); + + b.Property("NormalizedUserName") + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); + + b.Property("PasswordHash") + .HasColumnType("nvarchar(max)"); + + b.Property("PhoneNumber") + .HasMaxLength(11) + .HasColumnType("nvarchar(11)"); + + b.Property("PhoneNumberConfirmed") + .HasColumnType("bit"); + + b.Property("SecurityStamp") + .HasColumnType("nvarchar(max)"); + + b.Property("TwoFactorEnabled") + .HasColumnType("bit"); + + b.Property("UserAddress") + .HasColumnType("nvarchar(max)"); + + b.Property("UserAvatar") + .HasColumnType("nvarchar(max)"); + + b.Property("UserDOB") + .HasColumnType("date"); + + b.Property("UserDescription") + .HasMaxLength(1000) + .HasColumnType("nvarchar(1000)"); + + b.Property("UserName") + .IsRequired() + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); + + b.Property("isBanned") + .HasColumnType("bit"); + + b.HasKey("Id"); + + b.HasIndex("Email") + .IsUnique() + .HasFilter("[Email] IS NOT NULL"); + + b.HasIndex("NormalizedEmail") + .HasDatabaseName("EmailIndex"); + + b.HasIndex("NormalizedUserName") + .IsUnique() + .HasDatabaseName("UserNameIndex") + .HasFilter("[NormalizedUserName] IS NOT NULL"); + + b.HasIndex("UserName") + .IsUnique(); + + b.ToTable("AspNetUsers", (string)null); + }); + + modelBuilder.Entity("Dynamics.Models.Models.UserToOrganizationTransactionHistory", b => + { + b.Property("TransactionID") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("Amount") + .HasColumnType("int"); + + b.Property("Attachments") + .HasColumnType("nvarchar(max)"); + + b.Property("Message") + .HasColumnType("nvarchar(max)"); + + b.Property("ResourceID") + .HasColumnType("uniqueidentifier"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("Time") + .HasColumnType("date"); + + b.Property("UserID") + .HasColumnType("uniqueidentifier"); + + b.HasKey("TransactionID"); + + b.HasIndex("ResourceID"); + + b.HasIndex("UserID"); + + b.ToTable("UserToOrganizationTransactionHistories"); + }); + + modelBuilder.Entity("Dynamics.Models.Models.UserToProjectTransactionHistory", b => + { + b.Property("TransactionID") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("Amount") + .HasColumnType("int"); + + b.Property("Attachments") + .HasColumnType("nvarchar(max)"); + + b.Property("Message") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("ProjectResourceID") + .HasColumnType("uniqueidentifier"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("Time") + .HasColumnType("date"); + + b.Property("UserID") + .HasColumnType("uniqueidentifier"); + + b.HasKey("TransactionID"); + + b.HasIndex("ProjectResourceID"); + + b.HasIndex("UserID"); + + b.ToTable("UserToProjectTransactionHistories"); + }); + + modelBuilder.Entity("Dynamics.Models.Models.UserWalletTransaction", b => + { + b.Property("TransactionId") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("Amount") + .HasColumnType("int"); + + b.Property("Message") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("Time") + .HasColumnType("datetime2"); + + b.Property("TransactionType") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("WalletId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("TransactionId"); + + b.HasIndex("WalletId"); + + b.ToTable("UserWalletTransactions"); + }); + + modelBuilder.Entity("Dynamics.Models.Models.Wallet", b => + { + b.Property("WalletId") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("Amount") + .HasColumnType("int"); + + b.Property("Currency") + .IsRequired() + .HasMaxLength(3) + .HasColumnType("nvarchar(3)"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("WalletId"); + + b.HasIndex("UserId") + .IsUnique(); + + b.ToTable("Wallets"); + }); + + modelBuilder.Entity("Dynamics.Models.Models.Withdraw", b => + { + b.Property("WithdrawID") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("Message") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("ProjectID") + .HasColumnType("uniqueidentifier"); + + b.Property("Time") + .HasColumnType("datetime2"); + + b.HasKey("WithdrawID"); + + b.HasIndex("ProjectID"); + + b.ToTable("Withdraws"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRole", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasColumnType("nvarchar(max)"); + + b.Property("Name") + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); + + b.Property("NormalizedName") + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); + + b.HasKey("Id"); + + b.HasIndex("NormalizedName") + .IsUnique() + .HasDatabaseName("RoleNameIndex") + .HasFilter("[NormalizedName] IS NOT NULL"); + + b.ToTable("AspNetRoles", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ClaimType") + .HasColumnType("nvarchar(max)"); + + b.Property("ClaimValue") + .HasColumnType("nvarchar(max)"); + + b.Property("RoleId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("RoleId"); + + b.ToTable("AspNetRoleClaims", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ClaimType") + .HasColumnType("nvarchar(max)"); + + b.Property("ClaimValue") + .HasColumnType("nvarchar(max)"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("AspNetUserClaims", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => + { + b.Property("LoginProvider") + .HasColumnType("nvarchar(450)"); + + b.Property("ProviderKey") + .HasColumnType("nvarchar(450)"); + + b.Property("ProviderDisplayName") + .HasColumnType("nvarchar(max)"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("LoginProvider", "ProviderKey"); + + b.HasIndex("UserId"); + + b.ToTable("AspNetUserLogins", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => + { + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.Property("RoleId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("UserId", "RoleId"); + + b.HasIndex("RoleId"); + + b.ToTable("AspNetUserRoles", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => + { + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.Property("LoginProvider") + .HasColumnType("nvarchar(450)"); + + b.Property("Name") + .HasColumnType("nvarchar(450)"); + + b.Property("Value") + .HasColumnType("nvarchar(max)"); + + b.HasKey("UserId", "LoginProvider", "Name"); + + b.ToTable("AspNetUserTokens", (string)null); + }); + + modelBuilder.Entity("Dynamics.Models.Models.History", b => + { + b.HasOne("Dynamics.Models.Models.Project", "Project") + .WithMany("History") + .HasForeignKey("ProjectID") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Project"); + }); + + modelBuilder.Entity("Dynamics.Models.Models.Notification", b => + { + b.HasOne("Dynamics.Models.Models.User", "User") + .WithMany("Notifications") + .HasForeignKey("UserID") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Dynamics.Models.Models.OrganizationMember", b => + { + b.HasOne("Dynamics.Models.Models.Organization", "Organization") + .WithMany("OrganizationMember") + .HasForeignKey("OrganizationID") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Dynamics.Models.Models.User", "User") + .WithMany("OrganizationMember") + .HasForeignKey("UserID") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Organization"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Dynamics.Models.Models.OrganizationResource", b => + { + b.HasOne("Dynamics.Models.Models.Organization", "Organization") + .WithMany("OrganizationResource") + .HasForeignKey("OrganizationID") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Organization"); + }); + + modelBuilder.Entity("Dynamics.Models.Models.OrganizationToProjectHistory", b => + { + b.HasOne("Dynamics.Models.Models.OrganizationResource", "OrganizationResource") + .WithMany("OrganizationToProjectHistory") + .HasForeignKey("OrganizationResourceID") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Dynamics.Models.Models.ProjectResource", "ProjectResource") + .WithMany("OrganizationToProjectHistory") + .HasForeignKey("ProjectResourceID") + .OnDelete(DeleteBehavior.NoAction); + + b.Navigation("OrganizationResource"); + + b.Navigation("ProjectResource"); + }); + + modelBuilder.Entity("Dynamics.Models.Models.Project", b => + { + b.HasOne("Dynamics.Models.Models.Organization", "Organization") + .WithMany("Project") + .HasForeignKey("OrganizationID") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Dynamics.Models.Models.Request", "Request") + .WithOne("Project") + .HasForeignKey("Dynamics.Models.Models.Project", "RequestID"); + + b.Navigation("Organization"); + + b.Navigation("Request"); + }); + + modelBuilder.Entity("Dynamics.Models.Models.ProjectMember", b => + { + b.HasOne("Dynamics.Models.Models.Project", "Project") + .WithMany("ProjectMember") + .HasForeignKey("ProjectID") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Dynamics.Models.Models.User", "User") + .WithMany("ProjectMember") + .HasForeignKey("UserID") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Project"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Dynamics.Models.Models.ProjectResource", b => + { + b.HasOne("Dynamics.Models.Models.Project", "Project") + .WithMany("ProjectResource") + .HasForeignKey("ProjectID") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Project"); + }); + + modelBuilder.Entity("Dynamics.Models.Models.Report", b => + { + b.HasOne("Dynamics.Models.Models.User", "Reporter") + .WithMany("ReportsMade") + .HasForeignKey("ReporterID") + .OnDelete(DeleteBehavior.NoAction); + + b.Navigation("Reporter"); + }); + + modelBuilder.Entity("Dynamics.Models.Models.Request", b => + { + b.HasOne("Dynamics.Models.Models.User", "User") + .WithMany("Request") + .HasForeignKey("UserID") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Dynamics.Models.Models.UserToOrganizationTransactionHistory", b => + { + b.HasOne("Dynamics.Models.Models.OrganizationResource", "OrganizationResource") + .WithMany("UserToOrganizationTransactionHistory") + .HasForeignKey("ResourceID") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Dynamics.Models.Models.User", "User") + .WithMany("UserToOrganizationTransactionHistories") + .HasForeignKey("UserID") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("OrganizationResource"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Dynamics.Models.Models.UserToProjectTransactionHistory", b => + { + b.HasOne("Dynamics.Models.Models.ProjectResource", "ProjectResource") + .WithMany("UserToProjectTransactionHistory") + .HasForeignKey("ProjectResourceID") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Dynamics.Models.Models.User", "User") + .WithMany("UserToProjectTransactionHistories") + .HasForeignKey("UserID") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("ProjectResource"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Dynamics.Models.Models.UserWalletTransaction", b => + { + b.HasOne("Dynamics.Models.Models.Wallet", "Wallet") + .WithMany("WalletTransactions") + .HasForeignKey("WalletId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Wallet"); + }); + + modelBuilder.Entity("Dynamics.Models.Models.Wallet", b => + { + b.HasOne("Dynamics.Models.Models.User", "User") + .WithOne("Wallet") + .HasForeignKey("Dynamics.Models.Models.Wallet", "UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Dynamics.Models.Models.Withdraw", b => + { + b.HasOne("Dynamics.Models.Models.Project", "Project") + .WithMany("Withdraw") + .HasForeignKey("ProjectID") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Project"); + }); + + 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("Dynamics.Models.Models.User", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => + { + b.HasOne("Dynamics.Models.Models.User", 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("Dynamics.Models.Models.User", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => + { + b.HasOne("Dynamics.Models.Models.User", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Dynamics.Models.Models.Organization", b => + { + b.Navigation("OrganizationMember"); + + b.Navigation("OrganizationResource"); + + b.Navigation("Project"); + }); + + modelBuilder.Entity("Dynamics.Models.Models.OrganizationResource", b => + { + b.Navigation("OrganizationToProjectHistory"); + + b.Navigation("UserToOrganizationTransactionHistory"); + }); + + modelBuilder.Entity("Dynamics.Models.Models.Project", b => + { + b.Navigation("History"); + + b.Navigation("ProjectMember"); + + b.Navigation("ProjectResource"); + + b.Navigation("Withdraw"); + }); + + modelBuilder.Entity("Dynamics.Models.Models.ProjectResource", b => + { + b.Navigation("OrganizationToProjectHistory"); + + b.Navigation("UserToProjectTransactionHistory"); + }); + + modelBuilder.Entity("Dynamics.Models.Models.Request", b => + { + b.Navigation("Project") + .IsRequired(); + }); + + modelBuilder.Entity("Dynamics.Models.Models.User", b => + { + b.Navigation("Notifications"); + + b.Navigation("OrganizationMember"); + + b.Navigation("ProjectMember"); + + b.Navigation("ReportsMade"); + + b.Navigation("Request"); + + b.Navigation("UserToOrganizationTransactionHistories"); + + b.Navigation("UserToProjectTransactionHistories"); + + b.Navigation("Wallet") + .IsRequired(); + }); + + modelBuilder.Entity("Dynamics.Models.Models.Wallet", b => + { + b.Navigation("WalletTransactions"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/Dynamics.DataAccess/Migrations/20241106220416_initial.cs b/Dynamics.DataAccess/Migrations/20241106220416_initial.cs new file mode 100644 index 00000000..c9d77eb0 --- /dev/null +++ b/Dynamics.DataAccess/Migrations/20241106220416_initial.cs @@ -0,0 +1,794 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace Dynamics.DataAccess.Migrations +{ + /// + public partial class initial : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "AspNetRoles", + columns: table => new + { + Id = table.Column(type: "uniqueidentifier", nullable: false), + Name = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: true), + NormalizedName = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: true), + ConcurrencyStamp = table.Column(type: "nvarchar(max)", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_AspNetRoles", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "AspNetUsers", + columns: table => new + { + Id = table.Column(type: "uniqueidentifier", nullable: false), + UserName = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: false), + UserDOB = table.Column(type: "date", nullable: true), + PhoneNumber = table.Column(type: "nvarchar(11)", maxLength: 11, nullable: true), + UserAddress = table.Column(type: "nvarchar(max)", nullable: true), + UserAvatar = table.Column(type: "nvarchar(max)", nullable: true), + UserDescription = table.Column(type: "nvarchar(1000)", maxLength: 1000, nullable: true), + isBanned = table.Column(type: "bit", nullable: false), + CreatedDate = table.Column(type: "datetime2", nullable: true), + NormalizedUserName = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: true), + Email = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: true), + NormalizedEmail = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: true), + EmailConfirmed = table.Column(type: "bit", nullable: false), + PasswordHash = table.Column(type: "nvarchar(max)", nullable: true), + SecurityStamp = table.Column(type: "nvarchar(max)", nullable: true), + ConcurrencyStamp = table.Column(type: "nvarchar(max)", nullable: true), + PhoneNumberConfirmed = table.Column(type: "bit", nullable: false), + TwoFactorEnabled = table.Column(type: "bit", nullable: false), + LockoutEnd = table.Column(type: "datetimeoffset", nullable: true), + LockoutEnabled = table.Column(type: "bit", nullable: false), + AccessFailedCount = table.Column(type: "int", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_AspNetUsers", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "Organizations", + columns: table => new + { + OrganizationID = table.Column(type: "uniqueidentifier", nullable: false), + OrganizationName = table.Column(type: "nvarchar(100)", maxLength: 100, nullable: false), + OrganizationEmail = table.Column(type: "nvarchar(450)", nullable: true), + OrganizationPhoneNumber = table.Column(type: "nvarchar(max)", nullable: true), + OrganizationAddress = table.Column(type: "nvarchar(max)", nullable: true), + OrganizationDescription = table.Column(type: "nvarchar(max)", nullable: false), + OrganizationPictures = table.Column(type: "nvarchar(max)", nullable: true), + StartTime = table.Column(type: "date", nullable: false), + ShutdownDay = table.Column(type: "date", nullable: true), + OrganizationStatus = table.Column(type: "int", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Organizations", x => x.OrganizationID); + }); + + migrationBuilder.CreateTable( + name: "AspNetRoleClaims", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + RoleId = table.Column(type: "uniqueidentifier", nullable: false), + ClaimType = table.Column(type: "nvarchar(max)", nullable: true), + ClaimValue = table.Column(type: "nvarchar(max)", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_AspNetRoleClaims", x => x.Id); + table.ForeignKey( + name: "FK_AspNetRoleClaims_AspNetRoles_RoleId", + column: x => x.RoleId, + principalTable: "AspNetRoles", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "AspNetUserClaims", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + UserId = table.Column(type: "uniqueidentifier", nullable: false), + ClaimType = table.Column(type: "nvarchar(max)", nullable: true), + ClaimValue = table.Column(type: "nvarchar(max)", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_AspNetUserClaims", x => x.Id); + table.ForeignKey( + name: "FK_AspNetUserClaims_AspNetUsers_UserId", + column: x => x.UserId, + principalTable: "AspNetUsers", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "AspNetUserLogins", + columns: table => new + { + LoginProvider = table.Column(type: "nvarchar(450)", nullable: false), + ProviderKey = table.Column(type: "nvarchar(450)", nullable: false), + ProviderDisplayName = table.Column(type: "nvarchar(max)", nullable: true), + UserId = table.Column(type: "uniqueidentifier", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_AspNetUserLogins", x => new { x.LoginProvider, x.ProviderKey }); + table.ForeignKey( + name: "FK_AspNetUserLogins_AspNetUsers_UserId", + column: x => x.UserId, + principalTable: "AspNetUsers", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "AspNetUserRoles", + columns: table => new + { + UserId = table.Column(type: "uniqueidentifier", nullable: false), + RoleId = table.Column(type: "uniqueidentifier", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_AspNetUserRoles", x => new { x.UserId, x.RoleId }); + table.ForeignKey( + name: "FK_AspNetUserRoles_AspNetRoles_RoleId", + column: x => x.RoleId, + principalTable: "AspNetRoles", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_AspNetUserRoles_AspNetUsers_UserId", + column: x => x.UserId, + principalTable: "AspNetUsers", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "AspNetUserTokens", + columns: table => new + { + UserId = table.Column(type: "uniqueidentifier", nullable: false), + LoginProvider = table.Column(type: "nvarchar(450)", nullable: false), + Name = table.Column(type: "nvarchar(450)", nullable: false), + Value = table.Column(type: "nvarchar(max)", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_AspNetUserTokens", x => new { x.UserId, x.LoginProvider, x.Name }); + table.ForeignKey( + name: "FK_AspNetUserTokens_AspNetUsers_UserId", + column: x => x.UserId, + principalTable: "AspNetUsers", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "Notifications", + columns: table => new + { + NotificationID = table.Column(type: "uniqueidentifier", nullable: false), + UserID = table.Column(type: "uniqueidentifier", nullable: false), + Message = table.Column(type: "nvarchar(max)", nullable: false), + Date = table.Column(type: "datetime2", nullable: false), + Link = table.Column(type: "nvarchar(max)", nullable: false), + Status = table.Column(type: "int", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Notifications", x => x.NotificationID); + table.ForeignKey( + name: "FK_Notifications_AspNetUsers_UserID", + column: x => x.UserID, + principalTable: "AspNetUsers", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "Reports", + columns: table => new + { + ReportID = table.Column(type: "uniqueidentifier", nullable: false), + ReporterID = table.Column(type: "uniqueidentifier", nullable: true), + ObjectID = table.Column(type: "uniqueidentifier", nullable: false), + Type = table.Column(type: "nvarchar(max)", nullable: false), + Reason = table.Column(type: "nvarchar(100)", maxLength: 100, nullable: false), + ReportDate = table.Column(type: "datetime2", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Reports", x => x.ReportID); + table.ForeignKey( + name: "FK_Reports_AspNetUsers_ReporterID", + column: x => x.ReporterID, + principalTable: "AspNetUsers", + principalColumn: "Id"); + }); + + migrationBuilder.CreateTable( + name: "Requests", + columns: table => new + { + RequestID = table.Column(type: "uniqueidentifier", nullable: false), + UserID = table.Column(type: "uniqueidentifier", nullable: false), + Content = table.Column(type: "nvarchar(max)", nullable: false), + CreationDate = table.Column(type: "datetime2", nullable: true), + RequestTitle = table.Column(type: "nvarchar(max)", nullable: false), + RequestEmail = table.Column(type: "nvarchar(max)", nullable: false), + RequestPhoneNumber = table.Column(type: "nvarchar(max)", nullable: false), + Location = table.Column(type: "nvarchar(max)", nullable: false), + Attachment = table.Column(type: "nvarchar(max)", nullable: true), + isEmergency = table.Column(type: "int", nullable: true), + Status = table.Column(type: "int", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Requests", x => x.RequestID); + table.ForeignKey( + name: "FK_Requests_AspNetUsers_UserID", + column: x => x.UserID, + principalTable: "AspNetUsers", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "Wallets", + columns: table => new + { + WalletId = table.Column(type: "uniqueidentifier", nullable: false), + Amount = table.Column(type: "int", nullable: false), + Currency = table.Column(type: "nvarchar(3)", maxLength: 3, nullable: false), + UserId = table.Column(type: "uniqueidentifier", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Wallets", x => x.WalletId); + table.ForeignKey( + name: "FK_Wallets_AspNetUsers_UserId", + column: x => x.UserId, + principalTable: "AspNetUsers", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "OrganizationMember", + columns: table => new + { + UserID = table.Column(type: "uniqueidentifier", nullable: false), + OrganizationID = table.Column(type: "uniqueidentifier", nullable: false), + Status = table.Column(type: "int", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_OrganizationMember", x => new { x.OrganizationID, x.UserID }); + table.ForeignKey( + name: "FK_OrganizationMember_AspNetUsers_UserID", + column: x => x.UserID, + principalTable: "AspNetUsers", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_OrganizationMember_Organizations_OrganizationID", + column: x => x.OrganizationID, + principalTable: "Organizations", + principalColumn: "OrganizationID", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "OrganizationResources", + columns: table => new + { + ResourceID = table.Column(type: "uniqueidentifier", nullable: false), + OrganizationID = table.Column(type: "uniqueidentifier", nullable: false), + ResourceName = table.Column(type: "nvarchar(max)", nullable: false), + Quantity = table.Column(type: "int", nullable: false), + Unit = table.Column(type: "nvarchar(max)", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_OrganizationResources", x => x.ResourceID); + table.ForeignKey( + name: "FK_OrganizationResources_Organizations_OrganizationID", + column: x => x.OrganizationID, + principalTable: "Organizations", + principalColumn: "OrganizationID", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "Projects", + columns: table => new + { + ProjectID = table.Column(type: "uniqueidentifier", nullable: false), + OrganizationID = table.Column(type: "uniqueidentifier", nullable: false), + RequestID = table.Column(type: "uniqueidentifier", nullable: true), + ProjectName = table.Column(type: "nvarchar(100)", maxLength: 100, nullable: false), + ProjectEmail = table.Column(type: "nvarchar(max)", nullable: true), + ProjectPhoneNumber = table.Column(type: "nvarchar(max)", nullable: true), + ProjectAddress = table.Column(type: "nvarchar(max)", nullable: false), + ProjectStatus = table.Column(type: "int", nullable: false), + Attachment = table.Column(type: "nvarchar(max)", nullable: true), + ReportFile = table.Column(type: "nvarchar(max)", nullable: true), + ProjectDescription = table.Column(type: "nvarchar(1000)", maxLength: 1000, nullable: false), + StartTime = table.Column(type: "date", nullable: true), + EndTime = table.Column(type: "date", nullable: true), + ShutdownReason = table.Column(type: "nvarchar(max)", nullable: true), + isBanned = table.Column(type: "bit", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Projects", x => x.ProjectID); + table.ForeignKey( + name: "FK_Projects_Organizations_OrganizationID", + column: x => x.OrganizationID, + principalTable: "Organizations", + principalColumn: "OrganizationID", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_Projects_Requests_RequestID", + column: x => x.RequestID, + principalTable: "Requests", + principalColumn: "RequestID"); + }); + + migrationBuilder.CreateTable( + name: "UserWalletTransactions", + columns: table => new + { + TransactionId = table.Column(type: "uniqueidentifier", nullable: false), + Amount = table.Column(type: "int", nullable: false), + Message = table.Column(type: "nvarchar(500)", maxLength: 500, nullable: true), + TransactionType = table.Column(type: "nvarchar(max)", nullable: false), + Time = table.Column(type: "datetime2", nullable: false), + WalletId = table.Column(type: "uniqueidentifier", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_UserWalletTransactions", x => x.TransactionId); + table.ForeignKey( + name: "FK_UserWalletTransactions_Wallets_WalletId", + column: x => x.WalletId, + principalTable: "Wallets", + principalColumn: "WalletId", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "UserToOrganizationTransactionHistories", + columns: table => new + { + TransactionID = table.Column(type: "uniqueidentifier", nullable: false), + ResourceID = table.Column(type: "uniqueidentifier", nullable: false), + UserID = table.Column(type: "uniqueidentifier", nullable: false), + Status = table.Column(type: "int", nullable: false), + Amount = table.Column(type: "int", nullable: false), + Message = table.Column(type: "nvarchar(max)", nullable: true), + Time = table.Column(type: "date", nullable: false), + Attachments = table.Column(type: "nvarchar(max)", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_UserToOrganizationTransactionHistories", x => x.TransactionID); + table.ForeignKey( + name: "FK_UserToOrganizationTransactionHistories_AspNetUsers_UserID", + column: x => x.UserID, + principalTable: "AspNetUsers", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_UserToOrganizationTransactionHistories_OrganizationResources_ResourceID", + column: x => x.ResourceID, + principalTable: "OrganizationResources", + principalColumn: "ResourceID", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "Histories", + columns: table => new + { + HistoryID = table.Column(type: "uniqueidentifier", nullable: false), + ProjectID = table.Column(type: "uniqueidentifier", nullable: false), + Phase = table.Column(type: "nvarchar(100)", maxLength: 100, nullable: false), + Date = table.Column(type: "date", nullable: false), + Content = table.Column(type: "nvarchar(1000)", maxLength: 1000, nullable: false), + Attachment = table.Column(type: "nvarchar(max)", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_Histories", x => x.HistoryID); + table.ForeignKey( + name: "FK_Histories_Projects_ProjectID", + column: x => x.ProjectID, + principalTable: "Projects", + principalColumn: "ProjectID", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "ProjectMembers", + columns: table => new + { + UserID = table.Column(type: "uniqueidentifier", nullable: false), + ProjectID = table.Column(type: "uniqueidentifier", nullable: false), + Status = table.Column(type: "int", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_ProjectMembers", x => new { x.ProjectID, x.UserID }); + table.ForeignKey( + name: "FK_ProjectMembers_AspNetUsers_UserID", + column: x => x.UserID, + principalTable: "AspNetUsers", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_ProjectMembers_Projects_ProjectID", + column: x => x.ProjectID, + principalTable: "Projects", + principalColumn: "ProjectID", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "ProjectResources", + columns: table => new + { + ResourceID = table.Column(type: "uniqueidentifier", nullable: false), + ProjectID = table.Column(type: "uniqueidentifier", nullable: false), + ResourceName = table.Column(type: "nvarchar(100)", maxLength: 100, nullable: false), + Quantity = table.Column(type: "int", nullable: true), + ExpectedQuantity = table.Column(type: "int", nullable: false), + Unit = table.Column(type: "nvarchar(100)", maxLength: 100, nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_ProjectResources", x => x.ResourceID); + table.ForeignKey( + name: "FK_ProjectResources_Projects_ProjectID", + column: x => x.ProjectID, + principalTable: "Projects", + principalColumn: "ProjectID", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "Withdraws", + columns: table => new + { + WithdrawID = table.Column(type: "uniqueidentifier", nullable: false), + ProjectID = table.Column(type: "uniqueidentifier", nullable: false), + Message = table.Column(type: "nvarchar(500)", maxLength: 500, nullable: true), + Time = table.Column(type: "datetime2", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Withdraws", x => x.WithdrawID); + table.ForeignKey( + name: "FK_Withdraws_Projects_ProjectID", + column: x => x.ProjectID, + principalTable: "Projects", + principalColumn: "ProjectID", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "OrganizationToProjectTransactionHistory", + columns: table => new + { + TransactionID = table.Column(type: "uniqueidentifier", nullable: false), + OrganizationResourceID = table.Column(type: "uniqueidentifier", nullable: false), + ProjectResourceID = table.Column(type: "uniqueidentifier", nullable: true), + Status = table.Column(type: "int", nullable: false), + Amount = table.Column(type: "int", nullable: false), + Message = table.Column(type: "nvarchar(100)", maxLength: 100, nullable: true), + Time = table.Column(type: "date", nullable: false), + Attachments = table.Column(type: "nvarchar(max)", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_OrganizationToProjectTransactionHistory", x => x.TransactionID); + table.ForeignKey( + name: "FK_OrganizationToProjectTransactionHistory_OrganizationResources_OrganizationResourceID", + column: x => x.OrganizationResourceID, + principalTable: "OrganizationResources", + principalColumn: "ResourceID", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_OrganizationToProjectTransactionHistory_ProjectResources_ProjectResourceID", + column: x => x.ProjectResourceID, + principalTable: "ProjectResources", + principalColumn: "ResourceID"); + }); + + migrationBuilder.CreateTable( + name: "UserToProjectTransactionHistories", + columns: table => new + { + TransactionID = table.Column(type: "uniqueidentifier", nullable: false), + ProjectResourceID = table.Column(type: "uniqueidentifier", nullable: false), + UserID = table.Column(type: "uniqueidentifier", nullable: false), + Status = table.Column(type: "int", nullable: false), + Amount = table.Column(type: "int", nullable: false), + Message = table.Column(type: "nvarchar(100)", maxLength: 100, nullable: true), + Time = table.Column(type: "date", nullable: false), + Attachments = table.Column(type: "nvarchar(max)", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_UserToProjectTransactionHistories", x => x.TransactionID); + table.ForeignKey( + name: "FK_UserToProjectTransactionHistories_AspNetUsers_UserID", + column: x => x.UserID, + principalTable: "AspNetUsers", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_UserToProjectTransactionHistories_ProjectResources_ProjectResourceID", + column: x => x.ProjectResourceID, + principalTable: "ProjectResources", + principalColumn: "ResourceID", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateIndex( + name: "IX_AspNetRoleClaims_RoleId", + table: "AspNetRoleClaims", + column: "RoleId"); + + migrationBuilder.CreateIndex( + name: "RoleNameIndex", + table: "AspNetRoles", + column: "NormalizedName", + unique: true, + filter: "[NormalizedName] IS NOT NULL"); + + migrationBuilder.CreateIndex( + name: "IX_AspNetUserClaims_UserId", + table: "AspNetUserClaims", + column: "UserId"); + + migrationBuilder.CreateIndex( + name: "IX_AspNetUserLogins_UserId", + table: "AspNetUserLogins", + column: "UserId"); + + migrationBuilder.CreateIndex( + name: "IX_AspNetUserRoles_RoleId", + table: "AspNetUserRoles", + column: "RoleId"); + + migrationBuilder.CreateIndex( + name: "EmailIndex", + table: "AspNetUsers", + column: "NormalizedEmail"); + + migrationBuilder.CreateIndex( + name: "IX_AspNetUsers_Email", + table: "AspNetUsers", + column: "Email", + unique: true, + filter: "[Email] IS NOT NULL"); + + migrationBuilder.CreateIndex( + name: "IX_AspNetUsers_UserName", + table: "AspNetUsers", + column: "UserName", + unique: true); + + migrationBuilder.CreateIndex( + name: "UserNameIndex", + table: "AspNetUsers", + column: "NormalizedUserName", + unique: true, + filter: "[NormalizedUserName] IS NOT NULL"); + + migrationBuilder.CreateIndex( + name: "IX_Histories_ProjectID", + table: "Histories", + column: "ProjectID"); + + migrationBuilder.CreateIndex( + name: "IX_Notifications_UserID", + table: "Notifications", + column: "UserID"); + + migrationBuilder.CreateIndex( + name: "IX_OrganizationMember_UserID", + table: "OrganizationMember", + column: "UserID"); + + migrationBuilder.CreateIndex( + name: "IX_OrganizationResources_OrganizationID", + table: "OrganizationResources", + column: "OrganizationID"); + + migrationBuilder.CreateIndex( + name: "IX_Organizations_OrganizationEmail", + table: "Organizations", + column: "OrganizationEmail", + unique: true, + filter: "[OrganizationEmail] IS NOT NULL"); + + migrationBuilder.CreateIndex( + name: "IX_Organizations_OrganizationName", + table: "Organizations", + column: "OrganizationName", + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_OrganizationToProjectTransactionHistory_OrganizationResourceID", + table: "OrganizationToProjectTransactionHistory", + column: "OrganizationResourceID"); + + migrationBuilder.CreateIndex( + name: "IX_OrganizationToProjectTransactionHistory_ProjectResourceID", + table: "OrganizationToProjectTransactionHistory", + column: "ProjectResourceID"); + + migrationBuilder.CreateIndex( + name: "IX_ProjectMembers_UserID", + table: "ProjectMembers", + column: "UserID"); + + migrationBuilder.CreateIndex( + name: "IX_ProjectResources_ProjectID", + table: "ProjectResources", + column: "ProjectID"); + + migrationBuilder.CreateIndex( + name: "IX_Projects_OrganizationID", + table: "Projects", + column: "OrganizationID"); + + migrationBuilder.CreateIndex( + name: "IX_Projects_RequestID", + table: "Projects", + column: "RequestID", + unique: true, + filter: "[RequestID] IS NOT NULL"); + + migrationBuilder.CreateIndex( + name: "IX_Reports_ReporterID", + table: "Reports", + column: "ReporterID"); + + migrationBuilder.CreateIndex( + name: "IX_Requests_UserID", + table: "Requests", + column: "UserID"); + + migrationBuilder.CreateIndex( + name: "IX_UserToOrganizationTransactionHistories_ResourceID", + table: "UserToOrganizationTransactionHistories", + column: "ResourceID"); + + migrationBuilder.CreateIndex( + name: "IX_UserToOrganizationTransactionHistories_UserID", + table: "UserToOrganizationTransactionHistories", + column: "UserID"); + + migrationBuilder.CreateIndex( + name: "IX_UserToProjectTransactionHistories_ProjectResourceID", + table: "UserToProjectTransactionHistories", + column: "ProjectResourceID"); + + migrationBuilder.CreateIndex( + name: "IX_UserToProjectTransactionHistories_UserID", + table: "UserToProjectTransactionHistories", + column: "UserID"); + + migrationBuilder.CreateIndex( + name: "IX_UserWalletTransactions_WalletId", + table: "UserWalletTransactions", + column: "WalletId"); + + migrationBuilder.CreateIndex( + name: "IX_Wallets_UserId", + table: "Wallets", + column: "UserId", + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_Withdraws_ProjectID", + table: "Withdraws", + column: "ProjectID"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "AspNetRoleClaims"); + + migrationBuilder.DropTable( + name: "AspNetUserClaims"); + + migrationBuilder.DropTable( + name: "AspNetUserLogins"); + + migrationBuilder.DropTable( + name: "AspNetUserRoles"); + + migrationBuilder.DropTable( + name: "AspNetUserTokens"); + + migrationBuilder.DropTable( + name: "Histories"); + + migrationBuilder.DropTable( + name: "Notifications"); + + migrationBuilder.DropTable( + name: "OrganizationMember"); + + migrationBuilder.DropTable( + name: "OrganizationToProjectTransactionHistory"); + + migrationBuilder.DropTable( + name: "ProjectMembers"); + + migrationBuilder.DropTable( + name: "Reports"); + + migrationBuilder.DropTable( + name: "UserToOrganizationTransactionHistories"); + + migrationBuilder.DropTable( + name: "UserToProjectTransactionHistories"); + + migrationBuilder.DropTable( + name: "UserWalletTransactions"); + + migrationBuilder.DropTable( + name: "Withdraws"); + + migrationBuilder.DropTable( + name: "AspNetRoles"); + + migrationBuilder.DropTable( + name: "OrganizationResources"); + + migrationBuilder.DropTable( + name: "ProjectResources"); + + migrationBuilder.DropTable( + name: "Wallets"); + + migrationBuilder.DropTable( + name: "Projects"); + + migrationBuilder.DropTable( + name: "Organizations"); + + migrationBuilder.DropTable( + name: "Requests"); + + migrationBuilder.DropTable( + name: "AspNetUsers"); + } + } +} diff --git a/Dynamics.DataAccess/Repository/ProjectMemberRepository.cs b/Dynamics.DataAccess/Repository/ProjectMemberRepository.cs index 502a29b8..3cff6383 100644 --- a/Dynamics.DataAccess/Repository/ProjectMemberRepository.cs +++ b/Dynamics.DataAccess/Repository/ProjectMemberRepository.cs @@ -68,13 +68,21 @@ public async Task AddJoinRequest(ProjectMember p) { var existingMember = await _context.ProjectMembers .FirstOrDefaultAsync(pm => pm.UserID == p.UserID && pm.ProjectID == p.ProjectID); - if (existingMember != null) { - // Optionally handle the case where the member already exists - return false; // or throw an exception as appropriate + if (existingMember.Status == 0 || existingMember.Status == -2)//has sent join request or has been invited + { + // Optionally handle the case where the member already exists + return false; // or throw an exception as appropriate + } + if(existingMember.Status == -1 ) + { + existingMember.Status = 0; + _context.ProjectMembers.Update(existingMember); + await _context.SaveChangesAsync(); + return true; + } } - await _context.ProjectMembers.AddAsync(p); await _context.SaveChangesAsync(); return true; @@ -115,6 +123,14 @@ await _context.ProjectMembers.FirstOrDefaultAsync(x => } public async Task InviteMemberAsync(Guid memberID, Guid projectID) { + var existingObj = await GetAsync(x=>x.UserID.Equals(memberID) && x.ProjectID.Equals(projectID)); + if (existingObj != null) + { + existingObj.Status = -2; + _context.ProjectMembers.Update(existingObj); + await _context.SaveChangesAsync(); + return true; + } await _context.ProjectMembers.AddAsync(new ProjectMember() { UserID = memberID, diff --git a/Dynamics/Areas/Identity/Pages/Account/ExternalLogin.cshtml.cs b/Dynamics/Areas/Identity/Pages/Account/ExternalLogin.cshtml.cs index 9fcba6ee..f4746bd9 100644 --- a/Dynamics/Areas/Identity/Pages/Account/ExternalLogin.cshtml.cs +++ b/Dynamics/Areas/Identity/Pages/Account/ExternalLogin.cshtml.cs @@ -120,11 +120,6 @@ public async Task OnGetCallbackAsync(string returnUrl = null, str _logger.LogInformation("{Name} logged in with {LoginProvider} provider.", info.Principal.Identity.Name, info.LoginProvider); await _signInManager.SignInAsync(existingUser, isPersistent: false, authenticationMethod: null); - if (User.IsInRole(RoleConstants.Admin)) - { - return RedirectToAction("Index", "Home", new { area = "Admin" }); - } - if (returnUrl.Contains("JoinProjectRequest")) { returnUrl = returnUrl.Replace("memberid=00000000-0000-0000-0000-000000000000", @@ -144,10 +139,6 @@ public async Task OnGetCallbackAsync(string returnUrl = null, str HttpContext.Session.SetString("currentUserID", businessUser.Id.ToString()); _logger.LogInformation("{Name} logged in with {LoginProvider} provider.", info.Principal.Identity.Name, info.LoginProvider); - if (User.IsInRole(RoleConstants.Admin) && result.Succeeded) - { - return RedirectToAction("Index", "Home", new { area = "Admin" }); - } return Redirect(returnUrl); } diff --git a/Dynamics/Controllers/ProjectController.cs b/Dynamics/Controllers/ProjectController.cs index ec90a1b1..8e76a25a 100644 --- a/Dynamics/Controllers/ProjectController.cs +++ b/Dynamics/Controllers/ProjectController.cs @@ -502,7 +502,7 @@ public async Task GetUsersNotInProject(string key) var users = await _userRepository.GetAllUsersAsync(); var usersInProject = _projectService.FilterMemberOfProject(p => - p.ProjectID.Equals(new Guid(currentProjectID)) && p.Status > 0); + p.ProjectID.Equals(new Guid(currentProjectID)) && p.Status >= 0 || p.Status ==-2); var usersNotInProject = users.Where(u => !usersInProject.Any(up => up.Id == u.Id)); // Return as JSON (you could also return a PartialView) if (!string.IsNullOrEmpty(key)) @@ -563,7 +563,13 @@ public async Task InviteMembers(string userIds) var linkLeader = Url.Action(nameof(CancelJoinInvitation), "Project", new { projectId = new Guid(currentProjectID), memberId = userId }, Request.Scheme); //send to user and leader - await _notificationService.InviteProjectMemberRequestNotificationAsync(projectObj, user, linkUser, + var userString = HttpContext.Session.GetString("user"); + User currentUser = null; + if (userString != null) + { + currentUser = JsonConvert.DeserializeObject(userString); + } + await _notificationService.InviteProjectMemberRequestNotificationAsync(projectObj, user, currentUser,linkUser, linkLeader); } @@ -679,7 +685,7 @@ public async Task JoinProjectRequest(Guid memberID, Guid projectI } else if (res.Equals(MyConstants.Warning)) { - TempData[MyConstants.Warning] = "Already sent another join request!"; + TempData[MyConstants.Warning] = "Already sent another join request or has received an invitation from this project!"; TempData[MyConstants.Subtitle] = "Please wait for the project leader response!"; } else if (res.Equals(MyConstants.Error)) diff --git a/Dynamics/Services/INotificationService.cs b/Dynamics/Services/INotificationService.cs index cfa2b1ca..14d03ac4 100644 --- a/Dynamics/Services/INotificationService.cs +++ b/Dynamics/Services/INotificationService.cs @@ -11,7 +11,7 @@ public interface INotificationService Task ProcessProjectDonationNotificationAsync(Guid projectId,Guid? transId, string link, string type); Task ProcessProjectPhaseNotificationAsync(Guid projectId, string link, string type); Task AddProjectResourceNotificationAsync(Guid projectId, string link); - Task InviteProjectMemberRequestNotificationAsync(Project projectObj, User member, string linkUser, string linkLeader); + Task InviteProjectMemberRequestNotificationAsync(Project projectObj, User member,User sender, string linkUser, string linkLeader); Task ProcessInviteProjectMemberRequestNotificationAsync(Project project, User member, string link, string type); Task UpdateOrganizationNotificationAsync(Guid organizationId, string link); Task ProcessOrganizationDonationNotificationAsync(Guid organizationId, Guid? transId, string link, string type); diff --git a/Dynamics/Services/NotificationService.cs b/Dynamics/Services/NotificationService.cs index 3d166ee8..17a7061e 100644 --- a/Dynamics/Services/NotificationService.cs +++ b/Dynamics/Services/NotificationService.cs @@ -56,7 +56,7 @@ public async Task JoinProjectRequestNotificationAsync(Project project, string li }; await _notifRepo.AddNotificationAsync(notif); } - public async Task InviteProjectMemberRequestNotificationAsync(Project projectObj, User member, string linkUser, string linkLeader) + public async Task InviteProjectMemberRequestNotificationAsync(Project projectObj, User member,User sender, string linkUser, string linkLeader) { var notif = new Notification { @@ -68,12 +68,11 @@ public async Task InviteProjectMemberRequestNotificationAsync(Project projectObj Status = 0 // Unread }; await _notifRepo.AddNotificationAsync(notif); - - var leaderOfProject = await GetProjectLeaderAsync(projectObj.ProjectID); + var notifLeader = new Notification { NotificationID = Guid.NewGuid(), - UserID = leaderOfProject.Id, + UserID = sender.Id, Message = $"You have sent an invitation to \"{member.UserName}\" to join your project {projectObj.ProjectName}.\nClick this notification to cancel the invitation!", Date = DateTime.Now, Link = linkLeader, diff --git a/Dynamics/Services/ProjectService.cs b/Dynamics/Services/ProjectService.cs index 94af1f5e..ce709fc2 100644 --- a/Dynamics/Services/ProjectService.cs +++ b/Dynamics/Services/ProjectService.cs @@ -541,7 +541,6 @@ public async Task SendJoinProjectRequestAsync(Guid projectID, Guid membe { return MyConstants.Success; } - return MyConstants.Error; } if (existingJoinRequest.Status == -1) // Denied, update from -1 -> 0 diff --git a/Dynamics/Views/Home/Index.cshtml b/Dynamics/Views/Home/Index.cshtml index 2dd4cac5..2a937950 100644 --- a/Dynamics/Views/Home/Index.cshtml +++ b/Dynamics/Views/Home/Index.cshtml @@ -30,25 +30,25 @@

Discover

- + diff --git a/Dynamics/Views/Organization/Edit.cshtml b/Dynamics/Views/Organization/Edit.cshtml index ffb42a53..4b5f0b59 100644 --- a/Dynamics/Views/Organization/Edit.cshtml +++ b/Dynamics/Views/Organization/Edit.cshtml @@ -14,7 +14,7 @@ If you are a member of an organization, tell your leader to accept this request instead!

- +
@@ -81,7 +81,8 @@
- + @* *@ +
diff --git a/Dynamics/Views/Organization/ManageOrganizationResource.cshtml b/Dynamics/Views/Organization/ManageOrganizationResource.cshtml index 831d7900..4513e17d 100644 --- a/Dynamics/Views/Organization/ManageOrganizationResource.cshtml +++ b/Dynamics/Views/Organization/ManageOrganizationResource.cshtml @@ -377,7 +377,6 @@ else
- @*
- + @@ -178,7 +178,7 @@ - @@ -458,9 +458,25 @@ notificationMessage.innerText = "Please upload at least one proof image."; notificationMessage.style.display = "block"; } else { - notificationMessage.style.display = "none"; // Hide the message if files are selected + notificationMessage.style.display = "none"; + this.submit(); + document.getElementById("closeAcceptModel").submit(); + openLoading(); + } + }); + function openLoading(){ + Swal.fire({ + title: "Processing...", + text: "Please wait while your request is being processed", + icon: "info", + allowOutsideClick: false, + allowEscapeKey: false, + showConfirmButton: false, + didOpen: () => { + Swal.showLoading(); + } + }); } - }); //modal of proof image function openImageModal(imgSrc) { document.getElementById('modalImage').src = imgSrc; diff --git a/Dynamics/Views/Project/AddProjectPhaseReport.cshtml b/Dynamics/Views/Project/AddProjectPhaseReport.cshtml index 1ebd2813..463b9b5f 100644 --- a/Dynamics/Views/Project/AddProjectPhaseReport.cshtml +++ b/Dynamics/Views/Project/AddProjectPhaseReport.cshtml @@ -28,7 +28,7 @@

Create phase report

-
+
@@ -36,7 +36,7 @@ + required />
@@ -64,14 +64,14 @@
- -
- The date that your phase starts. - - + required /> +
+ The date that your phase starts. + +
@@ -88,6 +88,7 @@
+ diff --git a/Dynamics/Views/Project/ReviewUserDonateRequest.cshtml b/Dynamics/Views/Project/ReviewUserDonateRequest.cshtml index 8c2eb28d..0ad1d0b0 100644 --- a/Dynamics/Views/Project/ReviewUserDonateRequest.cshtml +++ b/Dynamics/Views/Project/ReviewUserDonateRequest.cshtml @@ -30,6 +30,7 @@

Review donate request

+ Make sure you contacted and received the resources before marking as accepted!
@@ -119,6 +120,7 @@ - @@ -222,7 +224,8 @@
- + + - + diff --git a/Dynamics/Views/Project/UpdateProjectProfile.cshtml b/Dynamics/Views/Project/UpdateProjectProfile.cshtml index 6f7d0f7a..d4f36abe 100644 --- a/Dynamics/Views/Project/UpdateProjectProfile.cshtml +++ b/Dynamics/Views/Project/UpdateProjectProfile.cshtml @@ -355,7 +355,7 @@ - +@await Html.PartialAsync("CustomComponent/_LoadingModalSweet", "user-information") @*Bank script*@ + \ No newline at end of file diff --git a/Dynamics/Views/Shared/CustomComponent/_LoadingModalSweet.cshtml b/Dynamics/Views/Shared/CustomComponent/_LoadingModalSweet.cshtml index 6ec9b7ef..37e8c1e6 100644 --- a/Dynamics/Views/Shared/CustomComponent/_LoadingModalSweet.cshtml +++ b/Dynamics/Views/Shared/CustomComponent/_LoadingModalSweet.cshtml @@ -37,4 +37,4 @@ This thing work the same as the loading modal, except it triggers a swal pop up* } catch (e) { console.log(e) } - \ No newline at end of file + diff --git a/Dynamics/Views/Shared/CustomComponent/_NavbarProject.cshtml b/Dynamics/Views/Shared/CustomComponent/_NavbarProject.cshtml index eb8f04f6..eb2f8a76 100644 --- a/Dynamics/Views/Shared/CustomComponent/_NavbarProject.cshtml +++ b/Dynamics/Views/Shared/CustomComponent/_NavbarProject.cshtml @@ -50,7 +50,7 @@ ||ViewContext.RouteData.Values["action"]?.ToString() =="UpdateProjectProfile" ||ViewContext.RouteData.Values["action"]?.ToString() =="ShutdownProject" ||ViewContext.RouteData.Values["action"]?.ToString() =="ImportFileProject" - ? "bg-gray-800 text-white font-bold" : "text-gray-500 hover:text-white hover:bg-gray-800")"> + ? "bg-gray-800 text-white font-bold " : "text-gray-500 hover:text-white hover:bg-gray-800 ")"> Details
-
+