From 1a504435120bf50f7a51ff1351abe8b7e398d6a2 Mon Sep 17 00:00:00 2001 From: HombreLaser Date: Thu, 24 Nov 2022 16:50:03 -0600 Subject: AƱadido DTO POST para Prize MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Forms/PrizeForm.cs | 16 ++++++++++ Migrations/ApplicationDbContextModelSnapshot.cs | 40 +++++++++++++++++++++++++ Models/ApplicationDbContext.cs | 1 + Profiles/PrizeProfile.cs | 12 ++++++++ 4 files changed, 69 insertions(+) create mode 100644 Forms/PrizeForm.cs create mode 100644 Profiles/PrizeProfile.cs diff --git a/Forms/PrizeForm.cs b/Forms/PrizeForm.cs new file mode 100644 index 0000000..04f33a0 --- /dev/null +++ b/Forms/PrizeForm.cs @@ -0,0 +1,16 @@ +using System.ComponentModel.DataAnnotations; +using BackendPIA.Validations; + +namespace BackendPIA.Forms { + public class PrizeForm { + [Required] + public long RaffleId { get; set; } + [Required] + public string? Name { get; set; } + [Required] + [UniqueTier] + public int Tier { get; set; } + [Required] + public string? Category { get; set; } + } +} \ No newline at end of file diff --git a/Migrations/ApplicationDbContextModelSnapshot.cs b/Migrations/ApplicationDbContextModelSnapshot.cs index a0d5dfa..e11a6ec 100644 --- a/Migrations/ApplicationDbContextModelSnapshot.cs +++ b/Migrations/ApplicationDbContextModelSnapshot.cs @@ -22,6 +22,35 @@ namespace BackendPIA.Migrations NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + modelBuilder.Entity("BackendPIA.Models.Prize", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Category") + .IsRequired() + .HasColumnType("text"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("RaffleId") + .HasColumnType("bigint"); + + b.Property("Tier") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("RaffleId"); + + b.ToTable("Prizes"); + }); + modelBuilder.Entity("BackendPIA.Models.Raffle", b => { b.Property("Id") @@ -279,6 +308,17 @@ namespace BackendPIA.Migrations b.ToTable("AspNetUserTokens", (string)null); }); + modelBuilder.Entity("BackendPIA.Models.Prize", b => + { + b.HasOne("BackendPIA.Models.Raffle", "Raffle") + .WithMany() + .HasForeignKey("RaffleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Raffle"); + }); + modelBuilder.Entity("BackendPIA.Models.Ticket", b => { b.HasOne("BackendPIA.Models.Raffle", "Raffle") diff --git a/Models/ApplicationDbContext.cs b/Models/ApplicationDbContext.cs index 80eb64e..8ab6b27 100644 --- a/Models/ApplicationDbContext.cs +++ b/Models/ApplicationDbContext.cs @@ -5,6 +5,7 @@ namespace BackendPIA.Models { public class ApplicationDbContext : IdentityDbContext { public DbSet? Raffles { get; set; } public DbSet? Tickets { get; set; } + public DbSet? Prizes { get; set; } public ApplicationDbContext(DbContextOptions options) : base(options) {} diff --git a/Profiles/PrizeProfile.cs b/Profiles/PrizeProfile.cs new file mode 100644 index 0000000..46545ef --- /dev/null +++ b/Profiles/PrizeProfile.cs @@ -0,0 +1,12 @@ +using AutoMapper; + +using BackendPIA.Models; +using BackendPIA.Forms; + +namespace BackendPIA.Profiles { + public class PrizeProfile : Profile { + public PrizeProfile() { + CreateMap(); + } + } +} \ No newline at end of file -- cgit v1.2.3