From d00e014de571a448005a3e462665a2ba7dd25644 Mon Sep 17 00:00:00 2001 From: Programmist73 Date: Wed, 10 May 2023 22:12:56 +0400 Subject: [PATCH] =?UTF-8?q?=D0=9E=D1=81=D1=82=D0=B0=D0=BB=D0=B8=D1=81?= =?UTF-8?q?=D1=8C=20=D0=BF=D0=BE=D0=BD=D1=82=D1=8B.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Implements/TransportStorage.cs | 42 ++++++++++++++++++- .../TransportCompany/FormTransport.cs | 3 +- 2 files changed, 42 insertions(+), 3 deletions(-) diff --git a/TransportCompany/TransportCompamyMongoDBImplementer/Implements/TransportStorage.cs b/TransportCompany/TransportCompamyMongoDBImplementer/Implements/TransportStorage.cs index 9d629d6..e7e5f1f 100644 --- a/TransportCompany/TransportCompamyMongoDBImplementer/Implements/TransportStorage.cs +++ b/TransportCompany/TransportCompamyMongoDBImplementer/Implements/TransportStorage.cs @@ -95,10 +95,48 @@ namespace TransportCompamyMongoDBImplementer.Implements List models = model.Select(x => Transport.Create(new() { - Tranport = x.Tranport, - TransportationType = "Что-то" + Tranport = x.Tranport })).ToList(); + //цикл для перезаписи типа грузоперевозки + foreach (var transport in models) + { + if (transport.TransportType.Equals("Баржа")) + { + transport.TransportationType = "Грузовая"; + } + + if (transport.TransportType.Equals("Вертолёт")) + { + transport.TransportationType = "Пассажирская"; + } + + if (transport.TransportType.Equals("Самолёт")) + { + transport.TransportationType = "Пассажирская"; + } + + if (transport.TransportType.Equals("Легковой автомобиль")) + { + transport.TransportationType = "Пассажирская"; + } + + if (transport.TransportType.Equals("Фура")) + { + transport.TransportationType = "Грузовая"; + } + + if (transport.TransportType.Equals("Минивен")) + { + transport.TransportationType = "Грузовая"; + } + + if (transport.TransportType.Equals("Открытый грузовик")) + { + transport.TransportationType = "Перевозка животных"; + } + } + transportCollection.InsertMany(models); return true; diff --git a/TransportCompany/TransportCompany/FormTransport.cs b/TransportCompany/TransportCompany/FormTransport.cs index 2d5718b..98142c7 100644 --- a/TransportCompany/TransportCompany/FormTransport.cs +++ b/TransportCompany/TransportCompany/FormTransport.cs @@ -51,6 +51,7 @@ namespace TransportCompany { dataGridView.Columns["Id"].Visible = true; dataGridView.Columns["MongoId"].Visible = false; + dataGridView.Columns["TransportationType"].Visible = false; } else { @@ -58,7 +59,7 @@ namespace TransportCompany dataGridView.Columns["MongoId"].Visible = true; } - dataGridView.Columns[1].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; + dataGridView.Columns[2].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; } _logger.LogInformation("Загрузка транспортных средств");