шедевросишарп

This commit is contained in:
Дмитрий Шиманский
2023-11-16 20:10:09 +03:00
parent 1c48750d87
commit 819d974f99
5 changed files with 374 additions and 5 deletions

View File

@@ -20,6 +20,22 @@ namespace DiscordApp.Controllers
Startup.appDbContext.Redirects.Update(data);
Startup.appDbContext.SaveChanges();
return Redirect(data.url);
}else if (data.RedirectType == Types.RedirectType.Redirected)
{
JsonNode jsonBodyContent = JsonNode.Parse(bodyContent);
string[] paymentData = jsonBodyContent["data"].ToString().Split(";");
var channelId = paymentData[1].Split(":")[1];
var channel = Startup.discordSocketClient.GetChannel(ulong.Parse(channelId)) as ITextChannel;
var message = channel.GetMessagesAsync().LastAsync().Result.Last() as IUserMessage;
message.ModifyAsync(func =>
{
func.Content = "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!";
func.Components = new ComponentBuilder()
.WithButton("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>", "addBaseOnMapModalSender")
.Build();
}).RunSynchronously();
return Redirect(message.GetJumpUrl());
}
else
{
@@ -42,7 +58,7 @@ namespace DiscordApp.Controllers
.Build();
}).RunSynchronously();
return Redirect(message.GetJumpUrl());
return Ok(message.GetJumpUrl());
}
}

View File

@@ -11,16 +11,16 @@ namespace DiscordApp.Justice.Interactions
[ComponentInteraction("addBaseOnMap")]
public async Task addBaseInteraction()
{
var redirectUri = Guid.NewGuid().ToString();
await DeferAsync(true);
var paymentData = new spworlds.Types.PaymentData()
{
Amount = 16,
Data = $"user:{Context.User.Id};channel:{Context.Channel.Id};",
RedirectUrl = Context.Interaction.GetOriginalResponseAsync().Result.GetJumpUrl(),
WebHookUrl = "https://discord.yawaflua.ru/addOnMap/"
RedirectUrl = $"https://discord.yawaflua.ru/redirects/{redirectUri}",
WebHookUrl = $"https://discord.yawaflua.ru/redirects/{redirectUri}"
};
var uri = await Startup.sp.InitPayment(paymentData);
var redirectUri = Guid.NewGuid().ToString();
var redirectTable = new Redirects() { Id = redirectUri , url = uri};
Startup.appDbContext.Redirects.Add(redirectTable);
Startup.appDbContext.SaveChanges();

View File

@@ -0,0 +1,319 @@
// <auto-generated />
using System;
using DiscordApp.Database;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace DiscordApp.Migrations
{
[DbContext(typeof(AppDbContext))]
[Migration("20231116170623_Migrate16112006")]
partial class Migrate16112006
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "7.0.13")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("DiscordApp.Database.Tables.ArtsPatents", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<long>("Date")
.HasColumnType("bigint");
b.Property<string>("Employee")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<int[]>("Number")
.IsRequired()
.HasColumnType("integer[]");
b.Property<string>("Size")
.IsRequired()
.HasColumnType("text");
b.Property<bool>("isAllowedToResell")
.HasColumnType("boolean");
b.Property<int>("passportId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("passportId");
b.ToTable("ArtsPatent", "public");
});
modelBuilder.Entity("DiscordApp.Database.Tables.Autobranches", b =>
{
b.Property<decimal>("ChannelId")
.ValueGeneratedOnAdd()
.HasColumnType("numeric(20,0)");
b.Property<string>("BranchName")
.IsRequired()
.HasColumnType("text");
b.HasKey("ChannelId");
b.ToTable("Autobranches", "public");
});
modelBuilder.Entity("DiscordApp.Database.Tables.Bizness", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<int>("ApplicantId")
.HasColumnType("integer");
b.Property<int[]>("BiznessEmployes")
.IsRequired()
.HasColumnType("integer[]");
b.Property<string>("BiznessName")
.IsRequired()
.HasColumnType("text");
b.Property<string>("BiznessType")
.IsRequired()
.HasColumnType("text");
b.Property<int>("CardNumber")
.HasColumnType("integer");
b.Property<long>("Date")
.HasColumnType("bigint");
b.Property<string>("Employee")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("ApplicantId");
b.ToTable("Bizness", "public");
});
modelBuilder.Entity("DiscordApp.Database.Tables.BooksPatents", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("Annotation")
.IsRequired()
.HasColumnType("text");
b.Property<long>("Date")
.HasColumnType("bigint");
b.Property<string>("Employee")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Janre")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<bool>("isAllowedToResell")
.HasColumnType("boolean");
b.Property<int>("passportId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("passportId");
b.ToTable("BooksPatent", "public");
});
modelBuilder.Entity("DiscordApp.Database.Tables.Certificate", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<DateOnly>("Date")
.HasColumnType("date");
b.Property<int>("DocumentId")
.HasColumnType("integer");
b.Property<string>("DocumentType")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Employee")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Text")
.IsRequired()
.HasColumnType("text");
b.Property<int>("passportId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("passportId");
b.ToTable("Certificate", "public");
});
modelBuilder.Entity("DiscordApp.Database.Tables.Passport", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("Applicant")
.IsRequired()
.HasColumnType("text");
b.Property<long>("Date")
.HasColumnType("bigint");
b.Property<decimal>("Employee")
.HasColumnType("numeric(20,0)");
b.Property<string>("Gender")
.IsRequired()
.HasColumnType("text");
b.Property<string>("RpName")
.IsRequired()
.HasColumnType("text");
b.Property<int>("Support")
.HasColumnType("integer");
b.Property<long>("birthDate")
.HasColumnType("bigint");
b.HasKey("Id");
b.ToTable("Passport", "public");
});
modelBuilder.Entity("DiscordApp.Database.Tables.Redirects", b =>
{
b.Property<string>("Id")
.HasColumnType("text");
b.Property<int>("RedirectType")
.HasColumnType("integer");
b.Property<string>("url")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.ToTable("Redirects", "public");
});
modelBuilder.Entity("DiscordApp.Database.Tables.Reports", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("Employee")
.IsRequired()
.HasColumnType("text");
b.Property<int>("type")
.HasColumnType("integer");
b.HasKey("Id");
b.ToTable("Reports", "public");
});
modelBuilder.Entity("DiscordApp.Database.Tables.ArtsPatents", b =>
{
b.HasOne("DiscordApp.Database.Tables.Passport", "passport")
.WithMany()
.HasForeignKey("passportId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("passport");
});
modelBuilder.Entity("DiscordApp.Database.Tables.Bizness", b =>
{
b.HasOne("DiscordApp.Database.Tables.Passport", "Applicant")
.WithMany()
.HasForeignKey("ApplicantId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Applicant");
});
modelBuilder.Entity("DiscordApp.Database.Tables.BooksPatents", b =>
{
b.HasOne("DiscordApp.Database.Tables.Passport", "passport")
.WithMany()
.HasForeignKey("passportId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("passport");
});
modelBuilder.Entity("DiscordApp.Database.Tables.Certificate", b =>
{
b.HasOne("DiscordApp.Database.Tables.Passport", "passport")
.WithMany()
.HasForeignKey("passportId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("passport");
});
#pragma warning restore 612, 618
}
}
}

View File

@@ -0,0 +1,31 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace DiscordApp.Migrations
{
/// <inheritdoc />
public partial class Migrate16112006 : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<int>(
name: "RedirectType",
schema: "public",
table: "Redirects",
type: "integer",
nullable: false,
defaultValue: 0);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "RedirectType",
schema: "public",
table: "Redirects");
}
}
}

View File

@@ -235,6 +235,9 @@ namespace DiscordApp.Migrations
b.Property<string>("Id")
.HasColumnType("text");
b.Property<int>("RedirectType")
.HasColumnType("integer");
b.Property<string>("url")
.IsRequired()
.HasColumnType("text");