исправление ошибок

This commit is contained in:
Алёна Фролова 2024-12-05 14:14:20 +04:00
parent c9057af05a
commit a52015a455
5 changed files with 24 additions and 26 deletions

View File

@ -8,6 +8,7 @@ namespace ProjectHorseRacing.Entities.Enums;
public enum HorseGender
{
None = 0,
Женский = 1,

View File

@ -9,6 +9,7 @@ namespace ProjectHorseRacing.Entities.Enums;
public enum RacePlaceEvent
{
None = 0,
Ипподром_1 = 1,

View File

@ -19,32 +19,32 @@ public partial class FormRace : Form
private readonly IRaceRepository _raceRepository;
private int? _raceId;
private int? _raceId;
public int Id
public int Id
{
set
{
set
try
{
try
var race = _raceRepository.ReadRaceById(value);
if (race == null)
{
var race = _raceRepository.ReadRaceById(value);
if (race == null)
{
throw new InvalidDataException(nameof(race));
}
dateTimePicker.Value = race.DateTime;
comboBoxPlaceEvent.SelectedItem = race.RacePlaceEvent;
_raceId = value;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при получении данных", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
throw new InvalidDataException(nameof(race));
}
dateTimePicker1.Value = race.DateTime.Date;
comboBoxPlaceEvent.SelectedItem = race.RacePlaceEvent;
_raceId = value;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при получении данных", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
}
}
public FormRace(IRaceRepository raceRepository)
{
@ -82,6 +82,6 @@ public partial class FormRace : Form
private void CancelButtonHorse_Click(object sender, EventArgs e) => Close();
private Race CreateRace(int id) => Race.CreateOperation(id, dateTimePicker.Value, (RacePlaceEvent)comboBoxPlaceEvent.SelectedItem!);
private Race CreateRace(int id) => Race.CreateOperation(id, dateTimePicker1.Value, (RacePlaceEvent)comboBoxPlaceEvent.SelectedItem!);
}

View File

@ -45,11 +45,7 @@ public class BuyHorseRepository : IBuyHorseRepository
foreach (var elem in buyHorse.BuyHorseHorses)
{
connection.Execute(queryBuyInsert, new
{
buyHorseId,
elem.HorseId
}, transaction);
connection.Execute(queryBuyInsert, new {buyHorseId, elem.HorseId}, transaction);
}
transaction.Commit();
}

View File

@ -117,7 +117,7 @@ public class JockeyRepository : IJockeyRepository
FirstName= @FirstName,
LastName= @LastName,
Age= @Age,
Rating= @Rating,
Rating= @Rating
WHERE Id= @Id";
connection.Execute(queryUpdate, jockey);
}