Compare commits

...

3 Commits
main ... Lab1

Author SHA1 Message Date
repka228
9dd158bd4c Интерфейсы репозиториев, репозитории и unity контейнер 2024-11-11 07:13:49 +04:00
repka228
b2c8a278be изменения сущностей 2024-11-11 06:21:25 +04:00
repka228
1f09536c8e сущности 2024-11-11 00:09:18 +04:00
20 changed files with 326 additions and 4 deletions

View File

@ -0,0 +1,18 @@
namespace ProjectRacing.Entities;
public class Competitions
{
public int Id { get; set; }
public DateOnly DateOfCompetitions { get; set; }
public string Adress { get; set; } = string.Empty;
public static Competitions CreateEntity(int id, DateOnly dateOfCompetitions, string adress)
{
return new Competitions
{
Id = id,
Adress = adress,
DateOfCompetitions = dateOfCompetitions
};
}
}

View File

@ -0,0 +1,25 @@
namespace ProjectRacing.Entities;
public class Horse
{
public int Id { get; private set; }
public string NameOfHorse { get; private set; } = string.Empty;
public bool Sex { get; private set; }
public DateOnly Birthday { get; private set; }
public int OwnerId { get; private set; }
public static Horse CreateEntity(int id, string nameOfHorse, bool sex, DateOnly birthday, int ownerId)
{
return new Horse
{
Id = id,
NameOfHorse = nameOfHorse,
Sex = sex,
Birthday = birthday,
OwnerId = ownerId
};
}
}

View File

@ -0,0 +1,21 @@
namespace ProjectRacing.Entities;
public class Jockey
{
public int Id { get; private set; }
public string NameOfJockey { get; private set; } = string.Empty;
public int Age { get; private set; }
public int Rating { get; private set; }
public string Number { get; private set; } = string.Empty;
public static Jockey CreateEntity(int id, string nameOfJockey, int age, int rating, string number)
{
return new Jockey
{
Id = id,
NameOfJockey = nameOfJockey,
Age = age,
Rating = rating,
Number = number
};
}
}

View File

@ -0,0 +1,16 @@
namespace ProjectRacing.Entities;
public class Owner
{
public int Id { get; private set; }
public string NameOfOwner { get; private set; } = string.Empty;
public string Number { get; private set; } = string.Empty;
public static Owner CreateEntity(int id, string nameOfOwner, string number)
{
return new Owner
{
Id = id,
NameOfOwner = nameOfOwner,
Number = number
};
}
}

View File

@ -0,0 +1,24 @@
namespace ProjectRacing.Entities;
public class Participants
{
public int ParticipantId { get; private set; }
public int JockeyId { get; private set; }
public int HorseId { get; private set; }
public int CompetitionsId { get; private set; }
public TimeSpan HorseTime { get; private set; }
public int HorsePlase { get; private set; }
public static Participants CreateEntity(int id, int jockeyId, int horseId, int competitionsId, TimeSpan horseTime, int horsePlace)
{
return new Participants
{
ParticipantId = id,
JockeyId = jockeyId,
HorseId = horseId,
CompetitionsId = competitionsId,
HorseTime = horseTime,
HorsePlase = horsePlace
};
}
}

View File

@ -1,6 +1,6 @@
namespace ProjectRacing namespace ProjectRacing
{ {
partial class Form1 partial class FormRacing
{ {
/// <summary> /// <summary>
/// Required designer variable. /// Required designer variable.

View File

@ -1,8 +1,8 @@
namespace ProjectRacing namespace ProjectRacing
{ {
public partial class Form1 : Form public partial class FormRacing : Form
{ {
public Form1() public FormRacing()
{ {
InitializeComponent(); InitializeComponent();
} }

View File

@ -1,3 +1,7 @@
using ProjectRacing.Repositories;
using ProjectRacing.Repositories.Implementations;
using Unity;
namespace ProjectRacing namespace ProjectRacing
{ {
internal static class Program internal static class Program
@ -11,7 +15,18 @@ namespace ProjectRacing
// To customize application configuration such as set high DPI settings or default font, // To customize application configuration such as set high DPI settings or default font,
// see https://aka.ms/applicationconfiguration. // see https://aka.ms/applicationconfiguration.
ApplicationConfiguration.Initialize(); ApplicationConfiguration.Initialize();
Application.Run(new Form1()); Application.Run(CreateContainer().Resolve<FormRacing>());
}
private static IUnityContainer CreateContainer()
{
var container = new UnityContainer();
container.RegisterType<ICompetitionsRepository, CompetitionsRepository>();
container.RegisterType<IHorseRepository, HorseRepository>();
container.RegisterType<IJockeyRepository, JockeyRepository>();
container.RegisterType<IOwnerRepository, OwnerRepository>();
container.RegisterType<IParticipantsRepository, ParticipantsRepository>();
return container;
} }
} }
} }

View File

@ -8,4 +8,8 @@
<ImplicitUsings>enable</ImplicitUsings> <ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup> </PropertyGroup>
<ItemGroup>
<PackageReference Include="Unity" Version="5.11.10" />
</ItemGroup>
</Project> </Project>

View File

@ -0,0 +1,11 @@
using ProjectRacing.Entities;
namespace ProjectRacing.Repositories;
public interface ICompetitionsRepository
{
IEnumerable<Competitions> GetCompetitionses();
Competitions GetCompetitionsById(int id);
void CreateCompetitions(Competitions competitions);
void UpdateCompetitions(Competitions competitions);
void DeleteCompetitions(int id);
}

View File

@ -0,0 +1,10 @@
using ProjectRacing.Entities;
namespace ProjectRacing.Repositories;
public interface IHorseRepository
{
IEnumerable<Horse> GetHorses();
Horse GetHorseById(int id);
void CreateHorse(Horse horse);
void UpdateHorse(Horse horse);
void DeleteHorse(int id);
}

View File

@ -0,0 +1,11 @@
using ProjectRacing.Entities;
namespace ProjectRacing.Repositories;
public interface IJockeyRepository
{
IEnumerable<Jockey> GetJockeys();
Jockey GetJockeyById(int id);
void CreateJockey(Jockey jockey);
void UpdateJockey(Jockey jockey);
void DeleteJockey(int id);
}

View File

@ -0,0 +1,11 @@
using ProjectRacing.Entities;
namespace ProjectRacing.Repositories;
public interface IOwnerRepository
{
IEnumerable<Owner> GetOwner();
Owner GetOwnerById(int id);
void CreateOwner(Owner owner);
void UpdateOwner(Owner owner);
void DeleteOwner(int id);
}

View File

@ -0,0 +1,11 @@
using ProjectRacing.Entities;
namespace ProjectRacing.Repositories;
public interface IParticipantsRepository
{
IEnumerable<Participants> GetParticipants();
Participants GetParticipantsById(int id);
void CreateParticipants(Participants participants);
void UpdateParticipants(Participants participants);
void DeleteParticipants(int id);
}

View File

@ -0,0 +1,29 @@
using ProjectRacing.Entities;
namespace ProjectRacing.Repositories.Implementations;
internal class CompetitionsRepository : ICompetitionsRepository
{
public void CreateCompetitions(Competitions competitions)
{
}
public void DeleteCompetitions(int id)
{
}
public Competitions GetCompetitionsById(int id)
{
return Competitions.CreateEntity(0, new DateOnly(0001,1,1), string.Empty);
}
public IEnumerable<Competitions> GetCompetitionses()
{
return [];
}
public void UpdateCompetitions(Competitions competitions)
{
}
}

View File

@ -0,0 +1,29 @@
using ProjectRacing.Entities;
namespace ProjectRacing.Repositories.Implementations;
public class HorseRepository : IHorseRepository
{
public void CreateHorse(Horse horse)
{
}
public void DeleteHorse(int id)
{
}
public Horse GetHorseById(int id)
{
return Horse.CreateEntity(0, string.Empty, true, new DateOnly(0001, 1, 1), 0);
}
public IEnumerable<Horse> GetHorses()
{
return [];
}
public void UpdateHorse(Horse horse)
{
}
}

View File

@ -0,0 +1,29 @@
using ProjectRacing.Entities;
namespace ProjectRacing.Repositories.Implementations;
internal class JockeyRepository : IJockeyRepository
{
public void CreateJockey(Jockey jockey)
{
}
public void DeleteJockey(int id)
{
}
public Jockey GetJockeyById(int id)
{
return Jockey.CreateEntity(0, string.Empty, 0, 0, string.Empty);
}
public IEnumerable<Jockey> GetJockeys()
{
return [];
}
public void UpdateJockey(Jockey jockey)
{
}
}

View File

@ -0,0 +1,29 @@
using ProjectRacing.Entities;
namespace ProjectRacing.Repositories.Implementations;
internal class OwnerRepository : IOwnerRepository
{
public void CreateOwner(Owner owner)
{
}
public void DeleteOwner(int id)
{
}
public IEnumerable<Owner> GetOwner()
{
return [];
}
public Owner GetOwnerById(int id)
{
return Owner.CreateEntity(0, string.Empty, string.Empty);
}
public void UpdateOwner(Owner owner)
{
}
}

View File

@ -0,0 +1,29 @@
using ProjectRacing.Entities;
namespace ProjectRacing.Repositories.Implementations;
internal class ParticipantsRepository : IParticipantsRepository
{
public void CreateParticipants(Participants participants)
{
}
public void DeleteParticipants(int id)
{
}
public IEnumerable<Participants> GetParticipants()
{
return [];
}
public Participants GetParticipantsById(int id)
{
return Participants.CreateEntity(0, 0, 0, 0, TimeSpan.Zero, 0);
}
public void UpdateParticipants(Participants participants)
{
}
}