|
@@ -9,6 +9,7 @@ using System.Collections.Immutable;
|
|
|
using System.Collections.ObjectModel;
|
|
|
using System.Linq;
|
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
+using System.Diagnostics;
|
|
|
|
|
|
namespace SocialEducatorAvalonia.ViewModels
|
|
|
{
|
|
@@ -54,7 +55,7 @@ namespace SocialEducatorAvalonia.ViewModels
|
|
|
readonly Dictionary<string, int> PaymentDict = [];
|
|
|
|
|
|
/// <summary>
|
|
|
- /// перечисление студентов в кеше
|
|
|
+ /// перечисление студентов в кэше
|
|
|
/// </summary>
|
|
|
List<Student> _studentsStorage = [];
|
|
|
|
|
@@ -75,7 +76,7 @@ namespace SocialEducatorAvalonia.ViewModels
|
|
|
/// <returns>True - могу менять, False - не могу менять</returns>
|
|
|
bool CheckAllFields()
|
|
|
{
|
|
|
- string functionName = new System.Diagnostics.StackTrace().GetFrame(1).GetMethod().Name;
|
|
|
+ string functionName = new StackTrace().GetFrame(1)?.GetMethod()?.Name ?? "Unknown";
|
|
|
|
|
|
switch (functionName)
|
|
|
{
|
|
@@ -115,7 +116,7 @@ namespace SocialEducatorAvalonia.ViewModels
|
|
|
|
|
|
void TakeCorrectData()
|
|
|
{
|
|
|
- string functionName = new System.Diagnostics.StackTrace().GetFrame(1).GetMethod().Name;
|
|
|
+ string functionName = new StackTrace().GetFrame(1)?.GetMethod()?.Name ?? "Unknown";
|
|
|
|
|
|
switch (functionName)
|
|
|
{
|
|
@@ -211,7 +212,7 @@ namespace SocialEducatorAvalonia.ViewModels
|
|
|
|
|
|
ObservableCollection<Student> students = new();
|
|
|
|
|
|
- if (DataEditorUtilities.ValueNullOrBlank(ref value))
|
|
|
+ if (!string.IsNullOrEmpty(value))
|
|
|
{
|
|
|
if (CheckAllFields())
|
|
|
students = new(DbContext.Students.FromSql($"select * from search_students_by_fio({value})").Include(x => x.StudentsAndPayments).ToList());
|
|
@@ -362,9 +363,9 @@ namespace SocialEducatorAvalonia.ViewModels
|
|
|
else // error
|
|
|
collection = new(StudentsList.Where(x => x.StudentsAndPayments.All(y => y.DataOfPayment.CompareTo(StartedDate) >= 0)).ToList());
|
|
|
}
|
|
|
- else
|
|
|
+ else if (SelectedEndDate.HasValue)
|
|
|
{
|
|
|
- DateOnly EndDate = DateOnly.FromDateTime((DateTime)SelectedEndDate);
|
|
|
+ DateOnly EndDate = SelectedEndDate.HasValue ? DateOnly.FromDateTime(SelectedEndDate.Value) : default;
|
|
|
|
|
|
if (CheckAllFields())
|
|
|
collection = new([.. DbContext.Students.FromSql($"select * from find_students_by_payment_end_date({EndDate})").Include(x => x.StudentsAndPayments)]);
|
|
@@ -387,9 +388,9 @@ namespace SocialEducatorAvalonia.ViewModels
|
|
|
/// <param name="value"></param>
|
|
|
partial void OnStudentsListChanged(ObservableCollection<Student> value)
|
|
|
{
|
|
|
- _studentsList = value;
|
|
|
+ StudentsList = value;
|
|
|
|
|
|
- var itemNotInList = _studentsList.FirstOrDefault(x => x.IsChecked == false);
|
|
|
+ var itemNotInList = StudentsList.FirstOrDefault(x => x.IsChecked == false);
|
|
|
|
|
|
if (itemNotInList is not null)
|
|
|
SelectedComboBox = false;
|
|
@@ -541,7 +542,7 @@ namespace SocialEducatorAvalonia.ViewModels
|
|
|
else
|
|
|
_personsToPayment.Add(student);
|
|
|
|
|
|
- var changeComboBox = _studentsList.FirstOrDefault(x => x.IsChecked == false);
|
|
|
+ var changeComboBox = StudentsList.FirstOrDefault(x => x.IsChecked == false);
|
|
|
|
|
|
if (changeComboBox is not null)
|
|
|
SelectedComboBox = false;
|