generated from zobweyt/Discord.Net.Template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
349 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
88 changes: 88 additions & 0 deletions
88
src/Giveaways.Data/Migrations/20240624181527_InitialCreate.Designer.cs
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
66 changes: 66 additions & 0 deletions
66
src/Giveaways.Data/Migrations/20240624181527_InitialCreate.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
using System; | ||
using Microsoft.EntityFrameworkCore.Migrations; | ||
|
||
#nullable disable | ||
|
||
namespace Giveaways.Data.Migrations | ||
{ | ||
/// <inheritdoc /> | ||
public partial class InitialCreate : Migration | ||
{ | ||
/// <inheritdoc /> | ||
protected override void Up(MigrationBuilder migrationBuilder) | ||
{ | ||
migrationBuilder.CreateTable( | ||
name: "Giveaways", | ||
columns: table => new | ||
{ | ||
MessageId = table.Column<ulong>(type: "INTEGER", nullable: false), | ||
ChannelId = table.Column<ulong>(type: "INTEGER", nullable: false), | ||
GuildId = table.Column<ulong>(type: "INTEGER", nullable: false), | ||
Prize = table.Column<string>(type: "TEXT", nullable: false), | ||
MaxWinners = table.Column<int>(type: "INTEGER", nullable: false), | ||
ExpiresAt = table.Column<DateTime>(type: "TEXT", nullable: false), | ||
Status = table.Column<int>(type: "INTEGER", nullable: false) | ||
}, | ||
constraints: table => | ||
{ | ||
table.PrimaryKey("PK_Giveaways", x => x.MessageId); | ||
}); | ||
|
||
migrationBuilder.CreateTable( | ||
name: "GiveawayParticipants", | ||
columns: table => new | ||
{ | ||
UserId = table.Column<ulong>(type: "INTEGER", nullable: false), | ||
GiveawayId = table.Column<ulong>(type: "INTEGER", nullable: false), | ||
IsWinner = table.Column<bool>(type: "INTEGER", nullable: false) | ||
}, | ||
constraints: table => | ||
{ | ||
table.PrimaryKey("PK_GiveawayParticipants", x => new { x.UserId, x.GiveawayId }); | ||
table.ForeignKey( | ||
name: "FK_GiveawayParticipants_Giveaways_GiveawayId", | ||
column: x => x.GiveawayId, | ||
principalTable: "Giveaways", | ||
principalColumn: "MessageId", | ||
onDelete: ReferentialAction.Cascade); | ||
}); | ||
|
||
migrationBuilder.CreateIndex( | ||
name: "IX_GiveawayParticipants_GiveawayId", | ||
table: "GiveawayParticipants", | ||
column: "GiveawayId"); | ||
} | ||
|
||
/// <inheritdoc /> | ||
protected override void Down(MigrationBuilder migrationBuilder) | ||
{ | ||
migrationBuilder.DropTable( | ||
name: "GiveawayParticipants"); | ||
|
||
migrationBuilder.DropTable( | ||
name: "Giveaways"); | ||
} | ||
} | ||
} |
85 changes: 85 additions & 0 deletions
85
src/Giveaways.Data/Migrations/AppDbContextModelSnapshot.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
// <auto-generated /> | ||
using System; | ||
using Giveaways.Data; | ||
using Microsoft.EntityFrameworkCore; | ||
using Microsoft.EntityFrameworkCore.Infrastructure; | ||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion; | ||
|
||
#nullable disable | ||
|
||
namespace Giveaways.Data.Migrations | ||
{ | ||
[DbContext(typeof(AppDbContext))] | ||
partial class AppDbContextModelSnapshot : ModelSnapshot | ||
{ | ||
protected override void BuildModel(ModelBuilder modelBuilder) | ||
{ | ||
#pragma warning disable 612, 618 | ||
modelBuilder.HasAnnotation("ProductVersion", "8.0.0"); | ||
|
||
modelBuilder.Entity("Giveaways.Data.Giveaway", b => | ||
{ | ||
b.Property<ulong>("MessageId") | ||
.HasColumnType("INTEGER"); | ||
|
||
b.Property<ulong>("ChannelId") | ||
.HasColumnType("INTEGER"); | ||
|
||
b.Property<DateTime>("ExpiresAt") | ||
.HasColumnType("TEXT"); | ||
|
||
b.Property<ulong>("GuildId") | ||
.HasColumnType("INTEGER"); | ||
|
||
b.Property<int>("MaxWinners") | ||
.HasColumnType("INTEGER"); | ||
|
||
b.Property<string>("Prize") | ||
.IsRequired() | ||
.HasColumnType("TEXT"); | ||
|
||
b.Property<int>("Status") | ||
.HasColumnType("INTEGER"); | ||
|
||
b.HasKey("MessageId"); | ||
|
||
b.ToTable("Giveaways"); | ||
}); | ||
|
||
modelBuilder.Entity("Giveaways.Data.GiveawayParticipant", b => | ||
{ | ||
b.Property<ulong>("UserId") | ||
.HasColumnType("INTEGER"); | ||
|
||
b.Property<ulong>("GiveawayId") | ||
.HasColumnType("INTEGER"); | ||
|
||
b.Property<bool>("IsWinner") | ||
.HasColumnType("INTEGER"); | ||
|
||
b.HasKey("UserId", "GiveawayId"); | ||
|
||
b.HasIndex("GiveawayId"); | ||
|
||
b.ToTable("GiveawayParticipants"); | ||
}); | ||
|
||
modelBuilder.Entity("Giveaways.Data.GiveawayParticipant", b => | ||
{ | ||
b.HasOne("Giveaways.Data.Giveaway", "Giveaway") | ||
.WithMany("Participants") | ||
.HasForeignKey("GiveawayId") | ||
.OnDelete(DeleteBehavior.Cascade) | ||
.IsRequired(); | ||
|
||
b.Navigation("Giveaway"); | ||
}); | ||
|
||
modelBuilder.Entity("Giveaways.Data.Giveaway", b => | ||
{ | ||
b.Navigation("Participants"); | ||
}); | ||
#pragma warning restore 612, 618 | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.ComponentModel.DataAnnotations; | ||
using System.ComponentModel.DataAnnotations.Schema; | ||
|
||
namespace Giveaways.Data; | ||
|
||
/// <summary> | ||
/// Represents a giveaway hosted by a user. | ||
/// </summary> | ||
public class Giveaway | ||
{ | ||
/// <summary> | ||
/// Gets the message identifier of the giveaway message. | ||
/// </summary> | ||
[Key] | ||
[DatabaseGenerated(DatabaseGeneratedOption.None)] | ||
public required ulong MessageId { get; init; } | ||
|
||
/// <summary> | ||
/// Gets the channel identifier where this giveaway was hosted. | ||
/// </summary> | ||
public required ulong ChannelId { get; init; } | ||
|
||
/// <summary> | ||
/// Gets the guild identifier where this giveaway was hosted. | ||
/// </summary> | ||
public required ulong GuildId { get; init; } | ||
|
||
/// <summary> | ||
/// Gets or sets the prize of this giveaway. | ||
/// </summary> | ||
public required string Prize { get; set; } | ||
|
||
/// <summary> | ||
/// Gets or sets the maximum number of winners for this giveaway. | ||
/// </summary> | ||
public required int MaxWinners { get; set; } | ||
|
||
/// <summary> | ||
/// Gets or sets the expiration date and time for this giveaway. | ||
/// </summary> | ||
public required DateTime ExpiresAt { get; set; } | ||
|
||
/// <summary> | ||
/// Gets or sets the current status of this giveaway. | ||
/// </summary> | ||
public GiveawayStatus Status { get; set; } = GiveawayStatus.Active; | ||
|
||
/// <summary> | ||
/// Gets the list of participants for this giveaway. | ||
/// </summary> | ||
public List<GiveawayParticipant> Participants { get; } = []; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
using System.ComponentModel.DataAnnotations.Schema; | ||
using Microsoft.EntityFrameworkCore; | ||
|
||
namespace Giveaways.Data; | ||
|
||
/// <summary> | ||
/// Represents a participant of a giveaway. | ||
/// </summary> | ||
[PrimaryKey(nameof(UserId), nameof(GiveawayId))] | ||
public class GiveawayParticipant | ||
{ | ||
/// <summary> | ||
/// Gets or sets the user ID of the participant. | ||
/// </summary> | ||
[DatabaseGenerated(DatabaseGeneratedOption.None)] | ||
public ulong UserId { get; set; } | ||
|
||
/// <summary> | ||
/// Gets or sets a value indicating whether the participant is a winner. | ||
/// </summary> | ||
public bool IsWinner { get; set; } = false; | ||
|
||
/// <summary> | ||
/// Gets or sets the ID of the giveaway the participant is associated with. | ||
/// </summary> | ||
public ulong GiveawayId { get; set; } | ||
|
||
/// <summary> | ||
/// Gets or sets the reference to the giveaway the participant is associated with. | ||
/// </summary> | ||
public Giveaway Giveaway { get; set; } = null!; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
namespace Giveaways; | ||
|
||
/// <summary> | ||
/// Represents the status of a giveaway. | ||
/// </summary> | ||
public enum GiveawayStatus | ||
{ | ||
/// <summary> | ||
/// The giveaway is currently active and participants can still enter. | ||
/// </summary> | ||
Active, | ||
|
||
/// <summary> | ||
/// The giveaway is temporarily suspended and not accepting new entries. | ||
/// </summary> | ||
Suspended, | ||
|
||
/// <summary> | ||
/// The giveaway has ended, and winners have been selected. | ||
/// </summary> | ||
Ended, | ||
} |