Feat ERP 3
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user