починил метод update Для rental

This commit is contained in:
Timourka 2024-04-23 19:57:33 +04:00
parent dec2a1ef1e
commit 77ce3e9b17

View File

@ -218,7 +218,13 @@ namespace database
{
using var conn = GetConnection();
conn.Open();
using var cmd = new NpgsqlCommand($"UPDATE rental SET car_id = {rental.CarId}, client_id = {rental.ClientId}, start_date = '{rental.StartDate}', end_date = '{rental.EndDate}', cost = {rental.Cost} WHERE id = {rental.Id}", conn);
using var cmd = new NpgsqlCommand("UPDATE rental SET car_id = @CarId, client_id = @ClientId, start_date = '@StartDate', end_date = '@EndDate', cost = @Cost WHERE id = @Id", conn);
cmd.Parameters.AddWithValue("@Id", rental.Id);
cmd.Parameters.AddWithValue("@CarId", rental.CarId);
cmd.Parameters.AddWithValue("@ClientId", rental.ClientId);
cmd.Parameters.AddWithValue("@StartDate", rental.StartDate);
cmd.Parameters.AddWithValue("@EndDate", rental.EndDate);
cmd.Parameters.AddWithValue("@Cost", rental.Cost);
cmd.ExecuteNonQuery();
}