✨ Account contact can be primary
This commit is contained in:
		@@ -376,7 +376,8 @@ public class AccountService(
 | 
			
		||||
        var contact = new AccountContact
 | 
			
		||||
        {
 | 
			
		||||
            Type = type,
 | 
			
		||||
            Content = content
 | 
			
		||||
            Content = content,
 | 
			
		||||
            AccountId = account.Id,
 | 
			
		||||
        };
 | 
			
		||||
 | 
			
		||||
        db.AccountContacts.Add(contact);
 | 
			
		||||
 
 | 
			
		||||
@@ -66,6 +66,7 @@ public class MagicSpellService(
 | 
			
		||||
            .Where(c => c.Account.Id == spell.AccountId)
 | 
			
		||||
            .Where(c => c.Type == AccountContactType.Email)
 | 
			
		||||
            .Where(c => c.VerifiedAt != null || bypassVerify)
 | 
			
		||||
            .OrderByDescending(c => c.IsPrimary)
 | 
			
		||||
            .Include(c => c.Account)
 | 
			
		||||
            .FirstOrDefaultAsync();
 | 
			
		||||
        if (contact is null) throw new ArgumentException("Account has no contact method that can use");
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										3414
									
								
								DysonNetwork.Sphere/Migrations/20250608114100_AccountContactCanBePrimary.Designer.cs
									
									
									
										generated
									
									
									
										Normal file
									
								
							
							
						
						
									
										3414
									
								
								DysonNetwork.Sphere/Migrations/20250608114100_AccountContactCanBePrimary.Designer.cs
									
									
									
										generated
									
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							@@ -0,0 +1,29 @@
 | 
			
		||||
using Microsoft.EntityFrameworkCore.Migrations;
 | 
			
		||||
 | 
			
		||||
#nullable disable
 | 
			
		||||
 | 
			
		||||
namespace DysonNetwork.Sphere.Migrations
 | 
			
		||||
{
 | 
			
		||||
    /// <inheritdoc />
 | 
			
		||||
    public partial class AccountContactCanBePrimary : Migration
 | 
			
		||||
    {
 | 
			
		||||
        /// <inheritdoc />
 | 
			
		||||
        protected override void Up(MigrationBuilder migrationBuilder)
 | 
			
		||||
        {
 | 
			
		||||
            migrationBuilder.AddColumn<bool>(
 | 
			
		||||
                name: "is_primary",
 | 
			
		||||
                table: "account_contacts",
 | 
			
		||||
                type: "boolean",
 | 
			
		||||
                nullable: false,
 | 
			
		||||
                defaultValue: false);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <inheritdoc />
 | 
			
		||||
        protected override void Down(MigrationBuilder migrationBuilder)
 | 
			
		||||
        {
 | 
			
		||||
            migrationBuilder.DropColumn(
 | 
			
		||||
                name: "is_primary",
 | 
			
		||||
                table: "account_contacts");
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -167,6 +167,10 @@ namespace DysonNetwork.Sphere.Migrations
 | 
			
		||||
                        .HasColumnType("timestamp with time zone")
 | 
			
		||||
                        .HasColumnName("deleted_at");
 | 
			
		||||
 | 
			
		||||
                    b.Property<bool>("IsPrimary")
 | 
			
		||||
                        .HasColumnType("boolean")
 | 
			
		||||
                        .HasColumnName("is_primary");
 | 
			
		||||
 | 
			
		||||
                    b.Property<int>("Type")
 | 
			
		||||
                        .HasColumnType("integer")
 | 
			
		||||
                        .HasColumnName("type");
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user