diff --git a/MPM-Betting.Blazor.ComponentLibrary/DesktopView/Matches.razor b/MPM-Betting.Blazor.ComponentLibrary/DesktopView/Matches.razor index 63542db..ec8d4f2 100644 --- a/MPM-Betting.Blazor.ComponentLibrary/DesktopView/Matches.razor +++ b/MPM-Betting.Blazor.ComponentLibrary/DesktopView/Matches.razor @@ -496,11 +496,11 @@ else private async Task PlaceBet() { - int amount; + long amount; int homeScore, awayScore; try { - amount = int.Parse(BetAmount); + amount = long.Parse(BetAmount); homeScore = int.Parse(scoreBets.HomeScore); awayScore = int.Parse(scoreBets.AwayScore); } @@ -579,7 +579,7 @@ else UpdateLoading(true); - var result = await UserDomain.PlaceGameBet(quote, homeScore, awayScore, SelectedMatch.Id, int.Parse(BetAmount)); + var result = await UserDomain.PlaceGameBet(quote, homeScore, awayScore, SelectedMatch.Id, long.Parse(BetAmount)); if (result.IsFaulted) { diff --git a/MPM-Betting.Blazor.ComponentLibrary/DesktopView/NavBar.razor b/MPM-Betting.Blazor.ComponentLibrary/DesktopView/NavBar.razor index 39b9b5b..a5d0de3 100644 --- a/MPM-Betting.Blazor.ComponentLibrary/DesktopView/NavBar.razor +++ b/MPM-Betting.Blazor.ComponentLibrary/DesktopView/NavBar.razor @@ -170,7 +170,7 @@ else MpmDbContext m_DbContext; private bool cancelClose; private bool reedemable = false; - private int Points { get; set; } + private long Points { get; set; } private bool IsFirstLogin = false; private string m_ImageUrl = "./Images/default-profile-picture.png"; @@ -277,11 +277,11 @@ else - private string ConvertToLog10(int number) + private string ConvertToLog10(long number) { if (number == 0) return "0"; - int mag = (int)(Math.Floor(Math.Log10(number)) / 3); + long mag = (int)(Math.Floor(Math.Log10(number)) / 3); double divisor = Math.Pow(10, mag * 3); double shortNumber = number / divisor; @@ -304,6 +304,12 @@ else case 4: suffix = "t"; break; + case 5: + suffix = "qt"; + break; + case 6: + suffix = "qit"; + break; default: suffix = "a fuck ton"; break; diff --git a/MPM-Betting.DataModel/User/MpmUser.cs b/MPM-Betting.DataModel/User/MpmUser.cs index 29ab355..38a94d1 100644 --- a/MPM-Betting.DataModel/User/MpmUser.cs +++ b/MPM-Betting.DataModel/User/MpmUser.cs @@ -10,7 +10,7 @@ public class MpmUser : IdentityUser { public List UserGroupEntries { get; set; } = []; - public int Points { get; set; } = 0; + public long Points { get; set; } = 0; public DateTime LastRedeemed { get; set; } = DateTime.MinValue; public List Achievments { get; set; } = []; diff --git a/MPM-Betting.DbManager/Migrations/20240610103657_set points to long.Designer.cs b/MPM-Betting.DbManager/Migrations/20240610103657_set points to long.Designer.cs new file mode 100644 index 0000000..ac4c262 --- /dev/null +++ b/MPM-Betting.DbManager/Migrations/20240610103657_set points to long.Designer.cs @@ -0,0 +1,974 @@ +// +using System; +using MPM_Betting.DataModel; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace MPM_Betting.DbManager.Migrations +{ + [DbContext(typeof(MpmDbContext))] + [Migration("20240610103657_set points to long")] + partial class setpointstolong + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "8.0.6") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + + modelBuilder.Entity("AchievementMpmUser", b => + { + b.Property("AchievmentsId") + .HasColumnType("int"); + + b.Property("UsersId") + .HasColumnType("nvarchar(450)"); + + b.HasKey("AchievmentsId", "UsersId"); + + b.HasIndex("UsersId"); + + b.ToTable("AchievementMpmUser"); + }); + + modelBuilder.Entity("MPM_Betting.DataModel.Betting.Bet", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Completed") + .HasColumnType("bit"); + + b.Property("GameId") + .HasColumnType("int"); + + b.Property("GroupId") + .HasColumnType("int"); + + b.Property("Hit") + .HasColumnType("bit"); + + b.Property("Points") + .HasColumnType("int"); + + b.Property("Processed") + .HasColumnType("bit"); + + b.Property("Type") + .HasColumnType("int"); + + b.Property("UserId") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.HasKey("Id"); + + b.HasIndex("GameId"); + + b.HasIndex("GroupId"); + + b.HasIndex("UserId"); + + b.ToTable("Bets", (string)null); + + b.UseTptMappingStrategy(); + }); + + modelBuilder.Entity("MPM_Betting.DataModel.Betting.CustomSeasonEntry", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("GameId") + .HasColumnType("int"); + + b.Property("SeasonId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("GameId"); + + b.HasIndex("SeasonId"); + + b.ToTable("CustomSeasonEntries"); + }); + + modelBuilder.Entity("MPM_Betting.DataModel.Betting.Game", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("BuiltinSeasonId") + .HasColumnType("int"); + + b.Property("GameState") + .HasColumnType("int"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("ReferenceId") + .HasColumnType("int"); + + b.Property("SportType") + .HasColumnType("int"); + + b.Property("StartTime") + .HasColumnType("datetime2"); + + b.HasKey("Id"); + + b.HasIndex("BuiltinSeasonId"); + + b.ToTable("Games"); + }); + + modelBuilder.Entity("MPM_Betting.DataModel.Betting.ScoreEntry", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Score") + .HasColumnType("int"); + + b.Property("SeasonEntryId") + .HasColumnType("int"); + + b.Property("UserGroupEntryId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("SeasonEntryId"); + + b.HasIndex("UserGroupEntryId"); + + b.ToTable("ScoreEntries"); + }); + + modelBuilder.Entity("MPM_Betting.DataModel.Betting.Season", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Description") + .IsRequired() + .HasMaxLength(2000) + .HasColumnType("nvarchar(2000)"); + + b.Property("Discriminator") + .IsRequired() + .HasMaxLength(13) + .HasColumnType("nvarchar(13)"); + + b.Property("End") + .HasColumnType("datetime2"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("Sport") + .HasColumnType("int"); + + b.Property("Start") + .HasColumnType("datetime2"); + + b.HasKey("Id"); + + b.ToTable("Seasons"); + + b.HasDiscriminator("Discriminator").HasValue("Season"); + + b.UseTphMappingStrategy(); + }); + + modelBuilder.Entity("MPM_Betting.DataModel.Betting.SeasonEntry", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("GroupId") + .HasColumnType("int"); + + b.Property("IsActive") + .HasColumnType("bit"); + + b.Property("SeasonId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("GroupId"); + + b.HasIndex("SeasonId"); + + b.ToTable("SeasonEntries"); + }); + + modelBuilder.Entity("MPM_Betting.DataModel.Rewarding.Achievement", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Description") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.Property("Title") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.HasKey("Id"); + + b.ToTable("Achievements"); + }); + + modelBuilder.Entity("MPM_Betting.DataModel.Rewarding.AchievementEntry", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("AchievementId") + .HasColumnType("int"); + + b.Property("DateEarned") + .HasColumnType("datetime2"); + + b.Property("UserId") + .HasColumnType("nvarchar(450)"); + + b.HasKey("Id"); + + b.HasIndex("AchievementId"); + + b.HasIndex("UserId"); + + b.ToTable("AchievementEntries"); + }); + + modelBuilder.Entity("MPM_Betting.DataModel.User.FavouriteFootballLeague", b => + { + b.Property("UserId") + .HasColumnType("nvarchar(450)"); + + b.Property("LeagueId") + .HasColumnType("int"); + + b.HasKey("UserId", "LeagueId"); + + b.ToTable("UserFavouriteSeasons"); + }); + + modelBuilder.Entity("MPM_Betting.DataModel.User.Message", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Content") + .IsRequired() + .HasMaxLength(5000) + .HasColumnType("nvarchar(max)"); + + b.Property("RecipientGroupId") + .HasColumnType("int"); + + b.Property("RecipientUserId") + .HasColumnType("nvarchar(450)"); + + b.Property("SenderId") + .HasColumnType("nvarchar(450)"); + + b.Property("Time") + .HasColumnType("datetime2"); + + b.HasKey("Id"); + + b.HasIndex("RecipientGroupId"); + + b.HasIndex("RecipientUserId"); + + b.HasIndex("SenderId"); + + b.ToTable("Messages"); + }); + + modelBuilder.Entity("MPM_Betting.DataModel.User.MpmGroup", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("CreatorId") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.Property("Description") + .HasMaxLength(1024) + .HasColumnType("nvarchar(1024)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b.Property("ProfilePictureUrl") + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.HasKey("Id"); + + b.HasIndex("CreatorId"); + + b.ToTable("Groups"); + }); + + modelBuilder.Entity("MPM_Betting.DataModel.User.MpmUser", b => + { + b.Property("Id") + .HasColumnType("nvarchar(450)"); + + b.Property("AccessFailedCount") + .HasColumnType("int"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasColumnType("nvarchar(max)"); + + b.Property("Email") + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); + + b.Property("EmailConfirmed") + .HasColumnType("bit"); + + b.Property("LastRedeemed") + .HasColumnType("datetime2"); + + b.Property("LockoutEnabled") + .HasColumnType("bit"); + + b.Property("LockoutEnd") + .HasColumnType("datetimeoffset"); + + b.Property("NormalizedEmail") + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); + + b.Property("NormalizedUserName") + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); + + b.Property("PasswordHash") + .HasColumnType("nvarchar(max)"); + + b.Property("PhoneNumber") + .HasColumnType("nvarchar(max)"); + + b.Property("PhoneNumberConfirmed") + .HasColumnType("bit"); + + b.Property("Points") + .HasColumnType("bigint"); + + b.Property("ProfilePictureUrl") + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.Property("SecurityStamp") + .HasColumnType("nvarchar(max)"); + + b.Property("TwoFactorEnabled") + .HasColumnType("bit"); + + b.Property("UserName") + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); + + b.HasKey("Id"); + + b.HasIndex("NormalizedEmail") + .HasDatabaseName("EmailIndex"); + + b.HasIndex("NormalizedUserName") + .IsUnique() + .HasDatabaseName("UserNameIndex") + .HasFilter("[NormalizedUserName] IS NOT NULL"); + + b.ToTable("AspNetUsers", (string)null); + }); + + modelBuilder.Entity("MPM_Betting.DataModel.User.Notification", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Date") + .HasColumnType("datetime2"); + + b.Property("IsRead") + .HasColumnType("bit"); + + b.Property("Message") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.Property("TargetId") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.HasKey("Id"); + + b.HasIndex("TargetId"); + + b.ToTable("Notifications"); + }); + + modelBuilder.Entity("MPM_Betting.DataModel.User.UserGroupEntry", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("GroupId") + .HasColumnType("int"); + + b.Property("MpmUserId") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.Property("Role") + .HasColumnType("int"); + + b.Property("Score") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("GroupId"); + + b.HasIndex("MpmUserId"); + + b.ToTable("UserGroupEntries"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRole", b => + { + b.Property("Id") + .HasColumnType("nvarchar(450)"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasColumnType("nvarchar(max)"); + + b.Property("Name") + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); + + b.Property("NormalizedName") + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); + + b.HasKey("Id"); + + b.HasIndex("NormalizedName") + .IsUnique() + .HasDatabaseName("RoleNameIndex") + .HasFilter("[NormalizedName] IS NOT NULL"); + + b.ToTable("AspNetRoles", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ClaimType") + .HasColumnType("nvarchar(max)"); + + b.Property("ClaimValue") + .HasColumnType("nvarchar(max)"); + + b.Property("RoleId") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.HasKey("Id"); + + b.HasIndex("RoleId"); + + b.ToTable("AspNetRoleClaims", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ClaimType") + .HasColumnType("nvarchar(max)"); + + b.Property("ClaimValue") + .HasColumnType("nvarchar(max)"); + + b.Property("UserId") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("AspNetUserClaims", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => + { + b.Property("LoginProvider") + .HasColumnType("nvarchar(450)"); + + b.Property("ProviderKey") + .HasColumnType("nvarchar(450)"); + + b.Property("ProviderDisplayName") + .HasColumnType("nvarchar(max)"); + + b.Property("UserId") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.HasKey("LoginProvider", "ProviderKey"); + + b.HasIndex("UserId"); + + b.ToTable("AspNetUserLogins", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => + { + b.Property("UserId") + .HasColumnType("nvarchar(450)"); + + b.Property("RoleId") + .HasColumnType("nvarchar(450)"); + + b.HasKey("UserId", "RoleId"); + + b.HasIndex("RoleId"); + + b.ToTable("AspNetUserRoles", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => + { + b.Property("UserId") + .HasColumnType("nvarchar(450)"); + + b.Property("LoginProvider") + .HasColumnType("nvarchar(450)"); + + b.Property("Name") + .HasColumnType("nvarchar(450)"); + + b.Property("Value") + .HasColumnType("nvarchar(max)"); + + b.HasKey("UserId", "LoginProvider", "Name"); + + b.ToTable("AspNetUserTokens", (string)null); + }); + + modelBuilder.Entity("MPM_Betting.DataModel.Football.GameBet", b => + { + b.HasBaseType("MPM_Betting.DataModel.Betting.Bet"); + + b.Property("AwayScore") + .HasColumnType("int"); + + b.Property("HomeScore") + .HasColumnType("int"); + + b.Property("Quote") + .HasColumnType("float"); + + b.Property("ResultHit") + .HasColumnType("bit"); + + b.Property("ScoreHit") + .HasColumnType("bit"); + + b.ToTable("FootballGameBets", (string)null); + }); + + modelBuilder.Entity("MPM_Betting.DataModel.Betting.BuiltinSeason", b => + { + b.HasBaseType("MPM_Betting.DataModel.Betting.Season"); + + b.Property("ReferenceId") + .HasColumnType("int"); + + b.HasDiscriminator().HasValue("BuiltinSeason"); + }); + + modelBuilder.Entity("MPM_Betting.DataModel.Betting.CustomSeason", b => + { + b.HasBaseType("MPM_Betting.DataModel.Betting.Season"); + + b.HasDiscriminator().HasValue("CustomSeason"); + }); + + modelBuilder.Entity("AchievementMpmUser", b => + { + b.HasOne("MPM_Betting.DataModel.Rewarding.Achievement", null) + .WithMany() + .HasForeignKey("AchievmentsId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("MPM_Betting.DataModel.User.MpmUser", null) + .WithMany() + .HasForeignKey("UsersId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("MPM_Betting.DataModel.Betting.Bet", b => + { + b.HasOne("MPM_Betting.DataModel.Betting.Game", "Game") + .WithMany("Bets") + .HasForeignKey("GameId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("MPM_Betting.DataModel.User.MpmGroup", "Group") + .WithMany("AllBets") + .HasForeignKey("GroupId") + .OnDelete(DeleteBehavior.NoAction); + + b.HasOne("MPM_Betting.DataModel.User.MpmUser", "User") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Game"); + + b.Navigation("Group"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("MPM_Betting.DataModel.Betting.CustomSeasonEntry", b => + { + b.HasOne("MPM_Betting.DataModel.Betting.Game", "Game") + .WithMany() + .HasForeignKey("GameId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("MPM_Betting.DataModel.Betting.CustomSeason", "Season") + .WithMany("Entries") + .HasForeignKey("SeasonId") + .OnDelete(DeleteBehavior.NoAction) + .IsRequired(); + + b.Navigation("Game"); + + b.Navigation("Season"); + }); + + modelBuilder.Entity("MPM_Betting.DataModel.Betting.Game", b => + { + b.HasOne("MPM_Betting.DataModel.Betting.BuiltinSeason", "BuiltinSeason") + .WithMany() + .HasForeignKey("BuiltinSeasonId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("BuiltinSeason"); + }); + + modelBuilder.Entity("MPM_Betting.DataModel.Betting.ScoreEntry", b => + { + b.HasOne("MPM_Betting.DataModel.Betting.SeasonEntry", "SeasonEntry") + .WithMany("ScoreEntries") + .HasForeignKey("SeasonEntryId") + .OnDelete(DeleteBehavior.NoAction) + .IsRequired(); + + b.HasOne("MPM_Betting.DataModel.User.UserGroupEntry", "UserGroupEntry") + .WithMany("ScoreEntries") + .HasForeignKey("UserGroupEntryId") + .OnDelete(DeleteBehavior.NoAction) + .IsRequired(); + + b.Navigation("SeasonEntry"); + + b.Navigation("UserGroupEntry"); + }); + + modelBuilder.Entity("MPM_Betting.DataModel.Betting.SeasonEntry", b => + { + b.HasOne("MPM_Betting.DataModel.User.MpmGroup", "Group") + .WithMany("Seasons") + .HasForeignKey("GroupId") + .OnDelete(DeleteBehavior.NoAction) + .IsRequired(); + + b.HasOne("MPM_Betting.DataModel.Betting.Season", "Season") + .WithMany() + .HasForeignKey("SeasonId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Group"); + + b.Navigation("Season"); + }); + + modelBuilder.Entity("MPM_Betting.DataModel.Rewarding.AchievementEntry", b => + { + b.HasOne("MPM_Betting.DataModel.Rewarding.Achievement", "Achievement") + .WithMany() + .HasForeignKey("AchievementId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("MPM_Betting.DataModel.User.MpmUser", "User") + .WithMany() + .HasForeignKey("UserId"); + + b.Navigation("Achievement"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("MPM_Betting.DataModel.User.FavouriteFootballLeague", b => + { + b.HasOne("MPM_Betting.DataModel.User.MpmUser", "User") + .WithMany("FavouriteFootballLeagues") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("User"); + }); + + modelBuilder.Entity("MPM_Betting.DataModel.User.Message", b => + { + b.HasOne("MPM_Betting.DataModel.User.MpmGroup", "RecipientGroup") + .WithMany() + .HasForeignKey("RecipientGroupId"); + + b.HasOne("MPM_Betting.DataModel.User.MpmUser", "RecipientUser") + .WithMany() + .HasForeignKey("RecipientUserId"); + + b.HasOne("MPM_Betting.DataModel.User.MpmUser", "Sender") + .WithMany() + .HasForeignKey("SenderId"); + + b.Navigation("RecipientGroup"); + + b.Navigation("RecipientUser"); + + b.Navigation("Sender"); + }); + + modelBuilder.Entity("MPM_Betting.DataModel.User.MpmGroup", b => + { + b.HasOne("MPM_Betting.DataModel.User.MpmUser", "Creator") + .WithMany() + .HasForeignKey("CreatorId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Creator"); + }); + + modelBuilder.Entity("MPM_Betting.DataModel.User.Notification", b => + { + b.HasOne("MPM_Betting.DataModel.User.MpmUser", "Target") + .WithMany() + .HasForeignKey("TargetId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Target"); + }); + + modelBuilder.Entity("MPM_Betting.DataModel.User.UserGroupEntry", b => + { + b.HasOne("MPM_Betting.DataModel.User.MpmGroup", "Group") + .WithMany("UserGroupEntries") + .HasForeignKey("GroupId") + .OnDelete(DeleteBehavior.NoAction) + .IsRequired(); + + b.HasOne("MPM_Betting.DataModel.User.MpmUser", "MpmUser") + .WithMany("UserGroupEntries") + .HasForeignKey("MpmUserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Group"); + + b.Navigation("MpmUser"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => + { + b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null) + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => + { + b.HasOne("MPM_Betting.DataModel.User.MpmUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => + { + b.HasOne("MPM_Betting.DataModel.User.MpmUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => + { + b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null) + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("MPM_Betting.DataModel.User.MpmUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => + { + b.HasOne("MPM_Betting.DataModel.User.MpmUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("MPM_Betting.DataModel.Football.GameBet", b => + { + b.HasOne("MPM_Betting.DataModel.Betting.Bet", null) + .WithOne() + .HasForeignKey("MPM_Betting.DataModel.Football.GameBet", "Id") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("MPM_Betting.DataModel.Betting.Game", b => + { + b.Navigation("Bets"); + }); + + modelBuilder.Entity("MPM_Betting.DataModel.Betting.SeasonEntry", b => + { + b.Navigation("ScoreEntries"); + }); + + modelBuilder.Entity("MPM_Betting.DataModel.User.MpmGroup", b => + { + b.Navigation("AllBets"); + + b.Navigation("Seasons"); + + b.Navigation("UserGroupEntries"); + }); + + modelBuilder.Entity("MPM_Betting.DataModel.User.MpmUser", b => + { + b.Navigation("FavouriteFootballLeagues"); + + b.Navigation("UserGroupEntries"); + }); + + modelBuilder.Entity("MPM_Betting.DataModel.User.UserGroupEntry", b => + { + b.Navigation("ScoreEntries"); + }); + + modelBuilder.Entity("MPM_Betting.DataModel.Betting.CustomSeason", b => + { + b.Navigation("Entries"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/MPM-Betting.DbManager/Migrations/20240610103657_set points to long.cs b/MPM-Betting.DbManager/Migrations/20240610103657_set points to long.cs new file mode 100644 index 0000000..b72e815 --- /dev/null +++ b/MPM-Betting.DbManager/Migrations/20240610103657_set points to long.cs @@ -0,0 +1,116 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace MPM_Betting.DbManager.Migrations +{ + /// + public partial class setpointstolong : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_Bets_Games_GameId", + table: "Bets"); + + migrationBuilder.DropForeignKey( + name: "FK_Notifications_AspNetUsers_TargetId", + table: "Notifications"); + + migrationBuilder.AlterColumn( + name: "TargetId", + table: "Notifications", + type: "nvarchar(450)", + nullable: false, + defaultValue: "", + oldClrType: typeof(string), + oldType: "nvarchar(450)", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "GameId", + table: "Bets", + type: "int", + nullable: false, + defaultValue: 0, + oldClrType: typeof(int), + oldType: "int", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "Points", + table: "AspNetUsers", + type: "bigint", + nullable: false, + oldClrType: typeof(int), + oldType: "int"); + + migrationBuilder.AddForeignKey( + name: "FK_Bets_Games_GameId", + table: "Bets", + column: "GameId", + principalTable: "Games", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + + migrationBuilder.AddForeignKey( + name: "FK_Notifications_AspNetUsers_TargetId", + table: "Notifications", + column: "TargetId", + principalTable: "AspNetUsers", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_Bets_Games_GameId", + table: "Bets"); + + migrationBuilder.DropForeignKey( + name: "FK_Notifications_AspNetUsers_TargetId", + table: "Notifications"); + + migrationBuilder.AlterColumn( + name: "TargetId", + table: "Notifications", + type: "nvarchar(450)", + nullable: true, + oldClrType: typeof(string), + oldType: "nvarchar(450)"); + + migrationBuilder.AlterColumn( + name: "GameId", + table: "Bets", + type: "int", + nullable: true, + oldClrType: typeof(int), + oldType: "int"); + + migrationBuilder.AlterColumn( + name: "Points", + table: "AspNetUsers", + type: "int", + nullable: false, + oldClrType: typeof(long), + oldType: "bigint"); + + migrationBuilder.AddForeignKey( + name: "FK_Bets_Games_GameId", + table: "Bets", + column: "GameId", + principalTable: "Games", + principalColumn: "Id"); + + migrationBuilder.AddForeignKey( + name: "FK_Notifications_AspNetUsers_TargetId", + table: "Notifications", + column: "TargetId", + principalTable: "AspNetUsers", + principalColumn: "Id"); + } + } +} diff --git a/MPM-Betting.DbManager/Migrations/MpmDbContextModelSnapshot.cs b/MPM-Betting.DbManager/Migrations/MpmDbContextModelSnapshot.cs index ae710c3..b6e5895 100644 --- a/MPM-Betting.DbManager/Migrations/MpmDbContextModelSnapshot.cs +++ b/MPM-Betting.DbManager/Migrations/MpmDbContextModelSnapshot.cs @@ -48,7 +48,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("Completed") .HasColumnType("bit"); - b.Property("GameId") + b.Property("GameId") .HasColumnType("int"); b.Property("GroupId") @@ -409,8 +409,8 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("PhoneNumberConfirmed") .HasColumnType("bit"); - b.Property("Points") - .HasColumnType("int"); + b.Property("Points") + .HasColumnType("bigint"); b.Property("ProfilePictureUrl") .HasMaxLength(200) @@ -459,6 +459,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) .HasColumnType("nvarchar(200)"); b.Property("TargetId") + .IsRequired() .HasColumnType("nvarchar(450)"); b.HasKey("Id"); @@ -689,7 +690,9 @@ protected override void BuildModel(ModelBuilder modelBuilder) { b.HasOne("MPM_Betting.DataModel.Betting.Game", "Game") .WithMany("Bets") - .HasForeignKey("GameId"); + .HasForeignKey("GameId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); b.HasOne("MPM_Betting.DataModel.User.MpmGroup", "Group") .WithMany("AllBets") @@ -841,7 +844,9 @@ protected override void BuildModel(ModelBuilder modelBuilder) { b.HasOne("MPM_Betting.DataModel.User.MpmUser", "Target") .WithMany() - .HasForeignKey("TargetId"); + .HasForeignKey("TargetId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); b.Navigation("Target"); }); diff --git a/MPM-Betting.Services/Domains/FootballActions.cs b/MPM-Betting.Services/Domains/FootballActions.cs index c979a58..9f16580 100644 --- a/MPM-Betting.Services/Domains/FootballActions.cs +++ b/MPM-Betting.Services/Domains/FootballActions.cs @@ -35,7 +35,7 @@ public async Task RemoveLeagueFromFavourites(int id) public List GetFavouriteLeaguesForUser() => m_DbContext.UserFavouriteSeasons.Where(s => s.User == m_User).Select(s => s.LeagueId).ToList(); public async Task> PlaceGameBet(double quote, int homeScore, int awayScore, - int referenceId, int points, MpmGroup? group = null) + int referenceId, long points, MpmGroup? group = null) { if (m_User is null) return s_NoUserException; @@ -48,6 +48,9 @@ public async Task> PlaceGameBet(double quote, int homeScore, if (await s_UserHasFootballGameBetQuery(m_DbContext, referenceId, m_User.Id, group)) return s_AlreadyExistsException; + + if (points > int.MaxValue) + return s_InvalidBetParameter; for (var i = 0; i < 50; i++) { @@ -75,6 +78,8 @@ public async Task> PlaceGameBet(double quote, int homeScore, logger.LogWarning("Game with reference id {ReferenceId} not found", referenceId); return s_InvalidBetParameter; } + + var pointsInt = (int)points; var bet = new GameBet() { @@ -85,7 +90,7 @@ public async Task> PlaceGameBet(double quote, int homeScore, HomeScore = homeScore, AwayScore = awayScore, Type = EBetType.FootballGame, - Points = points, + Points = pointsInt, }; if (group is null)