This commit is contained in:
Danil Markov 2023-04-21 13:55:02 +04:00
parent 1779a803a9
commit bca8b0373a
2 changed files with 7 additions and 7 deletions

View File

@ -11,19 +11,19 @@ namespace LawFirmFileImplement.Models
public string DocumentName { get; private set; } = string.Empty;
public double Price { get; private set; }
public Dictionary<int, int> Blanks { get; private set; } = new();
private Dictionary<int, (IBlankModel, int)>? _productBlanks = null;
private Dictionary<int, (IBlankModel, int)>? _documentBlanks = null;
public Dictionary<int, (IBlankModel, int)> DocumentBlanks
{
get
{
if (_productBlanks == null)
if (_documentBlanks == null)
{
var source = DataFileSingleton.GetInstance();
_productBlanks = Blanks.ToDictionary(x => x.Key, y =>
_documentBlanks = Blanks.ToDictionary(x => x.Key, y =>
((source.Blanks.FirstOrDefault(z => z.Id == y.Key) as IBlankModel)!,
y.Value));
}
return _productBlanks;
return _documentBlanks;
}
}
public static Document? Create(DocumentBindingModel model)
@ -69,7 +69,7 @@ namespace LawFirmFileImplement.Models
Price = model.Price;
Blanks = model.DocumentBlanks.ToDictionary(x => x.Key, x =>
x.Value.Item2);
_productBlanks = null;
_documentBlanks = null;
}
public DocumentViewModel GetViewModel => new()
{

View File

@ -45,12 +45,12 @@ namespace LawFirmView
try
{
int id = Convert.ToInt32(comboBoxDocument.SelectedValue);
var product = _logicD.ReadElement(new DocumentSearchModel
var document = _logicD.ReadElement(new DocumentSearchModel
{
Id = id
});
int count = Convert.ToInt32(textBoxCount.Text);
textBoxSum.Text = Math.Round(count * (product?.Price ?? 0), 2).ToString();
textBoxSum.Text = Math.Round(count * (document?.Price ?? 0), 2).ToString();
_logger.LogInformation("Расчет суммы заказа");
}
catch (Exception ex)