Добавили реализацию интерфейсов, добавили контейнер

This commit is contained in:
Tonb73 2024-11-08 21:29:34 +04:00
parent b130453828
commit 0265c4ebfc
11 changed files with 150 additions and 7 deletions

View File

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

View File

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

View File

@ -0,0 +1,34 @@
using ProjectTourAgency.Enities;
using ProjectTourAgency.Repositories;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectTourAgency.Implementations;
public class ClientRepository : IClientRepository
{
public void CreateClient(Client client)
{
}
public void DeleteClient(int id)
{
}
public Client ReadClientById(int id)
{
return Client.CreateEntity(0, string.Empty, DateTime.Now, string.Empty, 0);
}
public IEnumerable<Client> ReadClients()
{
return [];
}
public void UpdateClient(Client client)
{
}
}

View File

@ -0,0 +1,36 @@
using ProjectTourAgency.Enities;
using ProjectTourAgency.Repositories;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectTourAgency.Implementations;
public class DiscountRepository : IDiscountRepository
{
public void CreateDiscount(Discount discount)
{
}
public void DeleteDiscount(int id)
{
}
public Discount ReadDiscountById(int id)
{
return Discount.CreateEntity(0, 0, 0, 0);
}
public IEnumerable<Discount> ReadDiscounts()
{
return [];
}
public void UpdateDiscount(Discount discount)
{
}
}

View File

@ -0,0 +1,21 @@
using ProjectTourAgency.Enities;
using ProjectTourAgency.Repositories;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectTourAgency.Implementations;
public class ReceiptRepository : IReceiptRepository
{
public void CreateReceipt(Receipt receipt)
{
}
public IEnumerable<Receipt> ReadReceipts(DateTime? dateFrom = null, DateTime? dateTo = null, int? clientId = null, int? tourId = null)
{
return [];
}
}

View File

@ -0,0 +1,35 @@
using ProjectTourAgency.Enities;
using ProjectTourAgency.Repositories;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectTourAgency.Implementations;
public class TourRepositiry : ITourRepositiry
{
public void CreateTourt(Tour tour)
{
}
public void DeleteTour(int id)
{
}
public Tour ReadTourById(int id)
{
return Tour.CreateEntity(0, string.Empty, DateTime.Now, string.Empty, 0);
}
public IEnumerable<Tour> ReadTours()
{
return [];
}
public void UpdateTour(Tour tour)
{
}
}

View File

@ -1,3 +1,7 @@
using ProjectTourAgency.Implementations;
using ProjectTourAgency.Repositories;
using Unity;
namespace ProjectTourAgency
{
internal static class Program
@ -11,7 +15,19 @@ namespace ProjectTourAgency
// 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<FormTourAgency>());
}
private static IUnityContainer CreateContainer()
{
var container = new UnityContainer();
container.RegisterType<IClientRepository, ClientRepository>();
container.RegisterType<IDiscountRepository, DiscountRepository>();
container.RegisterType<IReceiptRepository, ReceiptRepository>();
container.RegisterType<ITourRepositiry, TourRepositiry>();
return container;
}
}
}

View File

@ -9,7 +9,7 @@
</PropertyGroup>
<ItemGroup>
<Folder Include="Implementations\" />
<PackageReference Include="Unity" Version="5.11.10" />
</ItemGroup>
</Project>

View File

@ -11,7 +11,7 @@ public interface IDiscountRepository
{
IEnumerable<Discount> ReadDiscounts();
Client ReadDiscountById(int id);
Discount ReadDiscountById(int id);
void CreateDiscount(Discount discount);
void UpdateDiscount(Discount discount);

View File

@ -11,9 +11,10 @@ public interface ITourRepositiry
{
IEnumerable<Tour> ReadTours();
Client ReadTourById(int id);
Tour ReadTourById(int id);
void CreateTourt(Tour tour);
void UpdateTour(Tour tour);
void DeleteTour(int id);