145 lines
5.3 KiB
C#
145 lines
5.3 KiB
C#
using BookingAbstractions.Models;
|
||
using BookingAbstractions.WorkAbstractions;
|
||
|
||
namespace BookingView
|
||
{
|
||
public partial class FormMain : Form
|
||
{
|
||
|
||
public FormMain()
|
||
{
|
||
InitializeComponent();
|
||
}
|
||
|
||
private void издателиToolStripMenuItem_Click(object sender, EventArgs e)
|
||
{
|
||
var service = Program.ServiceProvider?.GetService(typeof(FormPublisher));
|
||
if (service is FormPublisher form)
|
||
{
|
||
form.ShowDialog();
|
||
}
|
||
}
|
||
|
||
private void авторыToolStripMenuItem_Click(object sender, EventArgs e)
|
||
{
|
||
var service = Program.ServiceProvider?.GetService(typeof(FormAuthor));
|
||
if (service is FormAuthor form)
|
||
{
|
||
form.ShowDialog();
|
||
}
|
||
}
|
||
|
||
private void клиентыToolStripMenuItem_Click(object sender, EventArgs e)
|
||
{
|
||
var service = Program.ServiceProvider?.GetService(typeof(FormPublisher));
|
||
if (service is FormPublisher form)
|
||
{
|
||
form.ShowDialog();
|
||
}
|
||
}
|
||
|
||
private void отзывыToolStripMenuItem_Click(object sender, EventArgs e)
|
||
{
|
||
var service = Program.ServiceProvider?.GetService(typeof(FormReview));
|
||
if (service is FormReview form)
|
||
{
|
||
form.ShowDialog();
|
||
}
|
||
}
|
||
|
||
private void заказыToolStripMenuItem_Click(object sender, EventArgs e)
|
||
{
|
||
var service = Program.ServiceProvider?.GetService(typeof(FormBooking));
|
||
if (service is FormBooking form)
|
||
{
|
||
form.ShowDialog();
|
||
}
|
||
}
|
||
|
||
private void книгиToolStripMenuItem_Click(object sender, EventArgs e)
|
||
{
|
||
var service = Program.ServiceProvider?.GetService(typeof(FormBook));
|
||
if (service is FormBook form)
|
||
{
|
||
form.ShowDialog();
|
||
}
|
||
}
|
||
|
||
private void добавление1000ToolStripMenuItem_Click(object sender, EventArgs e)
|
||
{
|
||
var service = Program.ServiceProvider?.GetService(typeof(IPublisherWork));
|
||
if (service is IPublisherWork publisherLogic)
|
||
{
|
||
DateTime startTime = DateTime.Now;
|
||
for (int i = 0; i < 1000; i++)
|
||
{
|
||
Publisher publisher = new()
|
||
{
|
||
Name = "Название №" + i,
|
||
Address = "Адрес " + i,
|
||
PhoneNumber = "Номер " + i
|
||
};
|
||
publisherLogic.Create(publisher);
|
||
}
|
||
DateTime endTime = DateTime.Now;
|
||
|
||
labelTest.Text = $"Добавление 1000 строк выполнено за {(endTime - startTime).TotalMilliseconds} миллисекунд";
|
||
}
|
||
}
|
||
|
||
private void получение1000ToolStripMenuItem_Click(object sender, EventArgs e)
|
||
{
|
||
var service = Program.ServiceProvider?.GetService(typeof(IPublisherWork));
|
||
if (service is IPublisherWork publisherLogic)
|
||
{
|
||
DateTime startTime = DateTime.Now;
|
||
publisherLogic.GetAll();
|
||
DateTime endTime = DateTime.Now;
|
||
|
||
labelTest.Text = $"Получение 1000 строк выполнено за {(endTime - startTime).TotalMilliseconds} миллисекунд";
|
||
}
|
||
}
|
||
|
||
private void обновление1000ToolStripMenuItem_Click(object sender, EventArgs e)
|
||
{
|
||
var service = Program.ServiceProvider?.GetService(typeof(IPublisherWork));
|
||
if (service is IPublisherWork publisherLogic)
|
||
{
|
||
List<int> ids = publisherLogic.GetAll().Select(area => area.Id).ToList();
|
||
DateTime startTime = DateTime.Now;
|
||
for (int i = 0; i < ids.Count; i++)
|
||
{
|
||
Publisher publisher = new()
|
||
{
|
||
Id = ids[i],
|
||
Name = "Название №" + i + 2000,
|
||
Address = "Адрес " + i + 2000,
|
||
PhoneNumber = "Номер " + i + 2000
|
||
};
|
||
publisherLogic.Update(publisher);
|
||
}
|
||
DateTime endTime = DateTime.Now;
|
||
|
||
labelTest.Text = $"Обновление 1000 строк выполнено за {(endTime - startTime).TotalMilliseconds} миллисекунд";
|
||
}
|
||
}
|
||
|
||
private void удаление1000ToolStripMenuItem_Click(object sender, EventArgs e)
|
||
{
|
||
var service = Program.ServiceProvider?.GetService(typeof(IPublisherWork));
|
||
if (service is IPublisherWork publisherLogic)
|
||
{
|
||
List<int> ids = publisherLogic.GetAll().Select(area => area.Id).ToList();
|
||
DateTime startTime = DateTime.Now;
|
||
for (int i = 0; i < ids.Count; i++)
|
||
{
|
||
publisherLogic.Delete(ids[i]);
|
||
}
|
||
DateTime endTime = DateTime.Now;
|
||
|
||
labelTest.Text = $"Удаление 1000 строк выполнено за {(endTime - startTime).TotalMilliseconds} миллисекунд";
|
||
}
|
||
}
|
||
}
|
||
}
|