Another fixation.

This commit is contained in:
Programmist73 2023-05-10 21:55:18 +04:00
parent dc140799a2
commit 3cb983b7dc
3 changed files with 27 additions and 3 deletions

View File

@ -62,7 +62,8 @@ namespace TransportCompamyMongoDBImplementer.Implements
var truckingCollection = context.ConnectToMongo<Trucking>("trucking");
return truckingCollection.Find(x => !string.IsNullOrEmpty(model.MongoId) && x.Id == model.MongoId)
//не забудь, что тут сделал исправление для поиска по id клиента в MongoDB
return truckingCollection.Find(x => x.Client.Id == model.MongoId)
.ToList()
.Select(x => x.GetViewModel)
.ToList();

View File

@ -50,6 +50,7 @@ namespace TransportCompany
if (view != null)
{
textBoxTransport.Text = view.Tranport;
textBoxTypeTransportation.Text = view.TransportationType;
}
}
catch (Exception ex)

View File

@ -29,6 +29,7 @@ namespace TransportCompany
_logger = logger;
_truckingLogic = truckingLogic;
_clientLogic = clientLogic;
_mongo = false;
}
private void FormMain_Load(object sender, EventArgs e)
@ -70,7 +71,16 @@ namespace TransportCompany
if (listClients != null)
{
comboBoxEmails.DisplayMember = "Email";
if (_mongo)
{
comboBoxEmails.ValueMember = "MongoId";
}
else
{
comboBoxEmails.ValueMember = "Id";
}
comboBoxEmails.DataSource = listClients;
comboBoxEmails.SelectedItem = null;
}
@ -103,6 +113,8 @@ namespace TransportCompany
if (service is FormTransport form)
{
form.SetMongo = _mongo;
form.ShowDialog();
LoadData();
}
@ -179,10 +191,17 @@ namespace TransportCompany
LoadData();
}
else
{
if (_mongo)
{
dataGridView.DataSource = _truckingLogic.ReadList(new TruckingSearchModel { MongoId = comboBoxEmails.SelectedValue.ToString() });
}
else
{
dataGridView.DataSource = _truckingLogic.ReadList(null).Where(x => x.ClientId == comboBoxEmails.SelectedIndex).ToList();
}
}
}
private void CheckBoxSorted_CheckedChanged(object sender, EventArgs e)
{
@ -239,6 +258,7 @@ namespace TransportCompany
}
}*/
//ïåðåäà÷à äàííûõ èç Postgresql â MongoDB
private void TransferDataToolStripMenuItem_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormTransferData));
@ -249,6 +269,7 @@ namespace TransportCompany
}
}
//ðàáîòà ñ Postgresql
private void StartPostgresqlToolStripMenuItem_Click(object sender, EventArgs e)
{
_mongo = false;
@ -261,6 +282,7 @@ namespace TransportCompany
LoadData();
}
//ðàáîòà ñ MongoBD
private void StartMongoDBToolStripMenuItem_Click(object sender, EventArgs e)
{
_mongo = true;