2023-05-19 17:14:57 +04:00
|
|
|
|
using SchoolAgainStudyBusinessLogic.OfficePackage;
|
|
|
|
|
using SchoolAgainStudyContracts.BusinessLogicContracts;
|
|
|
|
|
using SchoolAgainStudyContracts.SearchModel;
|
|
|
|
|
using SchoolAgainStudyContracts.StorageContracts;
|
|
|
|
|
using SchoolAgainStudyContracts.ViewModel;
|
2023-05-19 17:47:04 +04:00
|
|
|
|
using SchoolAgainStudyDataBaseImplements.Models;
|
|
|
|
|
using SchoolAgainStudyDataModels.Models;
|
2023-05-19 17:14:57 +04:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
|
|
namespace SchoolAgainStudyBusinessLogic.BusinessLogic
|
|
|
|
|
{
|
|
|
|
|
public class ChartLogic : IChartLogic
|
|
|
|
|
{
|
|
|
|
|
private readonly IInterestLogic _interest;
|
|
|
|
|
private readonly IProductLogic _product;
|
|
|
|
|
private readonly IDiyLogic _diy;
|
2023-05-19 17:47:04 +04:00
|
|
|
|
private readonly ILessonLogic _lesson;
|
|
|
|
|
private readonly IMaterialLogic _material;
|
|
|
|
|
private readonly ITaskLogic _task;
|
2023-05-19 18:30:49 +04:00
|
|
|
|
private readonly IStudentLogic _student;
|
2023-05-19 17:47:04 +04:00
|
|
|
|
|
2023-05-19 18:30:49 +04:00
|
|
|
|
public ChartLogic(IInterestLogic interest, IProductLogic product, IDiyLogic diy, ILessonLogic lesson, ITaskLogic task, IMaterialLogic mateial, IStudentLogic student)
|
2023-05-19 17:14:57 +04:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
_interest = interest;
|
|
|
|
|
_product = product;
|
|
|
|
|
_diy = diy;
|
2023-05-19 17:47:04 +04:00
|
|
|
|
_lesson = lesson;
|
|
|
|
|
_task = task;
|
|
|
|
|
_material = mateial;
|
2023-05-19 18:30:49 +04:00
|
|
|
|
_student = student;
|
2023-05-19 17:14:57 +04:00
|
|
|
|
}
|
|
|
|
|
public (int Products, int Diyes) GetDifferenceInCount(int StudentId)
|
|
|
|
|
{
|
|
|
|
|
var products = _product.ReadList(new ProductSearchModel
|
|
|
|
|
{
|
|
|
|
|
StudentId = StudentId,
|
|
|
|
|
DateFrom = DateTime.SpecifyKind(DateTime.Now.AddMonths(-1), DateTimeKind.Utc),
|
|
|
|
|
DateTo = DateTime.SpecifyKind(DateTime.Now, DateTimeKind.Utc),
|
|
|
|
|
});
|
|
|
|
|
var diyes = _diy.ReadList(new DiySearchModel
|
|
|
|
|
{
|
|
|
|
|
StudentId = StudentId,
|
|
|
|
|
DateFrom = DateTime.SpecifyKind(DateTime.Now.AddMonths(-1), DateTimeKind.Utc),
|
|
|
|
|
DateTo = DateTime.SpecifyKind(DateTime.Now, DateTimeKind.Utc),
|
|
|
|
|
});
|
|
|
|
|
return (products.Count, diyes.Count);
|
|
|
|
|
}
|
|
|
|
|
public List<ActivityChartViewModel> GetActivitys(int StudentId)
|
|
|
|
|
{
|
|
|
|
|
var products = _product.ReadList(new ProductSearchModel
|
|
|
|
|
{
|
|
|
|
|
StudentId = StudentId,
|
|
|
|
|
DateFrom = DateTime.SpecifyKind(DateTime.Now.AddMonths(-1), DateTimeKind.Utc),
|
|
|
|
|
DateTo = DateTime.SpecifyKind(DateTime.Now, DateTimeKind.Utc),
|
|
|
|
|
});
|
|
|
|
|
var diyes = _diy.ReadList(new DiySearchModel
|
|
|
|
|
{
|
|
|
|
|
StudentId = StudentId,
|
|
|
|
|
DateFrom = DateTime.SpecifyKind(DateTime.Now.AddMonths(-1), DateTimeKind.Utc),
|
|
|
|
|
DateTo = DateTime.SpecifyKind(DateTime.Now, DateTimeKind.Utc),
|
|
|
|
|
});
|
|
|
|
|
Dictionary<DateTime, int> list = new Dictionary<DateTime, int>();
|
|
|
|
|
for(DateTime date = DateTime.Now.AddMonths(-1); date<= DateTime.Now; date=date.AddDays(1))
|
|
|
|
|
{
|
|
|
|
|
list.Add(date, 0);
|
|
|
|
|
foreach(var product in products)
|
|
|
|
|
{
|
|
|
|
|
if (product.DateCreate.Date == date.Date)
|
|
|
|
|
list[date] += 1;
|
|
|
|
|
}
|
|
|
|
|
foreach (var diy in diyes)
|
|
|
|
|
{
|
|
|
|
|
if (diy.DateCreate.Date == date.Date)
|
|
|
|
|
list[date] += 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
var actList = list.Select(g => new ActivityChartViewModel { dateOf = g.Key.ToString("dd/MM"), count = g.Value }).ToList();
|
|
|
|
|
return actList;
|
|
|
|
|
}
|
2023-05-19 17:47:04 +04:00
|
|
|
|
|
|
|
|
|
public List<TopersViewModel> GetTopMaterials(int TeacherId)
|
|
|
|
|
{
|
|
|
|
|
var materials = _material.ReadList(new MaterialSearchModel
|
|
|
|
|
{
|
|
|
|
|
TeacherId = TeacherId,
|
|
|
|
|
});
|
|
|
|
|
var lessons = _lesson.ReadList(new LessonSearchModel
|
|
|
|
|
{
|
|
|
|
|
TeacherId = TeacherId,
|
|
|
|
|
DateFrom = DateTime.SpecifyKind(DateTime.Now.AddMonths(-1), DateTimeKind.Utc),
|
|
|
|
|
DateTo = DateTime.SpecifyKind(DateTime.Now, DateTimeKind.Utc),
|
|
|
|
|
});
|
|
|
|
|
var tasks = _task.ReadList(new TaskSearchModel
|
|
|
|
|
{
|
|
|
|
|
TeacherId = TeacherId,
|
|
|
|
|
DateFrom = DateTime.SpecifyKind(DateTime.Now.AddMonths(-1), DateTimeKind.Utc),
|
|
|
|
|
DateTo = DateTime.SpecifyKind(DateTime.Now, DateTimeKind.Utc),
|
|
|
|
|
});
|
|
|
|
|
Dictionary<IMaterial, int> list = new Dictionary<IMaterial, int>();
|
|
|
|
|
foreach (var material in materials)
|
|
|
|
|
{
|
|
|
|
|
list.Add(material, 0);
|
|
|
|
|
foreach (var lesson in lessons)
|
|
|
|
|
{
|
|
|
|
|
if (lesson.LessonMaterials.ContainsKey(material.Id))
|
|
|
|
|
list[material] += 1;
|
|
|
|
|
}
|
|
|
|
|
foreach (var task in tasks)
|
|
|
|
|
{
|
|
|
|
|
if (task.TaskMaterials.ContainsKey(material.Id))
|
|
|
|
|
list[material] += 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
var actList = list.Select(g => new TopersViewModel { Name = g.Key.Title, Count = g.Value }).ToList();
|
|
|
|
|
return actList;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public List<TopersViewModel> GetTopStudents(int TeacherId)
|
|
|
|
|
{
|
2023-05-19 18:30:49 +04:00
|
|
|
|
var lessons = _lesson.ReadList(new LessonSearchModel
|
|
|
|
|
{
|
|
|
|
|
TeacherId = TeacherId
|
|
|
|
|
});
|
|
|
|
|
var tasks = _task.ReadList(new TaskSearchModel
|
|
|
|
|
{
|
|
|
|
|
TeacherId = TeacherId,
|
|
|
|
|
});
|
|
|
|
|
var diys = _diy.ReadList(null);
|
|
|
|
|
Dictionary<int, int> list = new Dictionary<int, int>();
|
|
|
|
|
foreach(var lesson in lessons)
|
|
|
|
|
{
|
|
|
|
|
var product = _product.ReadElement(new ProductSearchModel
|
|
|
|
|
{
|
|
|
|
|
Id = lesson.ProductId
|
|
|
|
|
});
|
|
|
|
|
if (list.ContainsKey(product.StudentId))
|
|
|
|
|
list[product.StudentId] += 1;
|
|
|
|
|
else list.Add(product.StudentId, 1);
|
|
|
|
|
}
|
|
|
|
|
foreach (var task in tasks)
|
|
|
|
|
{
|
|
|
|
|
foreach(var diy in diys)
|
|
|
|
|
{
|
|
|
|
|
if(diy.TaskId == task.Id)
|
|
|
|
|
{
|
|
|
|
|
if (list.ContainsKey(diy.StudentId))
|
|
|
|
|
list[diy.StudentId] += 1;
|
|
|
|
|
else list.Add(diy.StudentId, 1);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
var actList = list.Select(g => new TopersViewModel { Name = _student.ReadElement(new StudentSearchModel { Id = g.Key }).Name, Count = g.Value }).ToList();
|
|
|
|
|
return actList;
|
2023-05-19 17:47:04 +04:00
|
|
|
|
}
|
|
|
|
|
}
|
2023-05-19 17:14:57 +04:00
|
|
|
|
}
|