52 lines
1.6 KiB
C#
52 lines
1.6 KiB
C#
using Controller.Repository;
|
|
using Controller.ViewModels;
|
|
using DataModels.Models;
|
|
|
|
namespace Controller.BusinessLogic
|
|
{
|
|
public class GroupLogic
|
|
{
|
|
private readonly SpecializationRepository _specializationRepository;
|
|
private readonly GroupRepository _groupRepository;
|
|
public GroupLogic(SpecializationRepository rep, GroupRepository groupRepository)
|
|
{
|
|
_specializationRepository = rep;
|
|
_groupRepository = groupRepository;
|
|
}
|
|
|
|
public async Task<List<GroupViewModel>> GetViewModel()
|
|
{
|
|
var groups = await _groupRepository.GetAll();
|
|
var results = new List<GroupViewModel>();
|
|
|
|
foreach (var group in groups)
|
|
{
|
|
|
|
var spec = group.SpecializationId.HasValue
|
|
? await _specializationRepository.Get(group.SpecializationId.Value) : null;
|
|
|
|
Console.WriteLine(group.SpecializationId);
|
|
|
|
results.Add(new GroupViewModel(group, spec));
|
|
}
|
|
return results;
|
|
|
|
//var specs = new List<Specialization>
|
|
//{
|
|
// new Specialization{Id = 1, Code = "1234", Name = "Программная инженерия"},
|
|
// new Specialization{Id = 2, Code = "5678", Name = "Информатика"},
|
|
|
|
//};
|
|
|
|
//var groups = new List<Group>
|
|
//{
|
|
// new Group{Id = 1, Course = 3, Name = "ПИ", Number = 1, CountStudents = 29, SpecializationId = 1},
|
|
// new Group{Id = 2, Course = 3, Name = "ПМ", Number = 4, CountStudents = 24, SpecializationId = 2},
|
|
|
|
//};
|
|
|
|
|
|
}
|
|
}
|
|
}
|