Небольшие правки для логики отчетов

This commit is contained in:
Володя 2023-04-07 19:23:14 +03:00
parent 295c3f153b
commit ed83f62c01
5 changed files with 42 additions and 61 deletions

View File

@ -1,10 +1,12 @@
using SchoolAgainStudyBusinessLogic.OfficePackage;
using DocumentFormat.OpenXml.Office2021.DocumentTasks;
using SchoolAgainStudyBusinessLogic.OfficePackage;
using SchoolAgainStudyBusinessLogic.OfficePackage.HelperModels;
using SchoolAgainStudyContracts.BindingModel;
using SchoolAgainStudyContracts.BusinessLogicContracts;
using SchoolAgainStudyContracts.SearchModel;
using SchoolAgainStudyContracts.StorageContracts;
using SchoolAgainStudyContracts.ViewModel;
using SchoolAgainStudyDataBaseImplements.Models;
using SchoolAgainStudyDataModels.Models;
using System;
using System.Collections.Generic;
@ -137,51 +139,38 @@ namespace SchoolAgainStudyBusinessLogic.BusinessLogic
DateTo = model.DateTo
});
var list = new List<ReportInterestViewModel>();
foreach(InterestViewModel interest in interests)
{
foreach(ProductViewModel product in products)
{
if (product.ProductInterests.ContainsKey(interest.Id))
{
list.Add(new ReportInterestViewModel
{
InterestTitle=interest.Title,
InterestDesc = interest.Description,
WorkType = "Изделие",
WorkTitle = product.Title,
WorkDesc = product.Description,
DateCreate = product.DateCreate
});
}
}
}
foreach (InterestViewModel interest in interests)
foreach (ProductViewModel product in products)
{
foreach (DiyViewModel diy in diys)
{
if (diy.DiyInterests.ContainsKey(interest.Id))
foreach (int interestProduct in product.ProductInterests.Keys)
{
list.Add(new ReportInterestViewModel
if (diy.DiyInterests.ContainsKey(interestProduct))
{
InterestTitle = interest.Title,
InterestDesc = interest.Description,
WorkType = "Поделка",
WorkTitle = diy.Title,
WorkDesc = diy.Description,
DateCreate=diy.DateCreate
});
list.Add(new ReportInterestViewModel
{
InterestTitle = interests.FirstOrDefault(x => x.Id == interestProduct).ToString(),
ProductTitle = product.Title,
DateCreateProduct = product.DateCreate,
DiyTitle = diy.Title,
DateCreateDiy = diy.DateCreate
});
}
}
}
}
return list;
}
public List<ReportLessonTaskViewModel> GetLessonTask(ReportBindingModel model)
{
var materials = _materialStorage.GetFilteredList(new MaterialSearchModel
{
TeacherId = model.TeacherId
});
var tasks = _taskStorage.GetFilteredList(new TaskSearchModel
{
TeacherId = model.TeacherId,
@ -201,28 +190,21 @@ namespace SchoolAgainStudyBusinessLogic.BusinessLogic
foreach(LessonViewModel lesson in lessons)
{
bool check = false;
foreach (int materialTask in task.TaskMaterials.Keys)
{
if (check)
if (lesson.LessonMaterials.ContainsKey(materialTask))
{
list.Add(new ReportLessonTaskViewModel
{
TitleLesson = lesson.Title,
TitleTask = task.Title,
DateEventLesson = lesson.DateEvent,
DateIssueTask = task.DateIssue
});
break;
}
foreach (int materialLesson in lesson.LessonMaterials.Keys)
{
if (materialLesson == materialTask)
{
list.Add(new ReportLessonTaskViewModel
{
TitleLesson = lesson.Title,
TitleTask = task.Title,
DateEventLesson = lesson.DateEvent,
DateIssueTask = task.DateIssue
});
check=true;
break;
}
}
}
}

View File

@ -20,7 +20,7 @@ namespace SchoolAgainStudyBusinessLogic.OfficePackage
CreateRow(new PdfRowParameters
{
Texts = new List<string> { "Номер","Интерес", "Описание интереса", "Тип","Название", "Описание", "Дата" },
Texts = new List<string> {"Интерес", "Изделие", "Дата","Поделка", "Дата" },
Style = "NormalTitle",
ParagraphAlignment = PdfParagraphAlignmentType.Center
});
@ -29,7 +29,7 @@ namespace SchoolAgainStudyBusinessLogic.OfficePackage
{
CreateRow(new PdfRowParameters
{
Texts = new List<string> { interest.Id.ToString(),interest.InterestTitle,interest.InterestDesc,interest.WorkType,interest.WorkTitle,interest.WorkDesc, interest.DateCreate.ToShortDateString() },
Texts = new List<string> { interest.InterestTitle,interest.ProductTitle,interest.DateCreateProduct.ToShortDateString(), interest.DiyTitle, interest.DateCreateDiy.ToShortDateString() },
Style = "Normal",
ParagraphAlignment = PdfParagraphAlignmentType.Left
});

View File

@ -20,7 +20,7 @@ namespace SchoolAgainStudyBusinessLogic.OfficePackage
CreateRow(new PdfRowParameters
{
Texts = new List<string> { "Номер","Занятие", "Дата занятия", "Задание", "Дата выдачи задания" },
Texts = new List<string> { "Занятие", "Дата занятия", "Задание", "Дата выдачи задания" },
Style = "NormalTitle",
ParagraphAlignment = PdfParagraphAlignmentType.Center
});
@ -29,7 +29,7 @@ namespace SchoolAgainStudyBusinessLogic.OfficePackage
{
CreateRow(new PdfRowParameters
{
Texts = new List<string> { taskLesson.Id.ToString(), taskLesson.TitleLesson, taskLesson.DateEventLesson.ToShortDateString(), taskLesson.TitleTask, taskLesson.DateIssueTask.ToShortDateString()},
Texts = new List<string> { taskLesson.TitleLesson, taskLesson.DateEventLesson.ToShortDateString(), taskLesson.TitleTask, taskLesson.DateIssueTask.ToShortDateString()},
Style = "Normal",
ParagraphAlignment = PdfParagraphAlignmentType.Left
});

View File

@ -8,12 +8,11 @@ namespace SchoolAgainStudyContracts.ViewModel
{
public class ReportInterestViewModel
{
public int Id { get; set; }
public string InterestTitle { get; set; } = string.Empty;
public string InterestDesc { get; set; } = string.Empty;
public string WorkType { get; set; } = string.Empty;
public string WorkTitle { get; set; } = string.Empty;
public string WorkDesc { get; set; } = string.Empty;
public DateTime DateCreate { get; set; }
public string ProductTitle { get; set; } = string.Empty;
public DateTime DateCreateProduct { get; set; }
public string DiyTitle { get; set; } = string.Empty;
public DateTime DateCreateDiy{ get; set; }
}
}

View File

@ -8,7 +8,7 @@ namespace SchoolAgainStudyContracts.ViewModel
{
public class ReportLessonTaskViewModel
{
public int Id { get; set; }
public string TitleLesson { get; set; } = string.Empty;
public DateTime DateEventLesson { get; set; }
public string TitleTask { get; set; } = string.Empty;