From 15bcd7eb8a7a6c92002825c045a1124453482903 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D0=BB=D1=8C=D1=84=D0=B8=D1=8F=20=D0=A2=D1=83=D0=BA?= =?UTF-8?q?=D0=B0=D0=B5=D0=B2=D0=B0?= Date: Fri, 7 Apr 2023 22:28:12 +0300 Subject: [PATCH] =?UTF-8?q?=D0=B3=D0=BE=D1=82=D0=BE=D0=B2=D0=B0=D1=8F=20?= =?UTF-8?q?=D0=B1=D0=B8=D0=B7=D0=BD=D0=B5=D1=81=20=D0=BB=D0=BE=D0=B3=D0=B8?= =?UTF-8?q?=D0=BA=D0=B0,=20=D0=BE=D1=81=D1=82=D0=B0=D0=BB=D0=BE=D1=81?= =?UTF-8?q?=D1=8C=20=D0=B4=D0=BE=D0=B4=D0=B5=D0=BB=D0=B0=D1=82=D1=8C=20?= =?UTF-8?q?=D0=BE=D1=82=D1=87=D0=B5=D1=82=D1=8B=20=D0=B8=20=D0=B8=D1=85=20?= =?UTF-8?q?=D0=BB=D0=BE=D0=B3=D0=B8=D0=BA=D1=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BusinessLogics/CircleExpenseLogic.cs | 103 ++++++++++++++++++ .../BusinessLogics/CircleLessonLogic.cs | 103 ++++++++++++++++++ .../BusinessLogics/ExpenseLogic.cs | 102 +++++++++++++++++ .../BusinessLogics/PaymentLogic.cs | 56 ++++++++++ .../BusinessLogics/ReportLessonsLogic.cs | 13 +++ .../BusinessLogics/ReportLogic.cs | 42 ++++++- .../SchoolBusinessLogic.csproj | 9 ++ .../CircleExpenseBindingModel.cs | 18 +++ .../BindingModels/CircleLessonBindingModel.cs | 18 +++ .../BindingModels/ExpenseBindingModel.cs | 1 + .../BindingModels/PaymentBindingModel.cs | 5 +- .../BindingModels/ReportBindingModel.cs | 11 +- .../ICircleExpenseLogic.cs | 21 ++++ .../ICircleLessonLogic.cs | 21 ++++ .../BusinessLogicsContracts/IExpenseLogic.cs | 20 ++++ .../BusinessLogicsContracts/IPaymentLogic.cs | 6 +- .../IReportLessonsLogic.cs | 17 +++ .../BusinessLogicsContracts/IReportLogic.cs | 35 ++++-- .../SearchModel/CircleExpenseSearchModel.cs | 13 +++ .../SearchModel/CircleLessonSearchModel.cs | 13 +++ .../SearchModel/CircleSearchModel.cs | 4 + .../SearchModel/ExpenseSearchModel.cs | 3 + .../SearchModel/PaymentSearchModel.cs | 4 +- .../ICircleExpenseStorage.cs | 22 ++++ .../StoragesContracts/ICircleLessonStorage.cs | 22 ++++ .../StoragesContracts/ICircleStorage.cs | 3 +- .../ViewModels/CircleExpenseViewModel.cs | 19 ++++ .../ViewModels/CircleLessonViewModel.cs | 19 ++++ .../ViewModels/ExpenseViewModel.cs | 1 + .../ViewModels/PaymentViewModel.cs | 5 +- .../ViewModels/ReportCircleLessonViewModel.cs | 16 --- .../ReportCircleLessonsViewModel.cs | 23 ++++ .../ViewModels/ReportCircleViewModel.cs | 17 --- .../ViewModels/ReportExpensesViewModel.cs | 18 +++ .../ViewModels/ReportLessonCircleViewModel.cs | 16 --- .../ReportLessonCirclesViewModel.cs | 23 ++++ .../ViewModels/ReportViewModel.cs | 17 +-- .../ViewModels/ReportViewerLessonModel.cs | 15 --- .../Models/ICircleExpenseModel.cs | 23 ++++ .../Models/ICircleLessonModel.cs | 23 ++++ .../SchoolDataModels/Models/IExpenseModel.cs | 4 + .../SchoolDataModels/Models/IPaymentModel.cs | 10 +- .../Implements/CircleExpenseStorage.cs | 94 ++++++++++++++++ .../Implements/CircleLessonStorage.cs | 94 ++++++++++++++++ .../Implements/CircleStorage.cs | 33 +++++- .../Implements/ExpenseStorage.cs | 59 ++++++++-- .../Implements/LessonStorage.cs | 2 +- .../Implements/PaymentStorage.cs | 26 ++--- .../SchoolDatabaseImplements/Models/Circle.cs | 2 +- .../Models/CircleExpense.cs | 25 +++++ .../Models/CircleLesson.cs | 26 ++++- .../Models/Employee.cs | 3 +- .../Models/Expense.cs | 35 +++++- .../Models/Payment.cs | 23 ++-- 54 files changed, 1210 insertions(+), 146 deletions(-) create mode 100644 School/SchoolBusinessLogic/BusinessLogics/CircleExpenseLogic.cs create mode 100644 School/SchoolBusinessLogic/BusinessLogics/CircleLessonLogic.cs create mode 100644 School/SchoolBusinessLogic/BusinessLogics/ExpenseLogic.cs create mode 100644 School/SchoolBusinessLogic/BusinessLogics/PaymentLogic.cs create mode 100644 School/SchoolBusinessLogic/BusinessLogics/ReportLessonsLogic.cs create mode 100644 School/SchoolContracts/BindingModels/CircleExpenseBindingModel.cs create mode 100644 School/SchoolContracts/BindingModels/CircleLessonBindingModel.cs create mode 100644 School/SchoolContracts/BusinessLogicsContracts/ICircleExpenseLogic.cs create mode 100644 School/SchoolContracts/BusinessLogicsContracts/ICircleLessonLogic.cs create mode 100644 School/SchoolContracts/BusinessLogicsContracts/IExpenseLogic.cs create mode 100644 School/SchoolContracts/BusinessLogicsContracts/IReportLessonsLogic.cs create mode 100644 School/SchoolContracts/SearchModel/CircleExpenseSearchModel.cs create mode 100644 School/SchoolContracts/SearchModel/CircleLessonSearchModel.cs create mode 100644 School/SchoolContracts/StoragesContracts/ICircleExpenseStorage.cs create mode 100644 School/SchoolContracts/StoragesContracts/ICircleLessonStorage.cs create mode 100644 School/SchoolContracts/ViewModels/CircleExpenseViewModel.cs create mode 100644 School/SchoolContracts/ViewModels/CircleLessonViewModel.cs delete mode 100644 School/SchoolContracts/ViewModels/ReportCircleLessonViewModel.cs create mode 100644 School/SchoolContracts/ViewModels/ReportCircleLessonsViewModel.cs delete mode 100644 School/SchoolContracts/ViewModels/ReportCircleViewModel.cs create mode 100644 School/SchoolContracts/ViewModels/ReportExpensesViewModel.cs delete mode 100644 School/SchoolContracts/ViewModels/ReportLessonCircleViewModel.cs create mode 100644 School/SchoolContracts/ViewModels/ReportLessonCirclesViewModel.cs delete mode 100644 School/SchoolContracts/ViewModels/ReportViewerLessonModel.cs create mode 100644 School/SchoolDataModels/Models/ICircleExpenseModel.cs create mode 100644 School/SchoolDataModels/Models/ICircleLessonModel.cs create mode 100644 School/SchoolDatabaseImplements/Implements/CircleExpenseStorage.cs create mode 100644 School/SchoolDatabaseImplements/Implements/CircleLessonStorage.cs diff --git a/School/SchoolBusinessLogic/BusinessLogics/CircleExpenseLogic.cs b/School/SchoolBusinessLogic/BusinessLogics/CircleExpenseLogic.cs new file mode 100644 index 0000000..c1770e5 --- /dev/null +++ b/School/SchoolBusinessLogic/BusinessLogics/CircleExpenseLogic.cs @@ -0,0 +1,103 @@ +using Microsoft.Extensions.Logging; +using SchoolContracts.BindingModels; +using SchoolContracts.BusinessLogicsContracts; +using SchoolContracts.SearchModel; +using SchoolContracts.StoragesContracts; +using SchoolContracts.ViewModels; +using SchoolDatabaseImplement.Implements; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SchoolBusinessLogic.BusinessLogics +{ + public class CircleExpenseLogic : ICircleExpenseLogic + { + private readonly ILogger _logger; + private readonly ICircleExpenseStorage _circleExpenseStorage; + public CircleExpenseLogic(ILogger logger, ICircleExpenseStorage circleExpenseStorage) + { + _logger= logger; + _circleExpenseStorage= circleExpenseStorage; + } + + public bool Create(CircleExpenseBindingModel model) + { + CheckModel(model); + if (_circleExpenseStorage.Insert(model) == null) + { + _logger.LogWarning("Insert operation failed"); + return false; + } + return true; + } + + public bool Delete(CircleExpenseBindingModel model) + { + CheckModel(model, false); + _logger.LogInformation("Delete. Id: {Id}", model.Id); + if (_circleExpenseStorage.Delete(model) == null) + { + _logger.LogWarning("Delete operation failed"); + return false; + } + return true; + } + + public CircleExpenseViewModel? ReadElement(CircleExpenseSearchModel model) + { + if (model == null) + { + throw new ArgumentNullException(nameof(model)); + } + _logger.LogInformation("ReadElement. Id: {Id}", model.Id); + var element = _circleExpenseStorage.GetElement(model); + if (element == null) + { + _logger.LogWarning("ReadElement element not found"); + return null; + } + _logger.LogInformation("ReadElement found. Id: {Id}", element.Id); + return element; + } + + public List? ReadList(CircleExpenseSearchModel? model) + { + _logger.LogInformation("ReadList. Id: {Id}", model?.Id); + var list = model == null ? _circleExpenseStorage.GetFullList() : _circleExpenseStorage.GetFilteredList(model); + if (list == null) + { + _logger.LogWarning("ReadList return null list"); + return null; + } + _logger.LogInformation("ReadList. Count: {Count}", list.Count); + return list; + } + + public bool Update(CircleExpenseBindingModel model) + { + CheckModel(model); + if (_circleExpenseStorage.Update(model) == null) + { + _logger.LogWarning("Update operation failed"); + return false; + } + return true; + } + + private void CheckModel(CircleExpenseBindingModel model, bool withParams = true) + { + if (model == null) + { + throw new ArgumentException(nameof(model)); + } + if (!withParams) + { + return; + } + _logger.LogInformation("CircleExpense. Id: {Id}", model.Id); + } + } +} diff --git a/School/SchoolBusinessLogic/BusinessLogics/CircleLessonLogic.cs b/School/SchoolBusinessLogic/BusinessLogics/CircleLessonLogic.cs new file mode 100644 index 0000000..d6e1468 --- /dev/null +++ b/School/SchoolBusinessLogic/BusinessLogics/CircleLessonLogic.cs @@ -0,0 +1,103 @@ +using Microsoft.Extensions.Logging; +using SchoolContracts.BindingModels; +using SchoolContracts.BusinessLogicsContracts; +using SchoolContracts.SearchModel; +using SchoolContracts.StoragesContracts; +using SchoolContracts.ViewModels; +using SchoolDatabaseImplement.Implements; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SchoolBusinessLogic.BusinessLogics +{ + public class CircleLessonLogic : ICircleLessonLogic + { + private readonly ILogger _logger; + private readonly ICircleLessonStorage _circleLessonStorage; + public CircleLessonLogic(ILogger logger, ICircleLessonStorage circleLessonStorage) + { + _logger= logger; + _circleLessonStorage= circleLessonStorage; + } + + public bool Create(CircleLessonBindingModel model) + { + CheckModel(model); + if (_circleLessonStorage.Insert(model) == null) + { + _logger.LogWarning("Insert operation failed"); + return false; + } + return true; + } + + public bool Delete(CircleLessonBindingModel model) + { + CheckModel(model, false); + _logger.LogInformation("Delete. Id: {Id}", model.Id); + if (_circleLessonStorage.Delete(model) == null) + { + _logger.LogWarning("Delete operation failed"); + return false; + } + return true; + } + + public CircleLessonViewModel? ReadElement(CircleLessonSearchModel model) + { + if (model == null) + { + throw new ArgumentNullException(nameof(model)); + } + _logger.LogInformation("ReadElement. Id: {Id}", model.Id); + var element = _circleLessonStorage.GetElement(model); + if (element == null) + { + _logger.LogWarning("ReadElement element not found"); + return null; + } + _logger.LogInformation("ReadElement found. Id: {Id}", element.Id); + return element; + } + + public List? ReadList(CircleLessonSearchModel? model) + { + _logger.LogInformation("ReadList. Id: {Id}", model?.Id); + var list = model == null ? _circleLessonStorage.GetFullList() : _circleLessonStorage.GetFilteredList(model); + if (list == null) + { + _logger.LogWarning("ReadList return null list"); + return null; + } + _logger.LogInformation("ReadList. Count: {Count}", list.Count); + return list; + } + + public bool Update(CircleLessonBindingModel model) + { + CheckModel(model); + if (_circleLessonStorage.Update(model) == null) + { + _logger.LogWarning("Update operation failed"); + return false; + } + return true; + } + + private void CheckModel(CircleLessonBindingModel model, bool withParams = true) + { + if (model == null) + { + throw new ArgumentException(nameof(model)); + } + if (!withParams) + { + return; + } + _logger.LogInformation("CircleLesson. Id: {Id}", model.Id); + } + } +} diff --git a/School/SchoolBusinessLogic/BusinessLogics/ExpenseLogic.cs b/School/SchoolBusinessLogic/BusinessLogics/ExpenseLogic.cs new file mode 100644 index 0000000..4075e2d --- /dev/null +++ b/School/SchoolBusinessLogic/BusinessLogics/ExpenseLogic.cs @@ -0,0 +1,102 @@ +using Microsoft.Extensions.Logging; +using SchoolContracts.BindingModels; +using SchoolContracts.BusinessLogicsContracts; +using SchoolContracts.SearchModel; +using SchoolContracts.StoragesContracts; +using SchoolContracts.ViewModels; +using SchoolDatabaseImplements.Implements; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SchoolBusinessLogic.BusinessLogics +{ + public class ExpenseLogic : IExpenseLogic + { + private readonly ILogger _logger; + private readonly IExpenseStorage _expenseStorage; + public ExpenseLogic(ILogger logger, IExpenseStorage expenseStorage) + { + _logger = logger; + _expenseStorage = expenseStorage; + } + + public bool Create(ExpenseBindingModel model) + { + CheckModel(model); + if (_expenseStorage.Insert(model) == null) + { + _logger.LogWarning("Insert operation failed"); + return false; + } + return true; + } + + public bool Delete(ExpenseBindingModel model) + { + CheckModel(model, false); + _logger.LogInformation("Delete. Id: {Id}", model.Id); + if (_expenseStorage.Delete(model) == null) + { + _logger.LogWarning("Delete operation failed"); + return false; + } + return true; + } + + public ExpenseViewModel? ReadElement(ExpenseSearchModel model) + { + if (model == null) + { + throw new ArgumentNullException(nameof(model)); + } + _logger.LogInformation("ReadElement. Id: {Id}", model.Id); + var element = _expenseStorage.GetElement(model); + if (element == null) + { + _logger.LogWarning("ReadElement element not found"); + return null; + } + _logger.LogInformation("ReadElement found. Id: {Id}", element.Id); + return element; + } + + public List? ReadList(ExpenseSearchModel? model) + { + _logger.LogInformation("ReadList. Id: {Id}", model?.Id); + var list = model == null ? _expenseStorage.GetFullList() : _expenseStorage.GetFilteredList(model); + if (list == null) + { + _logger.LogWarning("ReadList return null list"); + return null; + } + _logger.LogInformation("ReadList. Count: {Count}", list.Count); + return list; + } + + public bool Update(ExpenseBindingModel model) + { + CheckModel(model); + if (_expenseStorage.Update(model) == null) + { + _logger.LogWarning("Update operation failed"); + return false; + } + return true; + } + private void CheckModel(ExpenseBindingModel model, bool withParams = true) + { + if (model == null) + { + throw new ArgumentException(nameof(model)); + } + if (!withParams) + { + return; + } + _logger.LogInformation("Expense. Id: {Id}", model.Id); + } + } +} diff --git a/School/SchoolBusinessLogic/BusinessLogics/PaymentLogic.cs b/School/SchoolBusinessLogic/BusinessLogics/PaymentLogic.cs new file mode 100644 index 0000000..374a005 --- /dev/null +++ b/School/SchoolBusinessLogic/BusinessLogics/PaymentLogic.cs @@ -0,0 +1,56 @@ +using Microsoft.Extensions.Logging; +using SchoolContracts.BindingModel; +using SchoolContracts.BusinessLogicsContracts; +using SchoolContracts.SearchModel; +using SchoolContracts.StoragesContracts; +using SchoolContracts.ViewModels; + +namespace SchoolBusinessLogic.BusinessLogics +{ + public class PaymentLogic : IPaymentLogic + { + private readonly ILogger _logger; + private readonly IPaymentStorage _paymentStorage; + public PaymentLogic(ILogger logger, IPaymentStorage paymentStorage) + { + _logger = logger; + _paymentStorage = paymentStorage; + } + public bool Create(PaymentBindingModel model) + { + throw new NotImplementedException(); + } + + public bool Delete(PaymentBindingModel model) + { + throw new NotImplementedException(); + } + + public PaymentViewModel? ReadElement(PaymentSearchModel model) + { + throw new NotImplementedException(); + } + + public List? ReadList(PaymentSearchModel? model) + { + throw new NotImplementedException(); + } + + public bool Update(PaymentBindingModel model) + { + throw new NotImplementedException(); + } + private void CheckModel(LessonBindingModel model, bool withParams = true) + { + if (model == null) + { + throw new ArgumentNullException(nameof(model)); + } + if (!withParams) + { + return; + } + _logger.LogInformation("Lesson. Id: {Id}", model.Id); + } + } +} diff --git a/School/SchoolBusinessLogic/BusinessLogics/ReportLessonsLogic.cs b/School/SchoolBusinessLogic/BusinessLogics/ReportLessonsLogic.cs new file mode 100644 index 0000000..2672ecb --- /dev/null +++ b/School/SchoolBusinessLogic/BusinessLogics/ReportLessonsLogic.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SchoolBusinessLogic.BusinessLogics +{ + public class ReportLessonsLogic + { + + } +} diff --git a/School/SchoolBusinessLogic/BusinessLogics/ReportLogic.cs b/School/SchoolBusinessLogic/BusinessLogics/ReportLogic.cs index 5ef72cb..d37f3a8 100644 --- a/School/SchoolBusinessLogic/BusinessLogics/ReportLogic.cs +++ b/School/SchoolBusinessLogic/BusinessLogics/ReportLogic.cs @@ -1,4 +1,8 @@ -using System; +using Microsoft.Extensions.Logging; +using SchoolContracts.BusinessLogicsContracts; +using SchoolContracts.StoragesContracts; +using SchoolContracts.ViewModels; +using System; using System.Collections.Generic; using System.Linq; using System.Text; @@ -6,8 +10,42 @@ using System.Threading.Tasks; namespace SchoolContracts.BusinessLogics { - public class ReportLogic + public class ReportLogic : IReportLogic { + private readonly ICircleStorage _circleStorage; + + private readonly IExpenseStorage _expenseStorage; + /// + /// Получение списка кружков с указанием списка затрат по ним + /// + /// + public List GetCircles() + { + var expenses = _expenseStorage.GetFullList(); + var circles = _circleStorage.GetFullList(); + var list = new List(); + foreach(var circle in circles) + { + var record = new ReportViewModel + { + CircleNumber = circle.Id, + Expenses = new List(), + CircleCount = 0 + + }; + foreach (var expense in expenses) + { + + } + list.Add(record); + } + return list; + } + /// + /// Получение списка занятий за определенный период + /// + /// + /// } } diff --git a/School/SchoolBusinessLogic/SchoolBusinessLogic.csproj b/School/SchoolBusinessLogic/SchoolBusinessLogic.csproj index 132c02c..bf61302 100644 --- a/School/SchoolBusinessLogic/SchoolBusinessLogic.csproj +++ b/School/SchoolBusinessLogic/SchoolBusinessLogic.csproj @@ -6,4 +6,13 @@ enable + + + + + + + + + diff --git a/School/SchoolContracts/BindingModels/CircleExpenseBindingModel.cs b/School/SchoolContracts/BindingModels/CircleExpenseBindingModel.cs new file mode 100644 index 0000000..cf16e3e --- /dev/null +++ b/School/SchoolContracts/BindingModels/CircleExpenseBindingModel.cs @@ -0,0 +1,18 @@ +using SchoolDataModels.Models; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SchoolContracts.BindingModels +{ + public class CircleExpenseBindingModel : ICircleExpenseModel + { + public int CircleId { get; set; } + + public int ExpenseId { get; set; } + + public int Id { get; set; } + } +} diff --git a/School/SchoolContracts/BindingModels/CircleLessonBindingModel.cs b/School/SchoolContracts/BindingModels/CircleLessonBindingModel.cs new file mode 100644 index 0000000..5ab3dfa --- /dev/null +++ b/School/SchoolContracts/BindingModels/CircleLessonBindingModel.cs @@ -0,0 +1,18 @@ +using SchoolDataModels.Models; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SchoolContracts.BindingModels +{ + public class CircleLessonBindingModel : ICircleLessonModel + { + public int CircleId { get; set; } + + public int LessonId { get; set; } + + public int Id { get; set; } + } +} diff --git a/School/SchoolContracts/BindingModels/ExpenseBindingModel.cs b/School/SchoolContracts/BindingModels/ExpenseBindingModel.cs index b6cc951..4d213f1 100644 --- a/School/SchoolContracts/BindingModels/ExpenseBindingModel.cs +++ b/School/SchoolContracts/BindingModels/ExpenseBindingModel.cs @@ -11,5 +11,6 @@ namespace SchoolContracts.BindingModels { public int Id { get; set; } public double Sum { get; set;} + public string ExpenseName { get; set;} } } diff --git a/School/SchoolContracts/BindingModels/PaymentBindingModel.cs b/School/SchoolContracts/BindingModels/PaymentBindingModel.cs index 7b2fdc4..c0b39ed 100644 --- a/School/SchoolContracts/BindingModels/PaymentBindingModel.cs +++ b/School/SchoolContracts/BindingModels/PaymentBindingModel.cs @@ -10,10 +10,9 @@ namespace SchoolContracts.BindingModel public class PaymentBindingModel : IPaymentModel { public int Id { get; set; } - public double Sum { get; set; } - public double Remains { get; set; } + public double PaySum { get; set; } public DateTime? DateOfPayment { get; set; } = DateTime.Now; - public int LessonId { get; set; } + public int CircleLessonId { get; set; } } } diff --git a/School/SchoolContracts/BindingModels/ReportBindingModel.cs b/School/SchoolContracts/BindingModels/ReportBindingModel.cs index 9d8a5de..f5992c8 100644 --- a/School/SchoolContracts/BindingModels/ReportBindingModel.cs +++ b/School/SchoolContracts/BindingModels/ReportBindingModel.cs @@ -9,9 +9,18 @@ namespace SchoolContracts.BindingModel public class ReportBindingModel { public string FileName { get; set; } = string.Empty; + /// + /// Выбранные кружки для отчета + /// + public List? SelectedCircles { get; set; } + /// + /// Начало периода для отчета по затратам + /// public DateTime? DateFrom { get; set; } + /// + /// Конец периода для отчета по затратам + /// public DateTime? DateTo { get; set; } - public int UserId { get; set; } } } diff --git a/School/SchoolContracts/BusinessLogicsContracts/ICircleExpenseLogic.cs b/School/SchoolContracts/BusinessLogicsContracts/ICircleExpenseLogic.cs new file mode 100644 index 0000000..cb50601 --- /dev/null +++ b/School/SchoolContracts/BusinessLogicsContracts/ICircleExpenseLogic.cs @@ -0,0 +1,21 @@ +using SchoolContracts.BindingModel; +using SchoolContracts.BindingModels; +using SchoolContracts.SearchModel; +using SchoolContracts.ViewModels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SchoolContracts.BusinessLogicsContracts +{ + public interface ICircleExpenseLogic + { + List? ReadList(CircleExpenseSearchModel? model); + CircleExpenseViewModel? ReadElement(CircleExpenseSearchModel model); + bool Create(CircleExpenseBindingModel model); + bool Update(CircleExpenseBindingModel model); + bool Delete(CircleExpenseBindingModel model); + } +} diff --git a/School/SchoolContracts/BusinessLogicsContracts/ICircleLessonLogic.cs b/School/SchoolContracts/BusinessLogicsContracts/ICircleLessonLogic.cs new file mode 100644 index 0000000..8f70681 --- /dev/null +++ b/School/SchoolContracts/BusinessLogicsContracts/ICircleLessonLogic.cs @@ -0,0 +1,21 @@ +using SchoolContracts.BindingModel; +using SchoolContracts.BindingModels; +using SchoolContracts.SearchModel; +using SchoolContracts.ViewModels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SchoolContracts.BusinessLogicsContracts +{ + public interface ICircleLessonLogic + { + List? ReadList(CircleLessonSearchModel? model); + CircleLessonViewModel? ReadElement(CircleLessonSearchModel model); + bool Create(CircleLessonBindingModel model); + bool Update(CircleLessonBindingModel model); + bool Delete(CircleLessonBindingModel model); + } +} diff --git a/School/SchoolContracts/BusinessLogicsContracts/IExpenseLogic.cs b/School/SchoolContracts/BusinessLogicsContracts/IExpenseLogic.cs new file mode 100644 index 0000000..cfc390e --- /dev/null +++ b/School/SchoolContracts/BusinessLogicsContracts/IExpenseLogic.cs @@ -0,0 +1,20 @@ +using SchoolContracts.BindingModels; +using SchoolContracts.SearchModel; +using SchoolContracts.ViewModels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SchoolContracts.BusinessLogicsContracts +{ + public interface IExpenseLogic + { + List? ReadList(ExpenseSearchModel? model); + ExpenseViewModel? ReadElement(ExpenseSearchModel model); + bool Create(ExpenseBindingModel model); + bool Update(ExpenseBindingModel model); + bool Delete(ExpenseBindingModel model); + } +} diff --git a/School/SchoolContracts/BusinessLogicsContracts/IPaymentLogic.cs b/School/SchoolContracts/BusinessLogicsContracts/IPaymentLogic.cs index 34b3bb8..e3073af 100644 --- a/School/SchoolContracts/BusinessLogicsContracts/IPaymentLogic.cs +++ b/School/SchoolContracts/BusinessLogicsContracts/IPaymentLogic.cs @@ -12,8 +12,10 @@ namespace SchoolContracts.BusinessLogicsContracts public interface IPaymentLogic { List? ReadList(PaymentSearchModel? model); - void CreateOrUpdate(PaymentBindingModel model); - void Delete(PaymentBindingModel model); + PaymentViewModel? ReadElement(PaymentSearchModel model); + bool Create(PaymentBindingModel model); + bool Update(PaymentBindingModel model); + bool Delete(PaymentBindingModel model); } } diff --git a/School/SchoolContracts/BusinessLogicsContracts/IReportLessonsLogic.cs b/School/SchoolContracts/BusinessLogicsContracts/IReportLessonsLogic.cs new file mode 100644 index 0000000..f974af4 --- /dev/null +++ b/School/SchoolContracts/BusinessLogicsContracts/IReportLessonsLogic.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SchoolContracts.BusinessLogicsContracts +{ + /// + /// Получение списка занятий с указанием, в каких кружках используются + /// + /// + public interface IReportLessonsLogic + { + + } +} diff --git a/School/SchoolContracts/BusinessLogicsContracts/IReportLogic.cs b/School/SchoolContracts/BusinessLogicsContracts/IReportLogic.cs index a45e86f..a46b18f 100644 --- a/School/SchoolContracts/BusinessLogicsContracts/IReportLogic.cs +++ b/School/SchoolContracts/BusinessLogicsContracts/IReportLogic.cs @@ -1,5 +1,6 @@ using SchoolContracts.BindingModel; using SchoolContracts.ViewModels; +using SchoolDataModels.Models; using System; using System.Collections.Generic; using System.Linq; @@ -11,18 +12,30 @@ namespace SchoolContracts.BusinessLogicsContracts public interface IReportLogic { /// - /// Получение списка занятий с указанием, в каких кружках используются + /// Получение списка кружков /// /// - List GetCircleLesson(); - List GetLessonCircle(); - void SaveCircleLessonToExcelFile(ReportBindingModel model); - void SaveLessonCircleToExcelFile(ReportBindingModel model); - void SaveCircleLessonToWordFile(ReportBindingModel model); - void SaveLessonCircleToWordFile(ReportBindingModel model); - List GetOrders(ReportBindingModel model); - List GetCircles(ReportBindingModel model); - void SaveOrdersToPdfFileCircle(ReportBindingModel model); - void SaveOrdersToPdfFileLessons(ReportBindingModel model); + List GetCircles(ReportBindingModel model); + /// + /// Получение списка затрат за определенный период + /// + /// + /// + //List GetExpenses(ReportBindingModel model); + /// + /// Сохранение компонент в файл-Word + /// + /// + void SaveComponentsToWordFile(ReportBindingModel model); + /// + /// Сохранение компонент с указаеним продуктов в файл-Excel + /// + /// + void SaveManufactureComponentToExcelFile(ReportBindingModel model); + /// + /// Сохранение заказов в файл-Pdf + /// + /// + void SaveOrdersToPdfFile(ReportBindingModel model); } } diff --git a/School/SchoolContracts/SearchModel/CircleExpenseSearchModel.cs b/School/SchoolContracts/SearchModel/CircleExpenseSearchModel.cs new file mode 100644 index 0000000..01d6ca8 --- /dev/null +++ b/School/SchoolContracts/SearchModel/CircleExpenseSearchModel.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SchoolContracts.SearchModel +{ + public class CircleExpenseSearchModel + { + public int? Id { get; set; } + } +} diff --git a/School/SchoolContracts/SearchModel/CircleLessonSearchModel.cs b/School/SchoolContracts/SearchModel/CircleLessonSearchModel.cs new file mode 100644 index 0000000..bc67235 --- /dev/null +++ b/School/SchoolContracts/SearchModel/CircleLessonSearchModel.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SchoolContracts.SearchModel +{ + public class CircleLessonSearchModel + { + public int? Id { get; set; } + } +} diff --git a/School/SchoolContracts/SearchModel/CircleSearchModel.cs b/School/SchoolContracts/SearchModel/CircleSearchModel.cs index 52adecc..3dedbe6 100644 --- a/School/SchoolContracts/SearchModel/CircleSearchModel.cs +++ b/School/SchoolContracts/SearchModel/CircleSearchModel.cs @@ -12,5 +12,9 @@ namespace SchoolContracts.SearchModel public DateTime? DateFrom { get; set; } public DateTime? DateTo { get; set; } public int? ClientId { get; set; } + /// + /// Id выбранных кружков + /// + public List? SelectedCirclesIds { get; set; } } } diff --git a/School/SchoolContracts/SearchModel/ExpenseSearchModel.cs b/School/SchoolContracts/SearchModel/ExpenseSearchModel.cs index 411ab1b..da3f271 100644 --- a/School/SchoolContracts/SearchModel/ExpenseSearchModel.cs +++ b/School/SchoolContracts/SearchModel/ExpenseSearchModel.cs @@ -9,5 +9,8 @@ namespace SchoolContracts.SearchModel public class ExpenseSearchModel { public int? Id { get; set; } + public string ExpenseName { get; set; } + public DateTime? DateTo { get; set; } + public DateTime? DateFrom { get; set; } } } diff --git a/School/SchoolContracts/SearchModel/PaymentSearchModel.cs b/School/SchoolContracts/SearchModel/PaymentSearchModel.cs index 5d5f74e..0cc8a77 100644 --- a/School/SchoolContracts/SearchModel/PaymentSearchModel.cs +++ b/School/SchoolContracts/SearchModel/PaymentSearchModel.cs @@ -9,8 +9,6 @@ namespace SchoolContracts.SearchModel public class PaymentSearchModel { public int? Id { get; set; } - public DateTime? DateTo { get; set; } - public DateTime? DateFrom { get; set; } - public int? LessonId { get; set; } + public int? CircleLessonId { get; set; } } } diff --git a/School/SchoolContracts/StoragesContracts/ICircleExpenseStorage.cs b/School/SchoolContracts/StoragesContracts/ICircleExpenseStorage.cs new file mode 100644 index 0000000..ecdabba --- /dev/null +++ b/School/SchoolContracts/StoragesContracts/ICircleExpenseStorage.cs @@ -0,0 +1,22 @@ +using SchoolContracts.BindingModel; +using SchoolContracts.BindingModels; +using SchoolContracts.SearchModel; +using SchoolContracts.ViewModels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SchoolContracts.StoragesContracts +{ + public interface ICircleExpenseStorage + { + List GetFullList(); + List GetFilteredList(CircleExpenseSearchModel model); + CircleExpenseViewModel GetElement(CircleExpenseSearchModel model); + CircleExpenseViewModel? Insert(CircleExpenseBindingModel model); + CircleExpenseViewModel? Update(CircleExpenseBindingModel model); + CircleExpenseViewModel? Delete(CircleExpenseBindingModel model); + } +} diff --git a/School/SchoolContracts/StoragesContracts/ICircleLessonStorage.cs b/School/SchoolContracts/StoragesContracts/ICircleLessonStorage.cs new file mode 100644 index 0000000..dd04a8d --- /dev/null +++ b/School/SchoolContracts/StoragesContracts/ICircleLessonStorage.cs @@ -0,0 +1,22 @@ +using SchoolContracts.BindingModel; +using SchoolContracts.BindingModels; +using SchoolContracts.SearchModel; +using SchoolContracts.ViewModels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SchoolContracts.StoragesContracts +{ + public interface ICircleLessonStorage + { + List GetFullList(); + List GetFilteredList(CircleLessonSearchModel model); + CircleLessonViewModel GetElement(CircleLessonSearchModel model); + CircleLessonViewModel? Insert(CircleLessonBindingModel model); + CircleLessonViewModel? Update(CircleLessonBindingModel model); + CircleLessonViewModel? Delete(CircleLessonBindingModel model); + } +} diff --git a/School/SchoolContracts/StoragesContracts/ICircleStorage.cs b/School/SchoolContracts/StoragesContracts/ICircleStorage.cs index 7f0e981..8b505f7 100644 --- a/School/SchoolContracts/StoragesContracts/ICircleStorage.cs +++ b/School/SchoolContracts/StoragesContracts/ICircleStorage.cs @@ -13,7 +13,8 @@ namespace SchoolContracts.StoragesContracts { List GetFullList(); List GetFilteredList(CircleSearchModel model); - CircleViewModel GetElement(CircleSearchModel model); + List GetLessonCircles(CircleSearchModel model); + CircleViewModel? GetElement(CircleSearchModel model); CircleViewModel? Insert(CircleBindingModel model); CircleViewModel? Update(CircleBindingModel model); CircleViewModel? Delete(CircleBindingModel model); diff --git a/School/SchoolContracts/ViewModels/CircleExpenseViewModel.cs b/School/SchoolContracts/ViewModels/CircleExpenseViewModel.cs new file mode 100644 index 0000000..f16143b --- /dev/null +++ b/School/SchoolContracts/ViewModels/CircleExpenseViewModel.cs @@ -0,0 +1,19 @@ +using SchoolDataModels.Models; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SchoolContracts.ViewModels +{ + public class CircleExpenseViewModel : ICircleExpenseModel + { + [DisplayName("Id кружка")] + public int CircleId { get; set; } + [DisplayName("Id затраты")] + public int ExpenseId { get; set; } + public int Id { get; set; } + } +} diff --git a/School/SchoolContracts/ViewModels/CircleLessonViewModel.cs b/School/SchoolContracts/ViewModels/CircleLessonViewModel.cs new file mode 100644 index 0000000..b11b33f --- /dev/null +++ b/School/SchoolContracts/ViewModels/CircleLessonViewModel.cs @@ -0,0 +1,19 @@ +using SchoolDataModels.Models; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SchoolContracts.ViewModels +{ + public class CircleLessonViewModel : ICircleLessonModel + { + [DisplayName("Id кружка")] + public int CircleId { get; set; } + [DisplayName("Id занятия")] + public int LessonId { get; set; } + public int Id { get; set; } + } +} diff --git a/School/SchoolContracts/ViewModels/ExpenseViewModel.cs b/School/SchoolContracts/ViewModels/ExpenseViewModel.cs index 08d88c4..18e97a5 100644 --- a/School/SchoolContracts/ViewModels/ExpenseViewModel.cs +++ b/School/SchoolContracts/ViewModels/ExpenseViewModel.cs @@ -10,6 +10,7 @@ namespace SchoolContracts.ViewModels public class ExpenseViewModel : IExpenseModel { public int Id { get; set; } + public string ExpenseName { get; set; } public double Sum { get; set; } } } diff --git a/School/SchoolContracts/ViewModels/PaymentViewModel.cs b/School/SchoolContracts/ViewModels/PaymentViewModel.cs index fb2bb5e..0e92c03 100644 --- a/School/SchoolContracts/ViewModels/PaymentViewModel.cs +++ b/School/SchoolContracts/ViewModels/PaymentViewModel.cs @@ -10,10 +10,9 @@ namespace SchoolContracts.ViewModels public class PaymentViewModel : IPaymentModel { public int Id { get; set; } - public double Sum { get; set; } - public double Remains { get; set; } + public double PaySum { get; set; } public DateTime? DateOfPayment { get; set; } - public int LessonId { get; set; } + public int CircleLessonId { get; set; } } } diff --git a/School/SchoolContracts/ViewModels/ReportCircleLessonViewModel.cs b/School/SchoolContracts/ViewModels/ReportCircleLessonViewModel.cs deleted file mode 100644 index 3492d07..0000000 --- a/School/SchoolContracts/ViewModels/ReportCircleLessonViewModel.cs +++ /dev/null @@ -1,16 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace SchoolContracts.ViewModels -{ - public class ReportCircleLessonViewModel - { - public DateTime? StartDate { get; set; } - public List Lessons { get; set; } - public int TotalCount { get; set; } - } - -} diff --git a/School/SchoolContracts/ViewModels/ReportCircleLessonsViewModel.cs b/School/SchoolContracts/ViewModels/ReportCircleLessonsViewModel.cs new file mode 100644 index 0000000..54e6200 --- /dev/null +++ b/School/SchoolContracts/ViewModels/ReportCircleLessonsViewModel.cs @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SchoolContracts.ViewModels +{ + /// + /// Модель для получения всех занятий по кружку для отчета + /// + public class ReportCircleLessonsViewModel + { + /// + /// Номер кружка + /// + public int CircleId { get; set; } + /// + /// Занятия в кружке + /// + public List CircleLessons { get; set; } = new(); + } +} diff --git a/School/SchoolContracts/ViewModels/ReportCircleViewModel.cs b/School/SchoolContracts/ViewModels/ReportCircleViewModel.cs deleted file mode 100644 index 94c7f09..0000000 --- a/School/SchoolContracts/ViewModels/ReportCircleViewModel.cs +++ /dev/null @@ -1,17 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace SchoolContracts.ViewModels -{ - public class ReportCircleViewModel - { - public DateTime DateStart { get; set; } - public string ClientName { get; set; } - public double Sum { get; set; } - public Dictionary Circles { get; set; } - - } -} diff --git a/School/SchoolContracts/ViewModels/ReportExpensesViewModel.cs b/School/SchoolContracts/ViewModels/ReportExpensesViewModel.cs new file mode 100644 index 0000000..6947c7a --- /dev/null +++ b/School/SchoolContracts/ViewModels/ReportExpensesViewModel.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SchoolContracts.ViewModels +{ + public class ReportExpensesViewModel + { + [DisplayName("Название затраты")] + public string ExpenseName { get; set; } = string.Empty; + [DisplayName("Сумма")] + public double Sum { get; set; } + } + +} diff --git a/School/SchoolContracts/ViewModels/ReportLessonCircleViewModel.cs b/School/SchoolContracts/ViewModels/ReportLessonCircleViewModel.cs deleted file mode 100644 index 965852e..0000000 --- a/School/SchoolContracts/ViewModels/ReportLessonCircleViewModel.cs +++ /dev/null @@ -1,16 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace SchoolContracts.ViewModels -{ - public class ReportLessonCircleViewModel - { - public string LessonName { get; set; } - public List Circles { get; set; } - public int TotalCount { get; set; } - - } -} diff --git a/School/SchoolContracts/ViewModels/ReportLessonCirclesViewModel.cs b/School/SchoolContracts/ViewModels/ReportLessonCirclesViewModel.cs new file mode 100644 index 0000000..4580c07 --- /dev/null +++ b/School/SchoolContracts/ViewModels/ReportLessonCirclesViewModel.cs @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SchoolContracts.ViewModels +{ + /// + /// Модель для получения всех занятий по кружку для отчета + /// + public class ReportLessonCircleViewModel + { + /// + /// Номер кружка + /// + public int CircleId { get; set; } + /// + /// Занятия в кружке + /// + public List CircleLessons { get; set; } = new(); + } +} diff --git a/School/SchoolContracts/ViewModels/ReportViewModel.cs b/School/SchoolContracts/ViewModels/ReportViewModel.cs index 65bbd3f..18634ee 100644 --- a/School/SchoolContracts/ViewModels/ReportViewModel.cs +++ b/School/SchoolContracts/ViewModels/ReportViewModel.cs @@ -10,14 +10,15 @@ namespace SchoolContracts.ViewModels public class ReportViewModel { [DisplayName("Имя кружка")] - int CircleNumber { get; set; } - [DisplayName("Дата кружка")] - DateTime Date { get; set; } - [DisplayName("Сумма")] - double Sum { get; set; } + public int CircleNumber { get; set; } + [DisplayName("Дата записи")] + public DateTime Date { get; set; } + [DisplayName("Сумма затрат")] + public double Sum { get; set; } [DisplayName("Кол-во занятий")] - int CircleCount { get; set; } - [DisplayName("Имя клиента")] - string ClientName { get; set; } = string.Empty; + public int CircleCount { get; set; } + [DisplayName("Название затраты")] + public List Expenses{ get; set; } + } } diff --git a/School/SchoolContracts/ViewModels/ReportViewerLessonModel.cs b/School/SchoolContracts/ViewModels/ReportViewerLessonModel.cs deleted file mode 100644 index b62a3fe..0000000 --- a/School/SchoolContracts/ViewModels/ReportViewerLessonModel.cs +++ /dev/null @@ -1,15 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace SchoolContracts.ViewModels -{ - public class ReportViewerLessonModel - { - public string LessonName { get; set; } - public int Count { get; set; } - - } -} diff --git a/School/SchoolDataModels/Models/ICircleExpenseModel.cs b/School/SchoolDataModels/Models/ICircleExpenseModel.cs new file mode 100644 index 0000000..362a38f --- /dev/null +++ b/School/SchoolDataModels/Models/ICircleExpenseModel.cs @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SchoolDataModels.Models +{ + /// + /// Кружок и затраты + /// + public interface ICircleExpenseModel : IId + { + /// + /// Id кружка + /// + public int CircleId { get;} + /// + /// Id затрат + /// + public int ExpenseId { get; } + } +} diff --git a/School/SchoolDataModels/Models/ICircleLessonModel.cs b/School/SchoolDataModels/Models/ICircleLessonModel.cs new file mode 100644 index 0000000..a37ef6d --- /dev/null +++ b/School/SchoolDataModels/Models/ICircleLessonModel.cs @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SchoolDataModels.Models +{ + /// + /// Кружок и занятие + /// + public interface ICircleLessonModel : IId + { + /// + /// Id кружка + /// + public int CircleId { get; } + /// /// + /// Id занятия + /// + public int LessonId { get; } + } +} diff --git a/School/SchoolDataModels/Models/IExpenseModel.cs b/School/SchoolDataModels/Models/IExpenseModel.cs index cb27b6d..70637a4 100644 --- a/School/SchoolDataModels/Models/IExpenseModel.cs +++ b/School/SchoolDataModels/Models/IExpenseModel.cs @@ -15,5 +15,9 @@ namespace SchoolDataModels.Models /// Сумма затраты /// public double Sum { get; } + /// + /// Название + /// + public string ExpenseName { get; } } } diff --git a/School/SchoolDataModels/Models/IPaymentModel.cs b/School/SchoolDataModels/Models/IPaymentModel.cs index 174bda9..128c83a 100644 --- a/School/SchoolDataModels/Models/IPaymentModel.cs +++ b/School/SchoolDataModels/Models/IPaymentModel.cs @@ -12,13 +12,9 @@ namespace SchoolDataModels.Models public interface IPaymentModel : IId { /// - /// Сумма + /// Оплаченная сумма /// - public double Sum { get; set; } - /// - /// Остатки - /// - public double Remains { get; set; } + public double PaySum { get; set; } /// /// Дата платежа /// @@ -26,6 +22,6 @@ namespace SchoolDataModels.Models /// /// Id занятия /// - public int LessonId { get; set; } + public int CircleLessonId { get; set; } } } diff --git a/School/SchoolDatabaseImplements/Implements/CircleExpenseStorage.cs b/School/SchoolDatabaseImplements/Implements/CircleExpenseStorage.cs new file mode 100644 index 0000000..7457c4e --- /dev/null +++ b/School/SchoolDatabaseImplements/Implements/CircleExpenseStorage.cs @@ -0,0 +1,94 @@ +using Microsoft.EntityFrameworkCore; +using SchoolContracts.BindingModels; +using SchoolContracts.SearchModel; +using SchoolContracts.StoragesContracts; +using SchoolContracts.ViewModels; +using SchoolDatabaseImplement; +using SchoolDatabaseImplement.Models; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SchoolDatabaseImplements.Implements +{ + public class CircleExpenseStorage : ICircleExpenseStorage + { + public CircleExpenseViewModel? Delete(CircleExpenseBindingModel model) + { + using var context = new SchoolDatabase(); + var circleExpense = context.CircleExpenses.FirstOrDefault(rec => rec.Id == model.Id); + if (circleExpense != null) + { + context.CircleExpenses.Remove(circleExpense); + context.SaveChanges(); + return circleExpense.GetViewModel; + } + return null; + } + + public CircleExpenseViewModel GetElement(CircleExpenseSearchModel model) + { + if (model == null) + { + return null; + } + using var context = new SchoolDatabase(); + if (model.Id.HasValue) + { + return context.CircleExpenses.Include(x => x.Circle) + .Include(x => x.Expense) + .FirstOrDefault(x => x.Id == model.Id)?.GetViewModel; + } + return null; + } + + public List GetFilteredList(CircleExpenseSearchModel model) + { + using var context = new SchoolDatabase(); + return context.CircleExpenses + .Where(x => x.Id == model.Id) + .Include(x => x.Circle) + .Include(x => x.Expense) + .Select(x => x.GetViewModel) + .ToList(); + } + + public List GetFullList() + { + using var context = new SchoolDatabase(); + return context.CircleExpenses + .Include(x => x.Circle) + .Include(x => x.Expense) + .Select(x => x.GetViewModel) + .ToList(); + } + + public CircleExpenseViewModel? Insert(CircleExpenseBindingModel model) + { + using var context = new SchoolDatabase(); + var newCircleExpense = CircleExpense.Create(context, model); + if (newCircleExpense == null) + { + return null; + } + context.CircleExpenses.Add(newCircleExpense); + context.SaveChanges(); + return newCircleExpense.GetViewModel; + } + + public CircleExpenseViewModel? Update(CircleExpenseBindingModel model) + { + using var context = new SchoolDatabase(); + var circleExpense = context.CircleExpenses.FirstOrDefault(x => x.Id == model.Id); + if (circleExpense == null) + { + return null; + } + circleExpense.Update(model); + context.SaveChanges(); + return circleExpense.GetViewModel; + } + } +} diff --git a/School/SchoolDatabaseImplements/Implements/CircleLessonStorage.cs b/School/SchoolDatabaseImplements/Implements/CircleLessonStorage.cs new file mode 100644 index 0000000..d4d3ce0 --- /dev/null +++ b/School/SchoolDatabaseImplements/Implements/CircleLessonStorage.cs @@ -0,0 +1,94 @@ +using Microsoft.EntityFrameworkCore; +using SchoolContracts.BindingModels; +using SchoolContracts.SearchModel; +using SchoolContracts.StoragesContracts; +using SchoolContracts.ViewModels; +using SchoolDatabaseImplement; +using SchoolDatabaseImplement.Models; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SchoolDatabaseImplements.Implements +{ + public class CircleLessonStorage : ICircleLessonStorage + { + public CircleLessonViewModel? Delete(CircleLessonBindingModel model) + { + using var context = new SchoolDatabase(); + var circlelesson = context.CircleLessons.FirstOrDefault(rec => rec.Id == model.Id); + if (circlelesson != null) + { + context.CircleLessons.Remove(circlelesson); + context.SaveChanges(); + return circlelesson.GetViewModel; + } + return null; + } + + public CircleLessonViewModel? GetElement(CircleLessonSearchModel model) + { + if (model == null) + { + return null; + } + using var context = new SchoolDatabase(); + if (model.Id.HasValue) + { + return context.CircleLessons.Include(x => x.Circle) + .Include(x => x.Lesson) + .FirstOrDefault(x => x.Id == model.Id)?.GetViewModel; + } + return null; + } + + public List GetFilteredList(CircleLessonSearchModel model) + { + using var context = new SchoolDatabase(); + return context.CircleLessons + .Where(x => x.Id == model.Id) + .Include(x => x.Circle) + .Include(x => x.Lesson) + .Select(x => x.GetViewModel) + .ToList(); + } + + public List GetFullList() + { + using var context = new SchoolDatabase(); + return context.CircleLessons + .Include(x => x.Circle) + .Include(x => x.Lesson) + .Select(x => x.GetViewModel) + .ToList(); + } + + public CircleLessonViewModel? Insert(CircleLessonBindingModel model) + { + using var context = new SchoolDatabase(); + var newCircleLesson = CircleLesson.Create(context, model); + if (newCircleLesson == null) + { + return null; + } + context.CircleLessons.Add(newCircleLesson); + context.SaveChanges(); + return newCircleLesson.GetViewModel; + } + + public CircleLessonViewModel? Update(CircleLessonBindingModel model) + { + using var context = new SchoolDatabase(); + var circlelesson = context.CircleLessons.FirstOrDefault(x => x.Id == model.Id); + if (circlelesson == null) + { + return null; + } + circlelesson.Update(model); + context.SaveChanges(); + return circlelesson.GetViewModel; + } + } +} diff --git a/School/SchoolDatabaseImplements/Implements/CircleStorage.cs b/School/SchoolDatabaseImplements/Implements/CircleStorage.cs index b780f02..6eeccd1 100644 --- a/School/SchoolDatabaseImplements/Implements/CircleStorage.cs +++ b/School/SchoolDatabaseImplements/Implements/CircleStorage.cs @@ -17,7 +17,6 @@ namespace SchoolDatabaseImplement.Implements { public List GetFullList() { - using var context = new SchoolDatabase(); return context.Circles .Include(x => x.Client) @@ -94,5 +93,37 @@ namespace SchoolDatabaseImplement.Implements } return null; } + + public List GetLessonCircles(CircleSearchModel model) + { + if (model.SelectedCirclesIds == null) + { + return new(); + } + using var context = new SchoolDatabase(); + return context.Circles + .Where(c => model.SelectedCirclesIds.Contains(c.Id)) + .Select(c => new ReportCircleLessonsViewModel() + { + CircleLessons = GetCircleLessons(context, new() { Id = c.Id }) + }) + .ToList(); + } + /// + /// Получение списка занятий по выбранному кружку + /// + /// + /// + private static List GetCircleLessons(SchoolDatabase context, CircleSearchModel model) + { + return context.Circles + .Include(wir => wir.CircleLessons) + .Where(wir => wir.Id == model.Id) + .Select(wir => new ReportLessonCirclesViewModel() + { + LessonId = wir.CircleLessons.Id + }) + .ToList(); + } } } diff --git a/School/SchoolDatabaseImplements/Implements/ExpenseStorage.cs b/School/SchoolDatabaseImplements/Implements/ExpenseStorage.cs index c11ad5f..72f314f 100644 --- a/School/SchoolDatabaseImplements/Implements/ExpenseStorage.cs +++ b/School/SchoolDatabaseImplements/Implements/ExpenseStorage.cs @@ -1,7 +1,10 @@ -using SchoolContracts.BindingModels; +using Microsoft.EntityFrameworkCore; +using SchoolContracts.BindingModels; using SchoolContracts.SearchModel; using SchoolContracts.StoragesContracts; using SchoolContracts.ViewModels; +using SchoolDatabaseImplement; +using SchoolDatabaseImplement.Models; using System; using System.Collections.Generic; using System.Linq; @@ -14,32 +17,74 @@ namespace SchoolDatabaseImplements.Implements { public ExpenseViewModel? Delete(ExpenseBindingModel model) { - throw new NotImplementedException(); + using var context = new SchoolDatabase(); + var element = context.Expenses.FirstOrDefault(x => x.Id == model.Id); + if (element != null) + { + context.Expenses.Remove(element); + context.SaveChanges(); + return element.GetViewModel; + } + return null; } public ExpenseViewModel GetElement(ExpenseSearchModel model) { - throw new NotImplementedException(); + using var context = new SchoolDatabase(); + if (model.Id.HasValue)//сначала ищем по Id + { + return context.Expenses + .FirstOrDefault(x => x.Id == model.Id)?.GetViewModel; + } + if (!string.IsNullOrEmpty(model.ExpenseName))//затем по названию + { + return context.Expenses + .FirstOrDefault(x => x.ExpenseName == model.ExpenseName)?.GetViewModel; + } + return null; } public List GetFilteredList(ExpenseSearchModel model) { - throw new NotImplementedException(); + using var context = new SchoolDatabase(); + return context.Expenses + .Where (x => x.Id == model.Id) + .Select(x => x.GetViewModel) + .ToList(); } public List GetFullList() { - throw new NotImplementedException(); + using var context = new SchoolDatabase(); + return context.Expenses + .Select(x => x.GetViewModel) + .ToList(); } public ExpenseViewModel? Insert(ExpenseBindingModel model) { - throw new NotImplementedException(); + using var context = new SchoolDatabase(); + var newExpense = Expense.Create(model); + if (newExpense == null) + { + return null; + } + context.Expenses.Add(newExpense); + context.SaveChanges(); + return newExpense.GetViewModel; } public ExpenseViewModel? Update(ExpenseBindingModel model) { - throw new NotImplementedException(); + using var context = new SchoolDatabase(); + var expense = context.Expenses.FirstOrDefault(x => x.Id == model.Id); + if (expense == null) + { + return null; + } + expense.Update(model); + context.SaveChanges(); + return expense.GetViewModel; } } } diff --git a/School/SchoolDatabaseImplements/Implements/LessonStorage.cs b/School/SchoolDatabaseImplements/Implements/LessonStorage.cs index cf0b9f1..409f05a 100644 --- a/School/SchoolDatabaseImplements/Implements/LessonStorage.cs +++ b/School/SchoolDatabaseImplements/Implements/LessonStorage.cs @@ -76,7 +76,7 @@ namespace SchoolDatabaseImplement.Implements public LessonViewModel? Delete(LessonBindingModel model) { using var context = new SchoolDatabase(); - var element = context.Lessons.FirstOrDefault(rec => rec.Id == model.Id); + var element = context.Lessons.FirstOrDefault(x => x.Id == model.Id); if (element != null) { context.Lessons.Remove(element); diff --git a/School/SchoolDatabaseImplements/Implements/PaymentStorage.cs b/School/SchoolDatabaseImplements/Implements/PaymentStorage.cs index 0d3f590..1eaf2e7 100644 --- a/School/SchoolDatabaseImplements/Implements/PaymentStorage.cs +++ b/School/SchoolDatabaseImplements/Implements/PaymentStorage.cs @@ -19,7 +19,7 @@ namespace SchoolDatabaseImplement.Implements { using var context = new SchoolDatabase(); return context.Payments - .Include(rec => rec.Lesson) + .Include(rec => rec.CircleLesson) .Select(x => x.GetViewModel) .ToList(); } @@ -31,17 +31,16 @@ namespace SchoolDatabaseImplement.Implements return null; } using var context = new SchoolDatabase(); - var list = context.Payments.Where(x => x.LessonId == model.LessonId) + var list = context.Payments.Where(x => x.CircleLessonId == model.CircleLessonId) .OrderBy(x => x.DateOfPayment) - .Include(x => x.Lesson); + .Include(x => x.CircleLesson); return list .Select(x => new PaymentViewModel { DateOfPayment = x.DateOfPayment, Id = x.Id, - Remains = x.Remains, - Sum = x.Sum, - LessonId = x.LessonId + PaySum = x.PaySum, + CircleLessonId = x.CircleLessonId }) .ToList(); } @@ -53,15 +52,14 @@ namespace SchoolDatabaseImplement.Implements } using var context = new SchoolDatabase(); { - var payment = context.Payments.Include(x=> x.Lesson) - .FirstOrDefault(x => x.LessonId == model.LessonId); - return payment != null? new PaymentViewModel + var payment = context.Payments.Include(x=> x.CircleLesson) + .FirstOrDefault(x => x.CircleLessonId == model.CircleLessonId); + return payment != null ? new PaymentViewModel { DateOfPayment = payment.DateOfPayment, Id = payment.Id, - Remains = payment.Lesson.LessonPrice, - Sum = payment.Sum, - LessonId = payment.LessonId + PaySum = payment.PaySum, + CircleLessonId = payment.CircleLessonId } : null; } @@ -83,7 +81,7 @@ namespace SchoolDatabaseImplement.Implements { var context = new SchoolDatabase(); var element = context.Payments. - Include(x => x.Lesson) + Include(x => x.CircleLesson) .FirstOrDefault(rec => rec.Id == model.Id); if (element == null) { @@ -98,7 +96,7 @@ namespace SchoolDatabaseImplement.Implements var context = new SchoolDatabase(); var element = context.Payments - .Include(x => x.Lesson) + .Include(x => x.CircleLesson) .FirstOrDefault(rec => rec.Id == model.Id); if (element != null) { diff --git a/School/SchoolDatabaseImplements/Models/Circle.cs b/School/SchoolDatabaseImplements/Models/Circle.cs index 79fdcaf..f59f772 100644 --- a/School/SchoolDatabaseImplements/Models/Circle.cs +++ b/School/SchoolDatabaseImplements/Models/Circle.cs @@ -22,7 +22,7 @@ namespace SchoolDatabaseImplement.Models public int ClientId { get; private set; } public virtual Client Client { get; private set; } = new(); [ForeignKey("CircleId")] - public virtual List CircleLessons { get; set; } = new(); + public virtual CircleLesson CircleLessons { get; set; } = new(); [ForeignKey("CircleId")] public virtual List CircleExpenses { get; set; } = new(); public static Circle Create(SchoolDatabase context, CircleBindingModel model) diff --git a/School/SchoolDatabaseImplements/Models/CircleExpense.cs b/School/SchoolDatabaseImplements/Models/CircleExpense.cs index 4744370..abf5453 100644 --- a/School/SchoolDatabaseImplements/Models/CircleExpense.cs +++ b/School/SchoolDatabaseImplements/Models/CircleExpense.cs @@ -1,4 +1,7 @@ using Microsoft.EntityFrameworkCore; +using SchoolContracts.BindingModel; +using SchoolContracts.BindingModels; +using SchoolContracts.ViewModels; using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; @@ -17,5 +20,27 @@ namespace SchoolDatabaseImplement.Models public int CircleId { get; set; } public virtual Expense Expense { get; set; } = new(); public virtual Circle Circle { get; set; } = new(); + public static CircleExpense? Create(SchoolDatabase context, CircleExpenseBindingModel model) + { + if (model == null) + { + return null; + } + return new() + { + Id = model.Id, + Circle = context.Circles.First(x => x.Id == model.CircleId), + Expense = context.Expenses.First(x => x.Id == model.ExpenseId) + }; + } + public void Update(CircleExpenseBindingModel model) + { + Id = model.Id; + } + + public CircleExpenseViewModel GetViewModel => new() + { + Id = Id + }; } } diff --git a/School/SchoolDatabaseImplements/Models/CircleLesson.cs b/School/SchoolDatabaseImplements/Models/CircleLesson.cs index 6e27992..1f86aa7 100644 --- a/School/SchoolDatabaseImplements/Models/CircleLesson.cs +++ b/School/SchoolDatabaseImplements/Models/CircleLesson.cs @@ -1,4 +1,7 @@ -using System; +using SchoolContracts.BindingModel; +using SchoolContracts.BindingModels; +using SchoolContracts.ViewModels; +using System; using System.Collections.Generic; using System.ComponentModel; using System.ComponentModel.DataAnnotations; @@ -21,5 +24,26 @@ namespace SchoolDatabaseImplement.Models public int Count { get; set; } public virtual Lesson Lesson { get; set; } = new(); public virtual Circle Circle { get; set; } = new(); + [ForeignKey("CircleLessonId")] + public virtual List Payments { get; set; } = new(); + public static CircleLesson Create(SchoolDatabase context, CircleLessonBindingModel model) + { + return new CircleLesson() + { + Id = model.Id, + Circle = context.Circles.First(x => x.Id == model.CircleId), + Lesson = context.Lessons.First(x => x.Id == model.LessonId) + }; + } + + public void Update(CircleLessonBindingModel model) + { + Id = model.Id; + } + + public CircleLessonViewModel GetViewModel => new() + { + Id = Id + }; } } diff --git a/School/SchoolDatabaseImplements/Models/Employee.cs b/School/SchoolDatabaseImplements/Models/Employee.cs index 1580490..df6c04a 100644 --- a/School/SchoolDatabaseImplements/Models/Employee.cs +++ b/School/SchoolDatabaseImplements/Models/Employee.cs @@ -53,8 +53,7 @@ namespace SchoolDatabaseImplement.Models public ExpenseViewModel GetViewModel => new() { - Id = Id, - //TODO + Id = Id }; } diff --git a/School/SchoolDatabaseImplements/Models/Expense.cs b/School/SchoolDatabaseImplements/Models/Expense.cs index 81683af..86bdb62 100644 --- a/School/SchoolDatabaseImplements/Models/Expense.cs +++ b/School/SchoolDatabaseImplements/Models/Expense.cs @@ -1,4 +1,7 @@ -using SchoolDataModels.Models; +using SchoolContracts.BindingModel; +using SchoolContracts.BindingModels; +using SchoolContracts.ViewModels; +using SchoolDataModels.Models; using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; @@ -12,9 +15,39 @@ namespace SchoolDatabaseImplement.Models public class Expense : IExpenseModel { public int Id { get; private set; } + public string ExpenseName { get; private set; } = string.Empty; [Required] public double Sum { get; private set; } [ForeignKey("ExpenseId")] public virtual List CircleExpenses { get; set; } = new(); + public static Expense? Create(ExpenseBindingModel model) + { + if (model == null) + { + return null; + } + return new() + { + Id = model.Id, + ExpenseName = model.ExpenseName, + Sum = model.Sum + }; + } + public void Update(ExpenseBindingModel model) + { + if (model == null) + { + return; + } + ExpenseName = model.ExpenseName; + Sum = model.Sum; + } + + public ExpenseViewModel GetViewModel => new() + { + Id = Id, + ExpenseName = ExpenseName, + Sum = Sum + }; } } diff --git a/School/SchoolDatabaseImplements/Models/Payment.cs b/School/SchoolDatabaseImplements/Models/Payment.cs index d6a8f8a..77df5c3 100644 --- a/School/SchoolDatabaseImplements/Models/Payment.cs +++ b/School/SchoolDatabaseImplements/Models/Payment.cs @@ -13,12 +13,12 @@ namespace SchoolDatabaseImplement.Models { public int Id { get; private set; } [Required] - public int LessonId { get; private set; } - public double Sum { get; private set; } - public double Remains { get; private set; } + public int CircleLessonId { get; private set; } + [Required] + public double PaySum { get; private set; } [Required] public DateTime? DateOfPayment { get; private set; } = DateTime.Now; - public virtual Lesson Lesson { get; private set; } = new(); + public virtual CircleLesson CircleLesson { get; private set; } = new(); public static Payment? Create(SchoolDatabase context, PaymentBindingModel? model) { if (model == null) @@ -29,9 +29,8 @@ namespace SchoolDatabaseImplement.Models return new Payment() { Id = model.Id, - Lesson = context.Lessons.First(x => x.Id == model.LessonId), - Sum = model.Sum, - Remains = model.Remains, + CircleLesson = context.CircleLessons.First(x => x.Id == model.CircleLessonId), + PaySum = model.PaySum, DateOfPayment = model.DateOfPayment }; } @@ -42,9 +41,8 @@ namespace SchoolDatabaseImplement.Models return; } Id = model.Id; - LessonId = model.LessonId; - Sum = model.Sum; - Remains = model.Remains; + CircleLessonId = model.CircleLessonId; + PaySum = model.PaySum; DateOfPayment = model.DateOfPayment; } @@ -57,9 +55,8 @@ namespace SchoolDatabaseImplement.Models return new() { Id = Id, - LessonId = LessonId, - Sum = Sum, - Remains = Remains, + CircleLessonId = CircleLessonId, + PaySum = PaySum, DateOfPayment = DateOfPayment }; }