diff --git a/UrphaCapital.API/Controllers/PaymentController.cs b/UrphaCapital.API/Controllers/PaymentController.cs new file mode 100644 index 0000000..8a72953 --- /dev/null +++ b/UrphaCapital.API/Controllers/PaymentController.cs @@ -0,0 +1,46 @@ +using MediatR; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; +using UrphaCapital.Application.UseCases.Admins.Commands; +using UrphaCapital.Application.UseCases.Admins.Queries; +using UrphaCapital.Application.UseCases.Payments.Commands; +using UrphaCapital.Application.UseCases.Payments.Queries; +using UrphaCapital.Application.ViewModels; +using UrphaCapital.Domain.Entities; +using UrphaCapital.Domain.Entities.Auth; + +namespace UrphaCapital.API.Controllers +{ + [Route("api/[controller]")] + [ApiController] + public class PaymentController : ControllerBase + { + private readonly IMediator _mediator; + + public PaymentController(IMediator mediator) + { + _mediator = mediator; + } + + [HttpPost] + public async Task PostPayment([FromBody] CreatePaymentCommand command, CancellationToken cancellation) + { + var response = await _mediator.Send(command, cancellation); + + return response; + } + [HttpGet("{index}/{count}")] + public async Task> GetPayments(int index, int count, CancellationToken cancellation) + { + var query = new GetAllPaymentsQuery() + { + Index = index, + Count = count + }; + + var response = await _mediator.Send(query, cancellation); + + return response; + } + } +} diff --git a/UrphaCapital.API/UrphaCapital.API.csproj b/UrphaCapital.API/UrphaCapital.API.csproj index dd4209f..131f687 100644 --- a/UrphaCapital.API/UrphaCapital.API.csproj +++ b/UrphaCapital.API/UrphaCapital.API.csproj @@ -25,4 +25,6 @@ + + diff --git a/UrphaCapital.API/wwwroot/CoursesPictures/b517aa80-242b-49f4-9f4e-81baa681e56a.jfif b/UrphaCapital.API/wwwroot/CoursesPictures/b517aa80-242b-49f4-9f4e-81baa681e56a.jfif new file mode 100644 index 0000000..dfaadad Binary files /dev/null and b/UrphaCapital.API/wwwroot/CoursesPictures/b517aa80-242b-49f4-9f4e-81baa681e56a.jfif differ diff --git a/UrphaCapital.API/wwwroot/MentorsPictures/667d9b39-e7f1-4579-bf16-519e4a9c56b7.jfif b/UrphaCapital.API/wwwroot/MentorsPictures/667d9b39-e7f1-4579-bf16-519e4a9c56b7.jfif new file mode 100644 index 0000000..dfaadad Binary files /dev/null and b/UrphaCapital.API/wwwroot/MentorsPictures/667d9b39-e7f1-4579-bf16-519e4a9c56b7.jfif differ diff --git a/UrphaCapital.Application/Abstractions/IApplicationDbContext.cs b/UrphaCapital.Application/Abstractions/IApplicationDbContext.cs index 09808ef..9311e60 100644 --- a/UrphaCapital.Application/Abstractions/IApplicationDbContext.cs +++ b/UrphaCapital.Application/Abstractions/IApplicationDbContext.cs @@ -20,6 +20,7 @@ public interface IApplicationDbContext public DbSet Students { get; set; } public DbSet Homeworks { get; set; } public DbSet Helps { get; set; } + public DbSet Paymentss { get; set; } ValueTask SaveChangesAsync(CancellationToken cancellationToken = default!); } diff --git a/UrphaCapital.Application/UseCases/Payments/Commands/CreatePaymentCommand.cs b/UrphaCapital.Application/UseCases/Payments/Commands/CreatePaymentCommand.cs new file mode 100644 index 0000000..10c4dca --- /dev/null +++ b/UrphaCapital.Application/UseCases/Payments/Commands/CreatePaymentCommand.cs @@ -0,0 +1,18 @@ +using MediatR; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using UrphaCapital.Application.ViewModels; + +namespace UrphaCapital.Application.UseCases.Payments.Commands +{ + public class CreatePaymentCommand: IRequest + { + public long StudentId { get; set; } + public Guid CourseId { get; set; } + public decimal Amount { get; set; } + public string PaymentStatus { get; set; } + } +} diff --git a/UrphaCapital.Application/UseCases/Payments/Handlers/CreatePaymentCommandHandler.cs b/UrphaCapital.Application/UseCases/Payments/Handlers/CreatePaymentCommandHandler.cs new file mode 100644 index 0000000..8e40aad --- /dev/null +++ b/UrphaCapital.Application/UseCases/Payments/Handlers/CreatePaymentCommandHandler.cs @@ -0,0 +1,45 @@ +using MediatR; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using UrphaCapital.Application.Abstractions; +using UrphaCapital.Application.UseCases.Payments.Commands; +using UrphaCapital.Application.ViewModels; +using UrphaCapital.Domain.Entities; +using UrphaCapital.Domain.Entities.Auth; + +namespace UrphaCapital.Application.UseCases.Payments.Handlers +{ + public class CreatePaymentCommandHandler : IRequestHandler + { + private readonly IApplicationDbContext _context; + + public CreatePaymentCommandHandler(IApplicationDbContext context) + { + _context = context; + } + + public async Task Handle(CreatePaymentCommand request, CancellationToken cancellationToken) + { + var payment = new Payment() + { + StudentId = request.StudentId, + CourseId = request.CourseId, + Amount = request.Amount, + PaymentStatus = request.PaymentStatus, + }; + + await _context.Paymentss.AddAsync(payment); + await _context.SaveChangesAsync(cancellationToken); + + return new ResponseModel() + { + Message = "Created", + StatusCode = 200, + IsSuccess = true + }; + } + } +} diff --git a/UrphaCapital.Application/UseCases/Payments/Queries/GetAllPaymentsQuery.cs b/UrphaCapital.Application/UseCases/Payments/Queries/GetAllPaymentsQuery.cs new file mode 100644 index 0000000..25d410c --- /dev/null +++ b/UrphaCapital.Application/UseCases/Payments/Queries/GetAllPaymentsQuery.cs @@ -0,0 +1,16 @@ +using MediatR; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using UrphaCapital.Domain.Entities; + +namespace UrphaCapital.Application.UseCases.Payments.Queries +{ + public class GetAllPaymentsQuery: IRequest> + { + public int Index { get; set; } + public int Count { get; set; } + } +} diff --git a/UrphaCapital.Application/UseCases/Payments/QueriesHandler/GetAllPaymentsQueryHandler.cs b/UrphaCapital.Application/UseCases/Payments/QueriesHandler/GetAllPaymentsQueryHandler.cs new file mode 100644 index 0000000..4810179 --- /dev/null +++ b/UrphaCapital.Application/UseCases/Payments/QueriesHandler/GetAllPaymentsQueryHandler.cs @@ -0,0 +1,29 @@ +using MediatR; +using Microsoft.EntityFrameworkCore; +using System; +using System.Collections; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using UrphaCapital.Application.Abstractions; +using UrphaCapital.Application.UseCases.Payments.Queries; +using UrphaCapital.Domain.Entities; + +namespace UrphaCapital.Application.UseCases.Payments.QueriesHandler +{ + public class GetAllPaymentsQueryHandler : IRequestHandler> + { + private readonly IApplicationDbContext _context; + + public GetAllPaymentsQueryHandler(IApplicationDbContext context) + { + _context = context; + } + + public async Task> Handle(GetAllPaymentsQuery request, CancellationToken cancellationToken) + { + return await _context.Paymentss.ToListAsync(cancellationToken); + } + } +} diff --git a/UrphaCapital.Domain/Entities/Payment.cs b/UrphaCapital.Domain/Entities/Payment.cs index 49fd6ec..d89c36c 100644 --- a/UrphaCapital.Domain/Entities/Payment.cs +++ b/UrphaCapital.Domain/Entities/Payment.cs @@ -13,9 +13,9 @@ public class Payment public long StudentId { get; set; } public Guid CourseId { get; set; } public decimal Amount { get; set; } + public string PaymentStatus { get; set; } public DateTimeOffset PaymentDate = DateTimeOffset.UtcNow; - public string PaymentStatus { get; set; } public Student Student { get; set; } public Course Course { get; set; } } diff --git a/UrphaCapital.Infrastructure/Migrations/20240916190519_usus.Designer.cs b/UrphaCapital.Infrastructure/Migrations/20240916190519_usus.Designer.cs new file mode 100644 index 0000000..275580c --- /dev/null +++ b/UrphaCapital.Infrastructure/Migrations/20240916190519_usus.Designer.cs @@ -0,0 +1,462 @@ +// +using System; +using System.Collections.Generic; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; +using UrphaCapital.Infrastructure.Persistanse; + +#nullable disable + +namespace UrphaCapital.Infrastructure.Migrations +{ + [DbContext(typeof(UrphaCapitalDbContext))] + [Migration("20240916190519_usus")] + partial class usus + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "8.0.7") + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + + modelBuilder.Entity("UrphaCapital.Domain.Entities.Answer", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Content") + .IsRequired() + .HasColumnType("text"); + + b.Property("TestId") + .HasColumnType("bigint"); + + b.Property("isCorrect") + .HasColumnType("boolean"); + + b.HasKey("Id"); + + b.HasIndex("TestId"); + + b.ToTable("Answers"); + }); + + modelBuilder.Entity("UrphaCapital.Domain.Entities.Auth.Admin", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Email") + .IsRequired() + .HasColumnType("text"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("PasswordHash") + .IsRequired() + .HasColumnType("text"); + + b.Property("PhoneNumber") + .IsRequired() + .HasColumnType("text"); + + b.Property("Role") + .IsRequired() + .HasColumnType("text"); + + b.Property("Salt") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("Admins"); + + b.HasData( + new + { + Id = 1L, + Email = "admin@gmail.com", + Name = "Ozod Ali", + PasswordHash = "LXixSmGK1zCimS7HJigEQYR1MWACNvNMb9ARcmRusdU=", + PhoneNumber = "+998934013443", + Role = "SuperAdmin", + Salt = "c8dc5061-7022-41ee-b2aa-d397f56b3fb3" + }); + }); + + modelBuilder.Entity("UrphaCapital.Domain.Entities.Auth.Mentor", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Description") + .IsRequired() + .HasColumnType("text"); + + b.Property("Email") + .IsRequired() + .HasColumnType("text"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("PasswordHash") + .IsRequired() + .HasColumnType("text"); + + b.Property("PhoneNumber") + .IsRequired() + .HasColumnType("text"); + + b.Property("Picture") + .IsRequired() + .HasColumnType("text"); + + b.Property("Role") + .IsRequired() + .HasColumnType("text"); + + b.Property("Salt") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("Mentors"); + }); + + modelBuilder.Entity("UrphaCapital.Domain.Entities.Auth.Student", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Address") + .IsRequired() + .HasColumnType("text"); + + b.Property>("CourseIds") + .HasColumnType("text[]"); + + b.Property("Email") + .IsRequired() + .HasColumnType("text"); + + b.Property("FullName") + .IsRequired() + .HasColumnType("text"); + + b.Property("PasswordHash") + .IsRequired() + .HasColumnType("text"); + + b.Property("PhoneNumber") + .IsRequired() + .HasColumnType("text"); + + b.Property("Role") + .IsRequired() + .HasColumnType("text"); + + b.Property("Salt") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("Students"); + }); + + modelBuilder.Entity("UrphaCapital.Domain.Entities.Course", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Description") + .IsRequired() + .HasColumnType("text"); + + b.Property("MentorId") + .HasColumnType("bigint"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("Picture") + .IsRequired() + .HasColumnType("text"); + + b.Property("Price") + .IsRequired() + .HasColumnType("text"); + + b.Property("Subtitle") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("MentorId"); + + b.ToTable("Courses"); + }); + + modelBuilder.Entity("UrphaCapital.Domain.Entities.Help", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Address") + .IsRequired() + .HasColumnType("text"); + + b.Property("CourseType") + .IsRequired() + .HasColumnType("text"); + + b.Property("Email") + .IsRequired() + .HasColumnType("text"); + + b.Property("FullName") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("Helps"); + }); + + modelBuilder.Entity("UrphaCapital.Domain.Entities.Homeworks", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Description") + .IsRequired() + .HasColumnType("text"); + + b.Property("FILE") + .IsRequired() + .HasColumnType("text"); + + b.Property("Grade") + .HasColumnType("integer"); + + b.Property("LessonId") + .HasColumnType("uuid"); + + b.Property("MentorId") + .HasColumnType("bigint"); + + b.Property("StudentId") + .HasColumnType("bigint"); + + b.Property("Title") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("LessonId"); + + b.ToTable("Homeworks"); + }); + + modelBuilder.Entity("UrphaCapital.Domain.Entities.Lesson", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CourseId") + .HasColumnType("uuid"); + + b.Property("HomeworkDescription") + .IsRequired() + .HasColumnType("text"); + + b.Property("Title") + .IsRequired() + .HasColumnType("text"); + + b.Property("Video") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("CourseId"); + + b.ToTable("Lessons"); + }); + + modelBuilder.Entity("UrphaCapital.Domain.Entities.Payment", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Amount") + .HasColumnType("numeric"); + + b.Property("CourseId") + .HasColumnType("uuid"); + + b.Property("PaymentStatus") + .IsRequired() + .HasColumnType("text"); + + b.Property("StudentId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("CourseId"); + + b.HasIndex("StudentId"); + + b.ToTable("Paymentss"); + }); + + modelBuilder.Entity("UrphaCapital.Domain.Entities.Test", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("LessonId") + .HasColumnType("uuid"); + + b.Property("Question") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("LessonId"); + + b.ToTable("Tests"); + }); + + modelBuilder.Entity("UrphaCapital.Domain.Entities.Answer", b => + { + b.HasOne("UrphaCapital.Domain.Entities.Test", "Test") + .WithMany("Answers") + .HasForeignKey("TestId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Test"); + }); + + modelBuilder.Entity("UrphaCapital.Domain.Entities.Course", b => + { + b.HasOne("UrphaCapital.Domain.Entities.Auth.Mentor", "Mentor") + .WithMany("Courses") + .HasForeignKey("MentorId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Mentor"); + }); + + modelBuilder.Entity("UrphaCapital.Domain.Entities.Homeworks", b => + { + b.HasOne("UrphaCapital.Domain.Entities.Lesson", "Lesson") + .WithMany() + .HasForeignKey("LessonId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Lesson"); + }); + + modelBuilder.Entity("UrphaCapital.Domain.Entities.Lesson", b => + { + b.HasOne("UrphaCapital.Domain.Entities.Course", "Course") + .WithMany() + .HasForeignKey("CourseId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Course"); + }); + + modelBuilder.Entity("UrphaCapital.Domain.Entities.Payment", b => + { + b.HasOne("UrphaCapital.Domain.Entities.Course", "Course") + .WithMany() + .HasForeignKey("CourseId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("UrphaCapital.Domain.Entities.Auth.Student", "Student") + .WithMany() + .HasForeignKey("StudentId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Course"); + + b.Navigation("Student"); + }); + + modelBuilder.Entity("UrphaCapital.Domain.Entities.Test", b => + { + b.HasOne("UrphaCapital.Domain.Entities.Lesson", "Lesson") + .WithMany() + .HasForeignKey("LessonId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Lesson"); + }); + + modelBuilder.Entity("UrphaCapital.Domain.Entities.Auth.Mentor", b => + { + b.Navigation("Courses"); + }); + + modelBuilder.Entity("UrphaCapital.Domain.Entities.Test", b => + { + b.Navigation("Answers"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/UrphaCapital.Infrastructure/Migrations/20240916190519_usus.cs b/UrphaCapital.Infrastructure/Migrations/20240916190519_usus.cs new file mode 100644 index 0000000..03839bd --- /dev/null +++ b/UrphaCapital.Infrastructure/Migrations/20240916190519_usus.cs @@ -0,0 +1,75 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; + +#nullable disable + +namespace UrphaCapital.Infrastructure.Migrations +{ + /// + public partial class usus : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "Paymentss", + columns: table => new + { + Id = table.Column(type: "bigint", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + StudentId = table.Column(type: "bigint", nullable: false), + CourseId = table.Column(type: "uuid", nullable: false), + Amount = table.Column(type: "numeric", nullable: false), + PaymentStatus = table.Column(type: "text", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Paymentss", x => x.Id); + table.ForeignKey( + name: "FK_Paymentss_Courses_CourseId", + column: x => x.CourseId, + principalTable: "Courses", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_Paymentss_Students_StudentId", + column: x => x.StudentId, + principalTable: "Students", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.UpdateData( + table: "Admins", + keyColumn: "Id", + keyValue: 1L, + columns: new[] { "PasswordHash", "Salt" }, + values: new object[] { "LXixSmGK1zCimS7HJigEQYR1MWACNvNMb9ARcmRusdU=", "c8dc5061-7022-41ee-b2aa-d397f56b3fb3" }); + + migrationBuilder.CreateIndex( + name: "IX_Paymentss_CourseId", + table: "Paymentss", + column: "CourseId"); + + migrationBuilder.CreateIndex( + name: "IX_Paymentss_StudentId", + table: "Paymentss", + column: "StudentId"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "Paymentss"); + + migrationBuilder.UpdateData( + table: "Admins", + keyColumn: "Id", + keyValue: 1L, + columns: new[] { "PasswordHash", "Salt" }, + values: new object[] { "njmXE2qt17lt9DCaV7m5cXLNyd07lyJqQbB5VeTfMfU=", "7b9a34e5-5d54-4c04-945e-c101ac484bf2" }); + } + } +} diff --git a/UrphaCapital.Infrastructure/Migrations/UrphaCapitalDbContextModelSnapshot.cs b/UrphaCapital.Infrastructure/Migrations/UrphaCapitalDbContextModelSnapshot.cs index 99a7fe9..8352a16 100644 --- a/UrphaCapital.Infrastructure/Migrations/UrphaCapitalDbContextModelSnapshot.cs +++ b/UrphaCapital.Infrastructure/Migrations/UrphaCapitalDbContextModelSnapshot.cs @@ -90,10 +90,10 @@ protected override void BuildModel(ModelBuilder modelBuilder) Id = 1L, Email = "admin@gmail.com", Name = "Ozod Ali", - PasswordHash = "njmXE2qt17lt9DCaV7m5cXLNyd07lyJqQbB5VeTfMfU=", + PasswordHash = "LXixSmGK1zCimS7HJigEQYR1MWACNvNMb9ARcmRusdU=", PhoneNumber = "+998934013443", Role = "SuperAdmin", - Salt = "7b9a34e5-5d54-4c04-945e-c101ac484bf2" + Salt = "c8dc5061-7022-41ee-b2aa-d397f56b3fb3" }); }); @@ -318,6 +318,36 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.ToTable("Lessons"); }); + modelBuilder.Entity("UrphaCapital.Domain.Entities.Payment", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Amount") + .HasColumnType("numeric"); + + b.Property("CourseId") + .HasColumnType("uuid"); + + b.Property("PaymentStatus") + .IsRequired() + .HasColumnType("text"); + + b.Property("StudentId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("CourseId"); + + b.HasIndex("StudentId"); + + b.ToTable("Paymentss"); + }); + modelBuilder.Entity("UrphaCapital.Domain.Entities.Test", b => { b.Property("Id") @@ -384,6 +414,25 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Navigation("Course"); }); + modelBuilder.Entity("UrphaCapital.Domain.Entities.Payment", b => + { + b.HasOne("UrphaCapital.Domain.Entities.Course", "Course") + .WithMany() + .HasForeignKey("CourseId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("UrphaCapital.Domain.Entities.Auth.Student", "Student") + .WithMany() + .HasForeignKey("StudentId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Course"); + + b.Navigation("Student"); + }); + modelBuilder.Entity("UrphaCapital.Domain.Entities.Test", b => { b.HasOne("UrphaCapital.Domain.Entities.Lesson", "Lesson") diff --git a/UrphaCapital.Infrastructure/Persistanse/UrphaCapitalDbContext.cs b/UrphaCapital.Infrastructure/Persistanse/UrphaCapitalDbContext.cs index fb98dc6..82457cb 100644 --- a/UrphaCapital.Infrastructure/Persistanse/UrphaCapitalDbContext.cs +++ b/UrphaCapital.Infrastructure/Persistanse/UrphaCapitalDbContext.cs @@ -28,6 +28,7 @@ public UrphaCapitalDbContext(DbContextOptions options) public DbSet Students { get; set; } public DbSet Homeworks { get; set; } public DbSet Helps { get; set; } + public DbSet Paymentss { get; set; } protected override void OnModelCreating(ModelBuilder modelBuilder) {