From 970ea7af868bbb499446157cc14f0de7691d8d18 Mon Sep 17 00:00:00 2001 From: cyxaruk Date: Tue, 12 Nov 2024 20:11:03 +0400 Subject: [PATCH] =?UTF-8?q?=D0=BF=D0=BE=D0=BB=D0=BE=D0=B2=D0=B8=D0=BD?= =?UTF-8?q?=D0=B0=20=D0=BB=D0=B0=D0=B1=D1=8B,=20=D0=B1=D0=B5=D0=B7=20?= =?UTF-8?q?=D1=84=D0=BE=D1=80=D0=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Entities/Bus.cs | 19 ++++------ .../Entities/Employee.cs | 4 +- .../Entities/Enums/EmployeePost.cs | 8 +--- .../Entities/Enums/RouteListType.cs | 21 ++++++++++ .../Entities/RouteGiveaway.cs | 24 ++++++++++++ .../Entities/RouteList.cs | 35 +++++++++++++++++ .../Entities/RouteRouteGiveaway.cs | 21 ++++++++++ .../Entities/StartingShift.cs | 38 +++++++++++++++++++ .../ProjectPeopleTransportation/Program.cs | 19 +++++++++- .../ProjectPeopleTransportation.csproj | 4 ++ .../Repositories/IBusRepository.cs | 16 ++++++++ .../Repositories/IEmployeeRepository.cs | 16 ++++++++ .../Repositories/IRouteGiveawayRepository.cs | 13 +++++++ .../Repositories/IRouteListRepository.cs | 17 +++++++++ .../Repositories/IStartingShiftRepository.cs | 11 ++++++ .../Implementations/BusRepository.cs | 28 ++++++++++++++ .../Implementations/EmployeeRepository.cs | 29 ++++++++++++++ .../RouteGiveawayRepository.cs | 19 ++++++++++ .../Implementations/RouteListRepository.cs | 29 ++++++++++++++ .../StartingShiftRepository.cs | 16 ++++++++ 20 files changed, 367 insertions(+), 20 deletions(-) create mode 100644 ProjectPeopleTransportation/ProjectPeopleTransportation/Entities/Enums/RouteListType.cs create mode 100644 ProjectPeopleTransportation/ProjectPeopleTransportation/Entities/RouteGiveaway.cs create mode 100644 ProjectPeopleTransportation/ProjectPeopleTransportation/Entities/RouteList.cs create mode 100644 ProjectPeopleTransportation/ProjectPeopleTransportation/Entities/RouteRouteGiveaway.cs create mode 100644 ProjectPeopleTransportation/ProjectPeopleTransportation/Entities/StartingShift.cs create mode 100644 ProjectPeopleTransportation/ProjectPeopleTransportation/Repositories/IBusRepository.cs create mode 100644 ProjectPeopleTransportation/ProjectPeopleTransportation/Repositories/IEmployeeRepository.cs create mode 100644 ProjectPeopleTransportation/ProjectPeopleTransportation/Repositories/IRouteGiveawayRepository.cs create mode 100644 ProjectPeopleTransportation/ProjectPeopleTransportation/Repositories/IRouteListRepository.cs create mode 100644 ProjectPeopleTransportation/ProjectPeopleTransportation/Repositories/IStartingShiftRepository.cs create mode 100644 ProjectPeopleTransportation/ProjectPeopleTransportation/Repositories/Implementations/BusRepository.cs create mode 100644 ProjectPeopleTransportation/ProjectPeopleTransportation/Repositories/Implementations/EmployeeRepository.cs create mode 100644 ProjectPeopleTransportation/ProjectPeopleTransportation/Repositories/Implementations/RouteGiveawayRepository.cs create mode 100644 ProjectPeopleTransportation/ProjectPeopleTransportation/Repositories/Implementations/RouteListRepository.cs create mode 100644 ProjectPeopleTransportation/ProjectPeopleTransportation/Repositories/Implementations/StartingShiftRepository.cs diff --git a/ProjectPeopleTransportation/ProjectPeopleTransportation/Entities/Bus.cs b/ProjectPeopleTransportation/ProjectPeopleTransportation/Entities/Bus.cs index 3abd200..664b39d 100644 --- a/ProjectPeopleTransportation/ProjectPeopleTransportation/Entities/Bus.cs +++ b/ProjectPeopleTransportation/ProjectPeopleTransportation/Entities/Bus.cs @@ -6,27 +6,24 @@ using System.Threading.Tasks; namespace ProjectPeopleTransportation.Entities; -internal class Bus +public class Bus { public int ID { get; private set; } - public string Model { get; private set; } = string.Empty; + public string BusName { get; private set; } = string.Empty; - public string Brand { get; private set; } = string.Empty; + public int LicensePlate { get; private set; } - public int BusNum { get; private set; } + public int Capacity { get; private set; } - public int YearOfCreation { get; private set; } - - public static Bus CreateEntity(int id, string model, int busNum, string brand, int yearOfCreation) + public static Bus CreateEntity(int id, string busName, int licensePlate, int capacity) { return new Bus { ID = id, - Model = model, - BusNum = busNum, - Brand = brand, - YearOfCreation = yearOfCreation + BusName = busName, + LicensePlate = licensePlate, + Capacity = capacity }; } diff --git a/ProjectPeopleTransportation/ProjectPeopleTransportation/Entities/Employee.cs b/ProjectPeopleTransportation/ProjectPeopleTransportation/Entities/Employee.cs index f33b779..740a267 100644 --- a/ProjectPeopleTransportation/ProjectPeopleTransportation/Entities/Employee.cs +++ b/ProjectPeopleTransportation/ProjectPeopleTransportation/Entities/Employee.cs @@ -4,7 +4,7 @@ namespace ProjectPeopleTransportation.Entities; public class Employee { - public int Id { get; private set; } + public int ID { get; private set; } public string FirstName { get; private set; } = string.Empty; @@ -18,7 +18,7 @@ public class Employee { return new Employee { - Id = id, + ID = id, FirstName = first ?? string.Empty, LastName = last ?? string.Empty, PhoneNum = phone, diff --git a/ProjectPeopleTransportation/ProjectPeopleTransportation/Entities/Enums/EmployeePost.cs b/ProjectPeopleTransportation/ProjectPeopleTransportation/Entities/Enums/EmployeePost.cs index bc61dc6..3641d74 100644 --- a/ProjectPeopleTransportation/ProjectPeopleTransportation/Entities/Enums/EmployeePost.cs +++ b/ProjectPeopleTransportation/ProjectPeopleTransportation/Entities/Enums/EmployeePost.cs @@ -10,11 +10,7 @@ public enum EmployeePost { None = 0, - Admin = 1, + Driver = 1, - Engineer = 2, - - Driver = 3, - - Conductor = 4 + Conductor = 2 } diff --git a/ProjectPeopleTransportation/ProjectPeopleTransportation/Entities/Enums/RouteListType.cs b/ProjectPeopleTransportation/ProjectPeopleTransportation/Entities/Enums/RouteListType.cs new file mode 100644 index 0000000..384495b --- /dev/null +++ b/ProjectPeopleTransportation/ProjectPeopleTransportation/Entities/Enums/RouteListType.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectPeopleTransportation.Entities.Enums; + +[Flags] +public enum RouteListType +{ + None = 0, + + RouteNum1 = 1, + + RouteNum2 = 2, + + RouteNum3 = 4, + + RouteNum4 = 8 +} diff --git a/ProjectPeopleTransportation/ProjectPeopleTransportation/Entities/RouteGiveaway.cs b/ProjectPeopleTransportation/ProjectPeopleTransportation/Entities/RouteGiveaway.cs new file mode 100644 index 0000000..1483f18 --- /dev/null +++ b/ProjectPeopleTransportation/ProjectPeopleTransportation/Entities/RouteGiveaway.cs @@ -0,0 +1,24 @@ +namespace ProjectPeopleTransportation.Entities; + +public class RouteGiveaway +{ + public int ID { get; private set; } + + public int EmployeeID { get; private set; } + + public DateTime DateReceipt { get; private set; } + + public IEnumerable RouteRouteGiveaway { get; private set; } = []; + + public static RouteGiveaway CreateOperation(int id, int employeeID, IEnumerable routeRouteGiveaway) + { + return new RouteGiveaway + { + ID = id, + EmployeeID = employeeID, + DateReceipt = DateTime.Now, + RouteRouteGiveaway = routeRouteGiveaway + }; + + } +} diff --git a/ProjectPeopleTransportation/ProjectPeopleTransportation/Entities/RouteList.cs b/ProjectPeopleTransportation/ProjectPeopleTransportation/Entities/RouteList.cs new file mode 100644 index 0000000..99ef7ec --- /dev/null +++ b/ProjectPeopleTransportation/ProjectPeopleTransportation/Entities/RouteList.cs @@ -0,0 +1,35 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +using ProjectPeopleTransportation.Entities.Enums; + +namespace ProjectPeopleTransportation.Entities; + + +public class RouteList +{ + public int ID { get; private set; } + + public RouteListType RouteListType { get; private set; } + + public string Name { get; private set; } = string.Empty; + + public string Description { get; private set; } = string.Empty; + + public static RouteList CreateEntity(int id, string name, string description, RouteListType routeListType) + { + return new RouteList + { + ID = id, + RouteListType = routeListType, + Name = name ?? string.Empty, + Description = description ?? string.Empty + }; + + } + + +} diff --git a/ProjectPeopleTransportation/ProjectPeopleTransportation/Entities/RouteRouteGiveaway.cs b/ProjectPeopleTransportation/ProjectPeopleTransportation/Entities/RouteRouteGiveaway.cs new file mode 100644 index 0000000..500ad18 --- /dev/null +++ b/ProjectPeopleTransportation/ProjectPeopleTransportation/Entities/RouteRouteGiveaway.cs @@ -0,0 +1,21 @@ +namespace ProjectPeopleTransportation.Entities; + +public class RouteRouteGiveaway +{ + public int ID { get; private set; } + + public int RouteID { get; private set; } + + public int Count { get; private set; } + + public static RouteRouteGiveaway CreateElement(int id, int routeID, int count) + { + return new RouteRouteGiveaway + { + ID = id, + RouteID = routeID, + Count = count + }; + + } +} diff --git a/ProjectPeopleTransportation/ProjectPeopleTransportation/Entities/StartingShift.cs b/ProjectPeopleTransportation/ProjectPeopleTransportation/Entities/StartingShift.cs new file mode 100644 index 0000000..c02c25e --- /dev/null +++ b/ProjectPeopleTransportation/ProjectPeopleTransportation/Entities/StartingShift.cs @@ -0,0 +1,38 @@ +using ProjectPeopleTransportation.Entities.Enums; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Xml.Linq; + +namespace ProjectPeopleTransportation.Entities; + +public class StartingShift +{ + public int ID { get; private set; } + + public int RouteListID { get; private set; } + + public int EmployeeID { get; private set; } + + public int BusID { get; private set; } + + public DateTime StartingShiftDate { get; private set; } + + public int ShiftDuration { get; private set; } + + public static StartingShift CreateOperation(int id, int routeListID, int employeeID, int busID, int shiftDuration) + { + return new StartingShift + { + ID = id, + RouteListID = routeListID, + EmployeeID = employeeID, + BusID = busID, + StartingShiftDate = DateTime.Now, + ShiftDuration = shiftDuration + }; + + } +} diff --git a/ProjectPeopleTransportation/ProjectPeopleTransportation/Program.cs b/ProjectPeopleTransportation/ProjectPeopleTransportation/Program.cs index d312325..f149e05 100644 --- a/ProjectPeopleTransportation/ProjectPeopleTransportation/Program.cs +++ b/ProjectPeopleTransportation/ProjectPeopleTransportation/Program.cs @@ -1,3 +1,7 @@ +using ProjectPeopleTransportation.Repositories; +using ProjectPeopleTransportation.Repositories.Implementations; +using Unity; + namespace ProjectPeopleTransportation { internal static class Program @@ -11,7 +15,20 @@ namespace ProjectPeopleTransportation // To customize application configuration such as set high DPI settings or default font, // see https://aka.ms/applicationconfiguration. ApplicationConfiguration.Initialize(); - Application.Run(new Form1()); + Application.Run(CreateContainer().Resolve()); + } + + private static IUnityContainer CreateContainer() + { + var container = new UnityContainer(); + + container.RegisterType(); + container.RegisterType(); + container.RegisterType(); + container.RegisterType(); + container.RegisterType(); + + return container; } } } \ No newline at end of file diff --git a/ProjectPeopleTransportation/ProjectPeopleTransportation/ProjectPeopleTransportation.csproj b/ProjectPeopleTransportation/ProjectPeopleTransportation/ProjectPeopleTransportation.csproj index 663fdb8..894afcd 100644 --- a/ProjectPeopleTransportation/ProjectPeopleTransportation/ProjectPeopleTransportation.csproj +++ b/ProjectPeopleTransportation/ProjectPeopleTransportation/ProjectPeopleTransportation.csproj @@ -8,4 +8,8 @@ enable + + + + \ No newline at end of file diff --git a/ProjectPeopleTransportation/ProjectPeopleTransportation/Repositories/IBusRepository.cs b/ProjectPeopleTransportation/ProjectPeopleTransportation/Repositories/IBusRepository.cs new file mode 100644 index 0000000..e3830f4 --- /dev/null +++ b/ProjectPeopleTransportation/ProjectPeopleTransportation/Repositories/IBusRepository.cs @@ -0,0 +1,16 @@ +using ProjectPeopleTransportation.Entities; + +namespace ProjectPeopleTransportation.Repositories; + +public interface IBusRepository +{ + IEnumerable ReadBuses(); + + Bus ReadBusByID(int id); + + void CreateBus(Bus bus); + + void UpdateBus(Bus bus); + + void DeleteBus(int id); +} diff --git a/ProjectPeopleTransportation/ProjectPeopleTransportation/Repositories/IEmployeeRepository.cs b/ProjectPeopleTransportation/ProjectPeopleTransportation/Repositories/IEmployeeRepository.cs new file mode 100644 index 0000000..7609063 --- /dev/null +++ b/ProjectPeopleTransportation/ProjectPeopleTransportation/Repositories/IEmployeeRepository.cs @@ -0,0 +1,16 @@ +using ProjectPeopleTransportation.Entities; + +namespace ProjectPeopleTransportation.Repositories; + +public interface IEmployeeRepository +{ + IEnumerable ReadEmployees(); + + Employee ReadEmployeeByID(int id); + + void CreateEmployee(Employee employee); + + void UpdateEmployee(Employee employee); + + void DeleteEmployee(int id); +} diff --git a/ProjectPeopleTransportation/ProjectPeopleTransportation/Repositories/IRouteGiveawayRepository.cs b/ProjectPeopleTransportation/ProjectPeopleTransportation/Repositories/IRouteGiveawayRepository.cs new file mode 100644 index 0000000..658f482 --- /dev/null +++ b/ProjectPeopleTransportation/ProjectPeopleTransportation/Repositories/IRouteGiveawayRepository.cs @@ -0,0 +1,13 @@ +using ProjectPeopleTransportation.Entities; + +namespace ProjectPeopleTransportation.Repositories; + +public interface IRouteGiveawayRepository +{ + IEnumerable ReadRouteGiveaway(DateTime? dateForm = null, DateTime? dateTo = null, + int? employeeId = null, int? busId = null); + + void CreateRouteGiveaway(RouteGiveaway routeGiveaway); + + void DeleteRouteGiveaway(int id); +} diff --git a/ProjectPeopleTransportation/ProjectPeopleTransportation/Repositories/IRouteListRepository.cs b/ProjectPeopleTransportation/ProjectPeopleTransportation/Repositories/IRouteListRepository.cs new file mode 100644 index 0000000..e0275cc --- /dev/null +++ b/ProjectPeopleTransportation/ProjectPeopleTransportation/Repositories/IRouteListRepository.cs @@ -0,0 +1,17 @@ +using ProjectPeopleTransportation.Entities; + + +namespace ProjectPeopleTransportation.Repositories; + +public interface IRouteListRepository +{ + IEnumerable ReadRouteLists(); + + RouteList ReadRouteListByID(int id); + + void CreateRouteList(RouteList routeList); + + void UpdateRouteList(RouteList routeList); + + void DeleteRouteList(int id); +} \ No newline at end of file diff --git a/ProjectPeopleTransportation/ProjectPeopleTransportation/Repositories/IStartingShiftRepository.cs b/ProjectPeopleTransportation/ProjectPeopleTransportation/Repositories/IStartingShiftRepository.cs new file mode 100644 index 0000000..0d48c73 --- /dev/null +++ b/ProjectPeopleTransportation/ProjectPeopleTransportation/Repositories/IStartingShiftRepository.cs @@ -0,0 +1,11 @@ +using ProjectPeopleTransportation.Entities; + +namespace ProjectPeopleTransportation.Repositories; + +public interface IStartingShiftRepository +{ + IEnumerable ReadStartingShifts(DateTime? dateForm = null, DateTime? dateTo = null, int? routeId = null, + int? employeeId = null, int? busId = null); + + void CreateStartingShift(StartingShift startingShift); +} diff --git a/ProjectPeopleTransportation/ProjectPeopleTransportation/Repositories/Implementations/BusRepository.cs b/ProjectPeopleTransportation/ProjectPeopleTransportation/Repositories/Implementations/BusRepository.cs new file mode 100644 index 0000000..4da4941 --- /dev/null +++ b/ProjectPeopleTransportation/ProjectPeopleTransportation/Repositories/Implementations/BusRepository.cs @@ -0,0 +1,28 @@ +using ProjectPeopleTransportation.Entities; + +namespace ProjectPeopleTransportation.Repositories.Implementations; + +public class BusRepository : IBusRepository +{ + public void CreateBus(Bus bus) + { + } + + public void DeleteBus(int id) + { + } + + public Bus ReadBusByID(int id) + { + return Bus.CreateEntity(0, string.Empty, 0, 0); + } + + public IEnumerable ReadBuses() + { + return []; + } + + public void UpdateBus(Bus bus) + { + } +} diff --git a/ProjectPeopleTransportation/ProjectPeopleTransportation/Repositories/Implementations/EmployeeRepository.cs b/ProjectPeopleTransportation/ProjectPeopleTransportation/Repositories/Implementations/EmployeeRepository.cs new file mode 100644 index 0000000..5e0ff59 --- /dev/null +++ b/ProjectPeopleTransportation/ProjectPeopleTransportation/Repositories/Implementations/EmployeeRepository.cs @@ -0,0 +1,29 @@ +using ProjectPeopleTransportation.Entities; +using ProjectPeopleTransportation.Entities.Enums; + +namespace ProjectPeopleTransportation.Repositories.Implementations; + +public class EmployeeRepository : IEmployeeRepository +{ + public void CreateEmployee(Employee employee) + { + } + + public void DeleteEmployee(int id) + { + } + + public Employee ReadEmployeeByID(int id) + { + return Employee.CreateEntity(0, string.Empty, string.Empty, 0, EmployeePost.None); + } + + public IEnumerable ReadEmployees() + { + return []; + } + + public void UpdateEmployee(Employee employee) + { + } +} diff --git a/ProjectPeopleTransportation/ProjectPeopleTransportation/Repositories/Implementations/RouteGiveawayRepository.cs b/ProjectPeopleTransportation/ProjectPeopleTransportation/Repositories/Implementations/RouteGiveawayRepository.cs new file mode 100644 index 0000000..e80afe4 --- /dev/null +++ b/ProjectPeopleTransportation/ProjectPeopleTransportation/Repositories/Implementations/RouteGiveawayRepository.cs @@ -0,0 +1,19 @@ +using ProjectPeopleTransportation.Entities; + +namespace ProjectPeopleTransportation.Repositories.Implementations; + +public class RouteGiveawayRepository : IRouteGiveawayRepository +{ + public void CreateRouteGiveaway(RouteGiveaway routeGiveaway) + { + } + + public void DeleteRouteGiveaway(int id) + { + } + + public IEnumerable ReadRouteGiveaway(DateTime? dateForm = null, DateTime? dateTo = null, int? employeeId = null, int? busId = null) + { + return []; + } +} diff --git a/ProjectPeopleTransportation/ProjectPeopleTransportation/Repositories/Implementations/RouteListRepository.cs b/ProjectPeopleTransportation/ProjectPeopleTransportation/Repositories/Implementations/RouteListRepository.cs new file mode 100644 index 0000000..ec05882 --- /dev/null +++ b/ProjectPeopleTransportation/ProjectPeopleTransportation/Repositories/Implementations/RouteListRepository.cs @@ -0,0 +1,29 @@ +using ProjectPeopleTransportation.Entities; +using ProjectPeopleTransportation.Entities.Enums; + +namespace ProjectPeopleTransportation.Repositories.Implementations; + +public class RouteListRepository : IRouteListRepository +{ + public void CreateRouteList(RouteList routeList) + { + } + + public void DeleteRouteList(int id) + { + } + + public RouteList ReadRouteListByID(int id) + { + return RouteList.CreateEntity(0, string.Empty, string.Empty, RouteListType.None); + } + + public IEnumerable ReadRouteLists() + { + return []; + } + + public void UpdateRouteList(RouteList routeList) + { + } +} diff --git a/ProjectPeopleTransportation/ProjectPeopleTransportation/Repositories/Implementations/StartingShiftRepository.cs b/ProjectPeopleTransportation/ProjectPeopleTransportation/Repositories/Implementations/StartingShiftRepository.cs new file mode 100644 index 0000000..b15b98c --- /dev/null +++ b/ProjectPeopleTransportation/ProjectPeopleTransportation/Repositories/Implementations/StartingShiftRepository.cs @@ -0,0 +1,16 @@ + +using ProjectPeopleTransportation.Entities; + +namespace ProjectPeopleTransportation.Repositories.Implementations; + +public class StartingShiftRepository : IStartingShiftRepository +{ + public void CreateStartingShift(StartingShift startingShift) + { + } + + public IEnumerable ReadStartingShifts(DateTime? dateForm = null, DateTime? dateTo = null, int? routeId = null, int? employeeId = null, int? busId = null) + { + return []; + } +}