Feat ERP 3

This commit is contained in:
2026-02-21 19:23:17 -03:00
parent 29aa8e30e7
commit 841cc961b5
13 changed files with 835 additions and 26 deletions

View File

@@ -81,7 +81,7 @@ public class ClientRepository
}
sql += " ORDER BY name";
return await conn.QueryAsync(sql, new { Query = $"%{searchTerm}%" });
}
@@ -136,4 +136,24 @@ public class ClientRepository
var sql = "UPDATE Users SET PasswordHash = @Hash, MustChangePassword = 1 WHERE Id = @Id";
await conn.ExecuteAsync(sql, new { Hash = passwordHash, Id = clientId });
}
public async Task<int> CreateFullClientAsync(Client client)
{
using var conn = _db.CreateConnection();
var sql = @"
INSERT INTO Users (
Username, PasswordHash, Role,
BillingName, BillingTaxId, Email, Phone, BillingAddress, BillingTaxType,
MustChangePassword, IsActive, CreatedAt
)
VALUES (
@DniOrCuit, 'N/A', 'Client',
@Name, @DniOrCuit, @Email, @Phone, @Address, @TaxType,
0, 1, GETUTCDATE()
);
SELECT CAST(SCOPE_IDENTITY() as int);";
// Usamos el CUIT como username por defecto para garantizar unicidad
return await conn.QuerySingleAsync<int>(sql, client);
}
}