This commit is contained in:
Danil Markov 2023-05-11 00:01:58 +04:00
parent d81f2cf847
commit 29481698ab
4 changed files with 15 additions and 4 deletions

View File

@ -2,6 +2,7 @@
using CarRentContracts.BindingModels;
using CarRentContracts.BusinessLogicContracts;
using CarRentContracts.SearchModels;
using CarRentContracts.ViewModels;
using ClientRentBusinessLogic.BusinessLogics;
using System;
using System.Collections.Generic;
@ -146,7 +147,16 @@ namespace CarRent
{
try
{
var view = _carLogic.ReadElement(new CarSearchModel { Id = _id.Value });
CarViewModel? view;
if (Program.CURRENT_DATABASE.Equals("PostgreSQL"))
{
view = _carLogic.ReadElement(new CarSearchModel { Id = _id });
}
else
{
view = _carLogic.ReadElement(new CarSearchModel { ObjectId = _objectId });
}
if (view != null)
{

View File

@ -182,7 +182,7 @@ namespace CarRent
if (service is FormCreateRental form)
{
form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
form.ObjectId = dataGridView.SelectedRows[0].Cells["ObjectId"].Value.ToString() ?? string.Empty;
form.ObjectId = dataGridView.SelectedRows[0].Cells["ObjectId"].Value.ToString() ?? string.Empty;
if (form.ShowDialog() == DialogResult.OK)
{

View File

@ -135,7 +135,7 @@ namespace CarRentMongoDB.Implements
{
using var context = new CarRentMongoDB();
var cars = context.GetCollection<Car>("Cars");
var filter = Builders<Car>.Filter.Eq(x => x.Id, model.Id);
var filter = Builders<Car>.Filter.Eq(x => x.ObjectId, model.ObjectId);
var component = cars.Find(filter).FirstOrDefault();
if (component == null)
{
@ -150,7 +150,7 @@ namespace CarRentMongoDB.Implements
{
using var context = new CarRentMongoDB();
var cars = context.GetCollection<Car>("Cars");
var filter = Builders<Car>.Filter.Eq(x => x.Id, model.Id);
var filter = Builders<Car>.Filter.Eq(x => x.ObjectId, model.ObjectId);
var element = cars.Find(filter).FirstOrDefault();
if (element != null)
{

View File

@ -83,6 +83,7 @@ namespace CarRentMongoDB.Models
Color = model.Color;
LicensePlate = model.LicensePlate;
RentalCostPerHour = model.RentalCostPerHour;
BranchStringId = model.BranchStringId;
}
public CarViewModel GetViewModel => new()