diff --git a/Server/ReasnAPI/ReasnAPI/Models/Database/Address.cs b/Server/ReasnAPI/ReasnAPI/Models/Database/Address.cs new file mode 100644 index 00000000..e7419ff9 --- /dev/null +++ b/Server/ReasnAPI/ReasnAPI/Models/Database/Address.cs @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; + +namespace ReasnAPI.Models.Database; + +public partial class Address +{ + public int Id { get; set; } + + public string City { get; set; } = null!; + + public string Country { get; set; } = null!; + + public string Street { get; set; } = null!; + + public string State { get; set; } = null!; + + public string? ZipCode { get; set; } + + public virtual ICollection Events { get; set; } = new List(); + + public virtual ICollection Users { get; set; } = new List(); +} diff --git a/Server/ReasnAPI/ReasnAPI/Models/Database/Comment.cs b/Server/ReasnAPI/ReasnAPI/Models/Database/Comment.cs new file mode 100644 index 00000000..2feb191a --- /dev/null +++ b/Server/ReasnAPI/ReasnAPI/Models/Database/Comment.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; + +namespace ReasnAPI.Models.Database; + +public partial class Comment +{ + public int Id { get; set; } + + public int EventId { get; set; } + + public string Content { get; set; } = null!; + + public DateTime CreatedAt { get; set; } + + public int UserId { get; set; } + + public virtual Event Event { get; set; } = null!; + + public virtual User User { get; set; } = null!; +} diff --git a/Server/ReasnAPI/ReasnAPI/Models/Database/Event.cs b/Server/ReasnAPI/ReasnAPI/Models/Database/Event.cs new file mode 100644 index 00000000..e8bceabc --- /dev/null +++ b/Server/ReasnAPI/ReasnAPI/Models/Database/Event.cs @@ -0,0 +1,39 @@ +using System; +using System.Collections.Generic; + +namespace ReasnAPI.Models.Database; + +public partial class Event +{ + public int Id { get; set; } + + public string Name { get; set; } = null!; + + public int AddressId { get; set; } + + public string Description { get; set; } = null!; + + public int OrganizerId { get; set; } + + public DateTime StartAt { get; set; } + + public DateTime EndAt { get; set; } + + public DateTime CreatedAt { get; set; } + + public DateTime UpdatedAt { get; set; } + + public string Slug { get; set; } = null!; + + public int StatusId { get; set; } + + public virtual Address Address { get; set; } = null!; + + public virtual ICollection Comments { get; set; } = new List(); + + public virtual User Organizer { get; set; } = null!; + + public virtual ICollection Participants { get; set; } = new List(); + + public virtual Status Status { get; set; } = null!; +} diff --git a/Server/ReasnAPI/ReasnAPI/Models/Database/EventParameter.cs b/Server/ReasnAPI/ReasnAPI/Models/Database/EventParameter.cs new file mode 100644 index 00000000..32fa03fc --- /dev/null +++ b/Server/ReasnAPI/ReasnAPI/Models/Database/EventParameter.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; + +namespace ReasnAPI.Models.Database; + +public partial class EventParameter +{ + public int ParameterId { get; set; } + + public int EventId { get; set; } + + public virtual Event Event { get; set; } = null!; + + public virtual Parameter Parameter { get; set; } = null!; +} diff --git a/Server/ReasnAPI/ReasnAPI/Models/Database/EventTag.cs b/Server/ReasnAPI/ReasnAPI/Models/Database/EventTag.cs new file mode 100644 index 00000000..e641f72d --- /dev/null +++ b/Server/ReasnAPI/ReasnAPI/Models/Database/EventTag.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; + +namespace ReasnAPI.Models.Database; + +public partial class EventTag +{ + public int EventId { get; set; } + + public int TagId { get; set; } + + public virtual Event Event { get; set; } = null!; + + public virtual Tag Tag { get; set; } = null!; +} diff --git a/Server/ReasnAPI/ReasnAPI/Models/Database/Image.cs b/Server/ReasnAPI/ReasnAPI/Models/Database/Image.cs new file mode 100644 index 00000000..0bf25075 --- /dev/null +++ b/Server/ReasnAPI/ReasnAPI/Models/Database/Image.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; + +namespace ReasnAPI.Models.Database; + +public partial class Image +{ + public int Id { get; set; } + + public byte[] ImageData { get; set; } = null!; + + public int ObjectTypeId { get; set; } + + public int ObjectId { get; set; } + + public virtual ObjectType ObjectType { get; set; } = null!; +} diff --git a/Server/ReasnAPI/ReasnAPI/Models/Database/Interest.cs b/Server/ReasnAPI/ReasnAPI/Models/Database/Interest.cs new file mode 100644 index 00000000..56c89b91 --- /dev/null +++ b/Server/ReasnAPI/ReasnAPI/Models/Database/Interest.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; + +namespace ReasnAPI.Models.Database; + +public partial class Interest +{ + public int Id { get; set; } + + public string Name { get; set; } = null!; + + public int Level { get; set; } +} diff --git a/Server/ReasnAPI/ReasnAPI/Models/Database/ObjectType.cs b/Server/ReasnAPI/ReasnAPI/Models/Database/ObjectType.cs new file mode 100644 index 00000000..c02354eb --- /dev/null +++ b/Server/ReasnAPI/ReasnAPI/Models/Database/ObjectType.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; + +namespace ReasnAPI.Models.Database; + +public partial class ObjectType +{ + public int Id { get; set; } + + public string Name { get; set; } = null!; + + public virtual ICollection Images { get; set; } = new List(); + + public virtual ICollection Statuses { get; set; } = new List(); +} diff --git a/Server/ReasnAPI/ReasnAPI/Models/Database/Parameter.cs b/Server/ReasnAPI/ReasnAPI/Models/Database/Parameter.cs new file mode 100644 index 00000000..f1d4d72a --- /dev/null +++ b/Server/ReasnAPI/ReasnAPI/Models/Database/Parameter.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; + +namespace ReasnAPI.Models.Database; + +public partial class Parameter +{ + public int Id { get; set; } + + public string Key { get; set; } = null!; + + public string Value { get; set; } = null!; +} diff --git a/Server/ReasnAPI/ReasnAPI/Models/Database/Participant.cs b/Server/ReasnAPI/ReasnAPI/Models/Database/Participant.cs new file mode 100644 index 00000000..3c867a77 --- /dev/null +++ b/Server/ReasnAPI/ReasnAPI/Models/Database/Participant.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; + +namespace ReasnAPI.Models.Database; + +public partial class Participant +{ + public int Id { get; set; } + + public int EventId { get; set; } + + public int UserId { get; set; } + + public int StatusId { get; set; } + + public virtual Event Event { get; set; } = null!; + + public virtual Status Status { get; set; } = null!; + + public virtual User User { get; set; } = null!; +} diff --git a/Server/ReasnAPI/ReasnAPI/Models/Database/ReasnContext.cs b/Server/ReasnAPI/ReasnAPI/Models/Database/ReasnContext.cs new file mode 100644 index 00000000..aa4c646a --- /dev/null +++ b/Server/ReasnAPI/ReasnAPI/Models/Database/ReasnContext.cs @@ -0,0 +1,372 @@ +using System; +using System.Collections.Generic; +using Microsoft.EntityFrameworkCore; + +namespace ReasnAPI.Models.Database; + +public partial class ReasnContext : DbContext +{ + public ReasnContext() + { + } + + public ReasnContext(DbContextOptions options) + : base(options) + { + } + + public virtual DbSet
Addresses { get; set; } + + public virtual DbSet Comments { get; set; } + + public virtual DbSet Events { get; set; } + + public virtual DbSet EventParameters { get; set; } + + public virtual DbSet EventTags { get; set; } + + public virtual DbSet Images { get; set; } + + public virtual DbSet Interests { get; set; } + + public virtual DbSet ObjectTypes { get; set; } + + public virtual DbSet Parameters { get; set; } + + public virtual DbSet Participants { get; set; } + + public virtual DbSet Roles { get; set; } + + public virtual DbSet Statuses { get; set; } + + public virtual DbSet Tags { get; set; } + + public virtual DbSet Users { get; set; } + + public virtual DbSet UserInterests { get; set; } + + protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) + => optionsBuilder.UseNpgsql("name=ConnectionStrings:DefaultValue"); + + protected override void OnModelCreating(ModelBuilder modelBuilder) + { + modelBuilder.Entity
(entity => + { + entity.HasKey(e => e.Id).HasName("address_pkey"); + + entity.ToTable("address", "common"); + + entity.Property(e => e.Id).HasColumnName("id"); + entity.Property(e => e.City) + .HasMaxLength(255) + .HasColumnName("city"); + entity.Property(e => e.Country) + .HasMaxLength(255) + .HasColumnName("country"); + entity.Property(e => e.State) + .HasMaxLength(255) + .HasColumnName("state"); + entity.Property(e => e.Street) + .HasMaxLength(255) + .HasColumnName("street"); + entity.Property(e => e.ZipCode) + .HasMaxLength(255) + .HasColumnName("zip_code"); + }); + + modelBuilder.Entity(entity => + { + entity.HasKey(e => e.Id).HasName("comment_pkey"); + + entity.ToTable("comment", "events"); + + entity.Property(e => e.Id).HasColumnName("id"); + entity.Property(e => e.Content) + .HasMaxLength(255) + .HasColumnName("content"); + entity.Property(e => e.CreatedAt).HasColumnName("created_at"); + entity.Property(e => e.EventId).HasColumnName("event_id"); + entity.Property(e => e.UserId).HasColumnName("user_id"); + + entity.HasOne(d => d.Event).WithMany(p => p.Comments) + .HasForeignKey(d => d.EventId) + .OnDelete(DeleteBehavior.ClientSetNull) + .HasConstraintName("comment_event_id_fkey"); + + entity.HasOne(d => d.User).WithMany(p => p.Comments) + .HasForeignKey(d => d.UserId) + .OnDelete(DeleteBehavior.ClientSetNull) + .HasConstraintName("comment_user_id_fkey"); + }); + + modelBuilder.Entity(entity => + { + entity.HasKey(e => e.Id).HasName("event_pkey"); + + entity.ToTable("event", "events"); + + entity.Property(e => e.Id).HasColumnName("id"); + entity.Property(e => e.AddressId).HasColumnName("address_id"); + entity.Property(e => e.CreatedAt).HasColumnName("created_at"); + entity.Property(e => e.Description).HasColumnName("description"); + entity.Property(e => e.EndAt).HasColumnName("end_at"); + entity.Property(e => e.Name) + .HasColumnType("character varying") + .HasColumnName("name"); + entity.Property(e => e.OrganizerId).HasColumnName("organizer_id"); + entity.Property(e => e.Slug) + .HasColumnType("character varying") + .HasColumnName("slug"); + entity.Property(e => e.StartAt).HasColumnName("start_at"); + entity.Property(e => e.StatusId).HasColumnName("status_id"); + entity.Property(e => e.UpdatedAt).HasColumnName("updated_at"); + + entity.HasOne(d => d.Address).WithMany(p => p.Events) + .HasForeignKey(d => d.AddressId) + .OnDelete(DeleteBehavior.ClientSetNull) + .HasConstraintName("event_address_id_fkey"); + + entity.HasOne(d => d.Organizer).WithMany(p => p.Events) + .HasForeignKey(d => d.OrganizerId) + .OnDelete(DeleteBehavior.ClientSetNull) + .HasConstraintName("event_organizer_id_fkey"); + + entity.HasOne(d => d.Status).WithMany(p => p.Events) + .HasForeignKey(d => d.StatusId) + .OnDelete(DeleteBehavior.ClientSetNull) + .HasConstraintName("event_status_id_fkey"); + }); + + modelBuilder.Entity(entity => + { + entity + .HasNoKey() + .ToTable("event_parameter", "events"); + + entity.Property(e => e.EventId).HasColumnName("event_id"); + entity.Property(e => e.ParameterId).HasColumnName("parameter_id"); + + entity.HasOne(d => d.Event).WithMany() + .HasForeignKey(d => d.EventId) + .OnDelete(DeleteBehavior.ClientSetNull) + .HasConstraintName("event_parameter_event_id_fkey"); + + entity.HasOne(d => d.Parameter).WithMany() + .HasForeignKey(d => d.ParameterId) + .OnDelete(DeleteBehavior.ClientSetNull) + .HasConstraintName("event_parameter_parameter_id_fkey"); + }); + + modelBuilder.Entity(entity => + { + entity + .HasNoKey() + .ToTable("event_tag", "events"); + + entity.Property(e => e.EventId).HasColumnName("event_id"); + entity.Property(e => e.TagId).HasColumnName("tag_id"); + + entity.HasOne(d => d.Event).WithMany() + .HasForeignKey(d => d.EventId) + .OnDelete(DeleteBehavior.ClientSetNull) + .HasConstraintName("event_tag_event_id_fkey"); + + entity.HasOne(d => d.Tag).WithMany() + .HasForeignKey(d => d.TagId) + .OnDelete(DeleteBehavior.ClientSetNull) + .HasConstraintName("event_tag_tag_id_fkey"); + }); + + modelBuilder.Entity(entity => + { + entity.HasKey(e => e.Id).HasName("image_pkey"); + + entity.ToTable("image", "common"); + + entity.Property(e => e.Id).HasColumnName("id"); + entity.Property(e => e.ImageData).HasColumnName("image_data"); + entity.Property(e => e.ObjectId).HasColumnName("object_id"); + entity.Property(e => e.ObjectTypeId).HasColumnName("object_type_id"); + + entity.HasOne(d => d.ObjectType).WithMany(p => p.Images) + .HasForeignKey(d => d.ObjectTypeId) + .OnDelete(DeleteBehavior.ClientSetNull) + .HasConstraintName("image_object_type_id_fkey"); + }); + + modelBuilder.Entity(entity => + { + entity.HasKey(e => e.Id).HasName("interest_pkey"); + + entity.ToTable("interest", "users"); + + entity.Property(e => e.Id).HasColumnName("id"); + entity.Property(e => e.Level).HasColumnName("level"); + entity.Property(e => e.Name) + .HasMaxLength(255) + .HasColumnName("name"); + }); + + modelBuilder.Entity(entity => + { + entity.HasKey(e => e.Id).HasName("object_type_pkey"); + + entity.ToTable("object_type", "common"); + + entity.Property(e => e.Id).HasColumnName("id"); + entity.Property(e => e.Name) + .HasMaxLength(255) + .HasColumnName("name"); + }); + + modelBuilder.Entity(entity => + { + entity.HasKey(e => e.Id).HasName("parameter_pkey"); + + entity.ToTable("parameter", "events"); + + entity.Property(e => e.Id).HasColumnName("id"); + entity.Property(e => e.Key) + .HasMaxLength(255) + .HasColumnName("key"); + entity.Property(e => e.Value) + .HasMaxLength(255) + .HasColumnName("value"); + }); + + modelBuilder.Entity(entity => + { + entity.HasKey(e => e.Id).HasName("participant_pkey"); + + entity.ToTable("participant", "events"); + + entity.Property(e => e.Id).HasColumnName("id"); + entity.Property(e => e.EventId).HasColumnName("event_id"); + entity.Property(e => e.StatusId).HasColumnName("status_id"); + entity.Property(e => e.UserId).HasColumnName("user_id"); + + entity.HasOne(d => d.Event).WithMany(p => p.Participants) + .HasForeignKey(d => d.EventId) + .OnDelete(DeleteBehavior.ClientSetNull) + .HasConstraintName("participant_event_id_fkey"); + + entity.HasOne(d => d.Status).WithMany(p => p.Participants) + .HasForeignKey(d => d.StatusId) + .OnDelete(DeleteBehavior.ClientSetNull) + .HasConstraintName("participant_status_id_fkey"); + + entity.HasOne(d => d.User).WithMany(p => p.Participants) + .HasForeignKey(d => d.UserId) + .OnDelete(DeleteBehavior.ClientSetNull) + .HasConstraintName("participant_user_id_fkey"); + }); + + modelBuilder.Entity(entity => + { + entity.HasKey(e => e.Id).HasName("role_pkey"); + + entity.ToTable("role", "users"); + + entity.Property(e => e.Id).HasColumnName("id"); + entity.Property(e => e.Name) + .HasMaxLength(255) + .HasColumnName("name"); + }); + + modelBuilder.Entity(entity => + { + entity.HasKey(e => e.Id).HasName("status_pkey"); + + entity.ToTable("status", "common"); + + entity.Property(e => e.Id).HasColumnName("id"); + entity.Property(e => e.Name) + .HasMaxLength(255) + .HasColumnName("name"); + entity.Property(e => e.ObjectTypeId).HasColumnName("object_type_id"); + + entity.HasOne(d => d.ObjectType).WithMany(p => p.Statuses) + .HasForeignKey(d => d.ObjectTypeId) + .OnDelete(DeleteBehavior.ClientSetNull) + .HasConstraintName("status_object_type_id_fkey"); + }); + + modelBuilder.Entity(entity => + { + entity.HasKey(e => e.Id).HasName("tag_pkey"); + + entity.ToTable("tag", "events"); + + entity.Property(e => e.Id).HasColumnName("id"); + entity.Property(e => e.Name) + .HasMaxLength(255) + .HasColumnName("name"); + }); + + modelBuilder.Entity(entity => + { + entity.HasKey(e => e.Id).HasName("user_pkey"); + + entity.ToTable("user", "users"); + + entity.Property(e => e.Id).HasColumnName("id"); + entity.Property(e => e.AddressId).HasColumnName("address_id"); + entity.Property(e => e.CreatedAt).HasColumnName("created_at"); + entity.Property(e => e.Email) + .HasMaxLength(255) + .HasColumnName("email"); + entity.Property(e => e.IsActive).HasColumnName("is_active"); + entity.Property(e => e.Name) + .HasMaxLength(255) + .HasColumnName("name"); + entity.Property(e => e.Password) + .HasMaxLength(255) + .HasColumnName("password"); + entity.Property(e => e.Phone) + .HasMaxLength(255) + .HasColumnName("phone"); + entity.Property(e => e.RoleId).HasColumnName("role_id"); + entity.Property(e => e.Surname) + .HasMaxLength(255) + .HasColumnName("surname"); + entity.Property(e => e.UpdatedAt).HasColumnName("updated_at"); + entity.Property(e => e.Username) + .HasMaxLength(255) + .HasColumnName("username"); + + entity.HasOne(d => d.Address).WithMany(p => p.Users) + .HasForeignKey(d => d.AddressId) + .OnDelete(DeleteBehavior.ClientSetNull) + .HasConstraintName("user_address_id_fkey"); + + entity.HasOne(d => d.Role).WithMany(p => p.Users) + .HasForeignKey(d => d.RoleId) + .OnDelete(DeleteBehavior.ClientSetNull) + .HasConstraintName("user_role_id_fkey"); + }); + + modelBuilder.Entity(entity => + { + entity + .HasNoKey() + .ToTable("user_interest", "users"); + + entity.Property(e => e.InterestId).HasColumnName("interest_id"); + entity.Property(e => e.UserId).HasColumnName("user_id"); + + entity.HasOne(d => d.Interest).WithMany() + .HasForeignKey(d => d.InterestId) + .OnDelete(DeleteBehavior.ClientSetNull) + .HasConstraintName("user_interest_interest_id_fkey"); + + entity.HasOne(d => d.User).WithMany() + .HasForeignKey(d => d.UserId) + .OnDelete(DeleteBehavior.ClientSetNull) + .HasConstraintName("user_interest_user_id_fkey"); + }); + + OnModelCreatingPartial(modelBuilder); + } + + partial void OnModelCreatingPartial(ModelBuilder modelBuilder); +} diff --git a/Server/ReasnAPI/ReasnAPI/Models/Database/Role.cs b/Server/ReasnAPI/ReasnAPI/Models/Database/Role.cs new file mode 100644 index 00000000..a996e058 --- /dev/null +++ b/Server/ReasnAPI/ReasnAPI/Models/Database/Role.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; + +namespace ReasnAPI.Models.Database; + +public partial class Role +{ + public int Id { get; set; } + + public string Name { get; set; } = null!; + + public virtual ICollection Users { get; set; } = new List(); +} diff --git a/Server/ReasnAPI/ReasnAPI/Models/Database/Status.cs b/Server/ReasnAPI/ReasnAPI/Models/Database/Status.cs new file mode 100644 index 00000000..9f5ad714 --- /dev/null +++ b/Server/ReasnAPI/ReasnAPI/Models/Database/Status.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; + +namespace ReasnAPI.Models.Database; + +public partial class Status +{ + public int Id { get; set; } + + public string Name { get; set; } = null!; + + public int ObjectTypeId { get; set; } + + public virtual ICollection Events { get; set; } = new List(); + + public virtual ObjectType ObjectType { get; set; } = null!; + + public virtual ICollection Participants { get; set; } = new List(); +} diff --git a/Server/ReasnAPI/ReasnAPI/Models/Database/Tag.cs b/Server/ReasnAPI/ReasnAPI/Models/Database/Tag.cs new file mode 100644 index 00000000..d5f4981f --- /dev/null +++ b/Server/ReasnAPI/ReasnAPI/Models/Database/Tag.cs @@ -0,0 +1,11 @@ +using System; +using System.Collections.Generic; + +namespace ReasnAPI.Models.Database; + +public partial class Tag +{ + public int Id { get; set; } + + public string Name { get; set; } = null!; +} diff --git a/Server/ReasnAPI/ReasnAPI/Models/Database/User.cs b/Server/ReasnAPI/ReasnAPI/Models/Database/User.cs new file mode 100644 index 00000000..ed0c9345 --- /dev/null +++ b/Server/ReasnAPI/ReasnAPI/Models/Database/User.cs @@ -0,0 +1,41 @@ +using System; +using System.Collections.Generic; + +namespace ReasnAPI.Models.Database; + +public partial class User +{ + public int Id { get; set; } + + public string Name { get; set; } = null!; + + public string Surname { get; set; } = null!; + + public string Username { get; set; } = null!; + + public string Password { get; set; } = null!; + + public DateTime CreatedAt { get; set; } + + public DateTime UpdatedAt { get; set; } + + public int RoleId { get; set; } + + public string Email { get; set; } = null!; + + public bool IsActive { get; set; } + + public int AddressId { get; set; } + + public string? Phone { get; set; } + + public virtual Address Address { get; set; } = null!; + + public virtual ICollection Comments { get; set; } = new List(); + + public virtual ICollection Events { get; set; } = new List(); + + public virtual ICollection Participants { get; set; } = new List(); + + public virtual Role Role { get; set; } = null!; +} diff --git a/Server/ReasnAPI/ReasnAPI/Models/Database/UserInterest.cs b/Server/ReasnAPI/ReasnAPI/Models/Database/UserInterest.cs new file mode 100644 index 00000000..7a41940e --- /dev/null +++ b/Server/ReasnAPI/ReasnAPI/Models/Database/UserInterest.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; + +namespace ReasnAPI.Models.Database; + +public partial class UserInterest +{ + public int UserId { get; set; } + + public int InterestId { get; set; } + + public virtual Interest Interest { get; set; } = null!; + + public virtual User User { get; set; } = null!; +} diff --git a/Server/ReasnAPI/ReasnAPI/appsettings.json b/Server/ReasnAPI/ReasnAPI/appsettings.json index 41ddc4c5..de86dfdc 100644 --- a/Server/ReasnAPI/ReasnAPI/appsettings.json +++ b/Server/ReasnAPI/ReasnAPI/appsettings.json @@ -16,7 +16,7 @@ ] }, "ConnectionStrings": { - "DefaultValue": "Server=postgres;Port=5432;Database=Reasn;User Id=dba;Password=sql;" + "DefaultValue": "Server=localhost;Port=5432;Database=reasn;User Id=dba;Password=sql;" }, "AllowedHosts": "*" }