вывод данных во view-модель с использованием методов
This commit is contained in:
parent
48ad010501
commit
c4402d976d
@ -4,6 +4,7 @@ using System;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
using System.ComponentModel.DataAnnotations.Schema;
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
using System.Linq;
|
||||||
using System.Runtime.Serialization;
|
using System.Runtime.Serialization;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
@ -59,5 +60,12 @@ namespace DatabaseCore.Models.Department
|
|||||||
public StudentGroup SecurityCheck(StudentGroup entity, bool allowFullData) => entity;
|
public StudentGroup SecurityCheck(StudentGroup entity, bool allowFullData) => entity;
|
||||||
|
|
||||||
public override string ToString() => $"{EducationDirection?.ShortName}-{AcademicCourse}{GroupNumber}";
|
public override string ToString() => $"{EducationDirection?.ShortName}-{AcademicCourse}{GroupNumber}";
|
||||||
|
|
||||||
|
//-------------------------------------------------------------------------
|
||||||
|
|
||||||
|
public int GetStudnetsByState(int state)
|
||||||
|
{
|
||||||
|
return Students?.Where(x => x.StudentState == state)?.Count() ?? 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,4 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace ModuleTools.Attributes
|
namespace ModuleTools.Attributes
|
||||||
{
|
{
|
||||||
@ -26,6 +27,8 @@ namespace ModuleTools.Attributes
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public bool AllowCopyWithoutRigth { get; set; } = true;
|
public bool AllowCopyWithoutRigth { get; set; } = true;
|
||||||
|
|
||||||
|
public Type[] MethodParams { get; set; } = null;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Настройка для полей сущности правил маппинга
|
/// Настройка для полей сущности правил маппинга
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -75,6 +75,39 @@ namespace ModuleTools.BusinessLogics
|
|||||||
value = (value as ICollection)?.Count;
|
value = (value as ICollection)?.Count;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
else if (prop == "Method")
|
||||||
|
{
|
||||||
|
int index = 0;
|
||||||
|
while (true)
|
||||||
|
{
|
||||||
|
if (props[index++] == "Method")
|
||||||
|
break;
|
||||||
|
if (index == props.Length)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
var methodName = props[index].Split('[')?[0];
|
||||||
|
if (string.IsNullOrEmpty(methodName))
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
var parameters = props[index].Split(new char[] { '[' , ']'}, StringSplitOptions.RemoveEmptyEntries)?[1].Split(',');
|
||||||
|
var objs = new object[parameters.Length];
|
||||||
|
for(int i = 0; i < parameters.Length; ++i)
|
||||||
|
{
|
||||||
|
var type = parameters[i].Split(':')[0];
|
||||||
|
switch(type)
|
||||||
|
{
|
||||||
|
case "Enum":
|
||||||
|
objs[i] = (int)Enum.Parse(customAttribute.MethodParams[i], parameters[i].Split(':')[1]);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
value = typeFrom.InvokeMember(methodName, BindingFlags.InvokeMethod | BindingFlags.Public | BindingFlags.Instance, null, value, objs);
|
||||||
|
break;
|
||||||
|
|
||||||
|
}
|
||||||
var bindingProperty = value.GetType().GetProperty(prop);
|
var bindingProperty = value.GetType().GetProperty(prop);
|
||||||
if (bindingProperty != null)
|
if (bindingProperty != null)
|
||||||
{
|
{
|
||||||
|
@ -3,6 +3,7 @@ using ModuleTools.Attributes;
|
|||||||
using ModuleTools.Enums;
|
using ModuleTools.Enums;
|
||||||
using ModuleTools.ViewModels;
|
using ModuleTools.ViewModels;
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace DepartmentBusinessLogic.ViewModels
|
namespace DepartmentBusinessLogic.ViewModels
|
||||||
{
|
{
|
||||||
@ -49,9 +50,14 @@ namespace DepartmentBusinessLogic.ViewModels
|
|||||||
[MapConfiguration("GroupNumber")]
|
[MapConfiguration("GroupNumber")]
|
||||||
public int GroupNumber { get; set; }
|
public int GroupNumber { get; set; }
|
||||||
|
|
||||||
|
[MapConfiguration("Method.GetStudnetsByState[Enum:Учится]", IsDifficle = true, MethodParams = new Type[] { typeof(StudentState) })]
|
||||||
|
public int StudentActualCount { get; set; }
|
||||||
|
|
||||||
|
[MapConfiguration("Method.GetStudnetsByState[Enum:Академ]", IsDifficle = true, MethodParams = new Type[] { typeof(StudentState) })]
|
||||||
|
public int StudentAcademCount { get; set; }
|
||||||
|
|
||||||
[ViewModelControlListProperty("Количество студентов")]
|
[ViewModelControlListProperty("Количество студентов")]
|
||||||
[MapConfiguration("Students.Count", IsDifficle = true)]
|
public string StudentCount => $"{StudentActualCount + StudentAcademCount} ({StudentActualCount}, {StudentAcademCount})";
|
||||||
public int StudentCount { get; set; }
|
|
||||||
|
|
||||||
[ViewModelControlElementProperty("Куратор", ControlType.ControlGuid, MustHaveValue = false, ReadOnly = false, ControlTypeObject = "DepartmentWindowsDesktop.EntityControls.ControlLecturerList, DepartmentWindowsDesktop")]
|
[ViewModelControlElementProperty("Куратор", ControlType.ControlGuid, MustHaveValue = false, ReadOnly = false, ControlTypeObject = "DepartmentWindowsDesktop.EntityControls.ControlLecturerList, DepartmentWindowsDesktop")]
|
||||||
[MapConfiguration("LecturerId")]
|
[MapConfiguration("LecturerId")]
|
||||||
|
Loading…
Reference in New Issue
Block a user