сделан отчет и заглушка для сотрудника
This commit is contained in:
parent
15bcd7eb8a
commit
c2a3d72fda
@ -0,0 +1,130 @@
|
|||||||
|
using SchoolContracts.BusinessLogicsContracts;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace SchoolBusinessLogic.BusinessLogics
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Заглушка для роли сотрудника
|
||||||
|
/// </summary>
|
||||||
|
public class EmployeeRoleImitationaLogic
|
||||||
|
{
|
||||||
|
private readonly IEmployeeLogic _employeeLogic;
|
||||||
|
private readonly ILessonLogic _lessonLogic;
|
||||||
|
private readonly IExpenseLogic _ExpenseLogic;
|
||||||
|
private readonly ICircleLogic _circleLogic;
|
||||||
|
private readonly ICircleExpenseLogic _circleExpenseLogic;
|
||||||
|
|
||||||
|
public EmployeeRoleImitationaLogic(IEmployeeLogic employeeLogic,
|
||||||
|
ILessonLogic lessonLogic, IExpenseLogic ExpenseLogic,
|
||||||
|
ICircleLogic circleLogic, ICircleExpenseLogic circleExpenseLogic)
|
||||||
|
{
|
||||||
|
_employeeLogic = employeeLogic;
|
||||||
|
_lessonLogic = lessonLogic;
|
||||||
|
_ExpenseLogic = ExpenseLogic;
|
||||||
|
_circleLogic = circleLogic;
|
||||||
|
_circleExpenseLogic = circleExpenseLogic;
|
||||||
|
}
|
||||||
|
private bool GenerateEmployeeData()
|
||||||
|
{
|
||||||
|
if(_employeeLogic.ReadList(null)?.Count != 0 )
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
using (StreamReader sr = new("employees.txt"))
|
||||||
|
{
|
||||||
|
string? currentString;
|
||||||
|
while ((currentString = sr.ReadLine()) != null)
|
||||||
|
{
|
||||||
|
var employeeRecData = currentString.Split(',');
|
||||||
|
_employeeLogic.Create(new()
|
||||||
|
{
|
||||||
|
EmployeeEmail = employeeRecData[0],
|
||||||
|
EmployeePassword = employeeRecData[1],
|
||||||
|
EmployeeName = employeeRecData[2],
|
||||||
|
EmployeePhone = employeeRecData[3]
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
private bool GenerateLessonData()
|
||||||
|
{
|
||||||
|
if(_lessonLogic.ReadList(null)?.Count != 0)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
using (StreamReader sr = new("lessons.txt"))
|
||||||
|
{
|
||||||
|
string? currentString;
|
||||||
|
while ((currentString = sr.ReadLine()) != null)
|
||||||
|
{
|
||||||
|
var lessonRecData = currentString.Split(',');
|
||||||
|
_lessonLogic.Create(new()
|
||||||
|
{
|
||||||
|
LessonName = Convert.ToString(lessonRecData[0]),
|
||||||
|
LessonPrice = Convert.ToDouble(lessonRecData[1])
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
public bool GenerateExpense()
|
||||||
|
{
|
||||||
|
if (_ExpenseLogic.ReadList(null)?.Count != 0)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
using (StreamReader sr = new("expenses.txt"))
|
||||||
|
{
|
||||||
|
string? currentString;
|
||||||
|
while ((currentString = sr.ReadLine()) != null)
|
||||||
|
{
|
||||||
|
var expenseRecData = currentString.Split(',');
|
||||||
|
_ExpenseLogic.Create(new()
|
||||||
|
{
|
||||||
|
ExpenseName = Convert.ToString(expenseRecData[0]),
|
||||||
|
Sum = Convert.ToDouble(expenseRecData[1]),
|
||||||
|
Count = Convert.ToInt32(expenseRecData[2]),
|
||||||
|
EmployeeId = Convert.ToInt32(expenseRecData[3])
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
public bool GenerateCircleExpense()
|
||||||
|
{
|
||||||
|
var ExpenseList = _ExpenseLogic.ReadList(null);
|
||||||
|
if (ExpenseList == null)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (ExpenseList.Count == 0)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
var CircleList = _circleLogic.ReadList(null);
|
||||||
|
if (CircleList == null)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (CircleList.Count == 0)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
Random rnd = new Random();
|
||||||
|
for (int i = 0; i < 2; i++)
|
||||||
|
{
|
||||||
|
_circleExpenseLogic.Create(new()
|
||||||
|
{
|
||||||
|
ExpenseId = rnd.Next(0, ExpenseList.Count),
|
||||||
|
CircleId = rnd.Next(0, CircleList.Count)
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,13 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace SchoolBusinessLogic.BusinessLogics
|
|
||||||
{
|
|
||||||
public class ReportLessonsLogic
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,51 +1,54 @@
|
|||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
|
using Microsoft.Identity.Client;
|
||||||
using SchoolContracts.BusinessLogicsContracts;
|
using SchoolContracts.BusinessLogicsContracts;
|
||||||
using SchoolContracts.StoragesContracts;
|
using SchoolContracts.StoragesContracts;
|
||||||
using SchoolContracts.ViewModels;
|
using SchoolContracts.ViewModels;
|
||||||
using System;
|
using SchoolDatabaseImplement.Models;
|
||||||
using System.Collections.Generic;
|
using SchoolDataModels.Models;
|
||||||
using System.Linq;
|
using SchoolContracts.BindingModel;
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace SchoolContracts.BusinessLogics
|
namespace SchoolContracts.BusinessLogics
|
||||||
{
|
{
|
||||||
public class ReportLogic : IReportLogic
|
public class ReportLogic : IReportLogic
|
||||||
{
|
{
|
||||||
private readonly ICircleStorage _circleStorage;
|
private readonly ICircleStorage _circleStorage;
|
||||||
|
private readonly ILogger _logger;
|
||||||
|
private readonly ICircleExpenseStorage _circleExpenseStorage;
|
||||||
|
|
||||||
private readonly IExpenseStorage _expenseStorage;
|
public ReportLogic(ILogger logger, ICircleStorage circleStorage,
|
||||||
/// <summary>
|
ICircleExpenseStorage circleExpenseStorage)
|
||||||
/// Получение списка кружков с указанием списка затрат по ним
|
|
||||||
/// </summary>
|
|
||||||
/// <returns></returns>
|
|
||||||
public List<ReportViewModel> GetCircles()
|
|
||||||
{
|
{
|
||||||
var expenses = _expenseStorage.GetFullList();
|
_logger = logger;
|
||||||
var circles = _circleStorage.GetFullList();
|
_circleStorage = circleStorage;
|
||||||
var list = new List<ReportViewModel>();
|
_circleExpenseStorage = circleExpenseStorage;
|
||||||
foreach(var circle in circles)
|
|
||||||
{
|
|
||||||
var record = new ReportViewModel
|
|
||||||
{
|
|
||||||
CircleNumber = circle.Id,
|
|
||||||
Expenses = new List<ReportExpensesViewModel>(),
|
|
||||||
CircleCount = 0
|
|
||||||
|
|
||||||
};
|
|
||||||
foreach (var expense in expenses)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
list.Add(record);
|
|
||||||
}
|
|
||||||
return list;
|
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Получение списка занятий за определенный период
|
/// получение занятий по кружку
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="model"></param>
|
public List<ReportCircleLessonsViewModel> GetLessonCircles(ReportBindingModel model)
|
||||||
/// <returns></returns>
|
{
|
||||||
|
return _circleStorage.GetLessonCircles(new() { SelectedCirclesIds = model.SelectedCircles});
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// получение затрат кружку
|
||||||
|
/// </summary>
|
||||||
|
public List<ReportExpensesInCirclesViewModel> GetExpenses (ReportBindingModel model)
|
||||||
|
{
|
||||||
|
return _circleExpenseStorage.GetExpensesInCircles(new() { DateFrom = model.DateFrom, DateTo = model.DateTo });
|
||||||
|
}
|
||||||
|
public void SaveComponentsToWordFile(ReportBindingModel model)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SaveManufactureComponentToExcelFile(ReportBindingModel model)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SaveOrdersToPdfFile(ReportBindingModel model)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,6 @@ namespace SchoolContracts.BindingModel
|
|||||||
public DateTime DateStart { get; set; } = DateTime.Now;
|
public DateTime DateStart { get; set; } = DateTime.Now;
|
||||||
public int ClientId { get; set; }
|
public int ClientId { get; set; }
|
||||||
public int LessonId { get; set; }
|
public int LessonId { get; set; }
|
||||||
public double Remains { get; set; }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -12,5 +12,7 @@ namespace SchoolContracts.BindingModels
|
|||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
public double Sum { get; set;}
|
public double Sum { get; set;}
|
||||||
public string ExpenseName { get; set;}
|
public string ExpenseName { get; set;}
|
||||||
|
public int Count { get; set; }
|
||||||
|
public int EmployeeId { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,16 +12,16 @@ namespace SchoolContracts.BusinessLogicsContracts
|
|||||||
public interface IReportLogic
|
public interface IReportLogic
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Получение списка кружков
|
/// Получение списка кружков по занятиям
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
List<ReportCirclesViewModel> GetCircles(ReportBindingModel model);
|
List<ReportCircleLessonsViewModel> GetLessonCircles(ReportBindingModel model);
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Получение списка затрат за определенный период
|
/// Получение списка затрат за определенный период
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="model"></param>
|
/// <param name="model"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
//List<ReportOrdersViewModel> GetExpenses(ReportBindingModel model);
|
List<ReportExpensesInCirclesViewModel> GetExpenses(ReportBindingModel model);
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Сохранение компонент в файл-Word
|
/// Сохранение компонент в файл-Word
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -9,5 +9,7 @@ namespace SchoolContracts.SearchModel
|
|||||||
public class CircleExpenseSearchModel
|
public class CircleExpenseSearchModel
|
||||||
{
|
{
|
||||||
public int? Id { get; set; }
|
public int? Id { get; set; }
|
||||||
|
public DateTime? DateTo { get; set; }
|
||||||
|
public DateTime? DateFrom { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,5 +18,6 @@ namespace SchoolContracts.StoragesContracts
|
|||||||
CircleExpenseViewModel? Insert(CircleExpenseBindingModel model);
|
CircleExpenseViewModel? Insert(CircleExpenseBindingModel model);
|
||||||
CircleExpenseViewModel? Update(CircleExpenseBindingModel model);
|
CircleExpenseViewModel? Update(CircleExpenseBindingModel model);
|
||||||
CircleExpenseViewModel? Delete(CircleExpenseBindingModel model);
|
CircleExpenseViewModel? Delete(CircleExpenseBindingModel model);
|
||||||
|
List<ReportExpensesInCirclesViewModel> GetExpensesInCircles(CircleExpenseSearchModel model);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,5 +12,7 @@ namespace SchoolContracts.ViewModels
|
|||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
public string ExpenseName { get; set; }
|
public string ExpenseName { get; set; }
|
||||||
public double Sum { get; set; }
|
public double Sum { get; set; }
|
||||||
|
public int Count { get; set; }
|
||||||
|
public int EmployeeId { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,6 +18,6 @@ namespace SchoolContracts.ViewModels
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Занятия в кружке
|
/// Занятия в кружке
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public List<ReportLessonCirclesViewModel> CircleLessons { get; set; } = new();
|
public List<ReportLessonCirclesViewModel> Lessons { get; set; } = new();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,12 +7,18 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace SchoolContracts.ViewModels
|
namespace SchoolContracts.ViewModels
|
||||||
{
|
{
|
||||||
public class ReportExpensesViewModel
|
public class ReportExpensesInCirclesViewModel
|
||||||
{
|
{
|
||||||
[DisplayName("Название затраты")]
|
[DisplayName("Название затраты")]
|
||||||
public string ExpenseName { get; set; } = string.Empty;
|
public string ExpenseName { get; set; } = string.Empty;
|
||||||
[DisplayName("Сумма")]
|
[DisplayName("Сумма")]
|
||||||
public double Sum { get; set; }
|
public double Sum { get; set; }
|
||||||
|
[DisplayName("Номер кружка")]
|
||||||
|
public int CircleId { get; set; }
|
||||||
|
[DisplayName("Имя сотрудника")]
|
||||||
|
public string EmployeeName { get; set; }
|
||||||
|
[DisplayName("Кол-во затрат")]
|
||||||
|
public int Count { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -7,17 +7,21 @@ using System.Threading.Tasks;
|
|||||||
namespace SchoolContracts.ViewModels
|
namespace SchoolContracts.ViewModels
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Модель для получения всех занятий по кружку для отчета
|
/// Модель для получения одного занятия для отчета
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class ReportLessonCircleViewModel
|
public class ReportLessonCirclesViewModel
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Номер кружка
|
/// Номер занятия
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int CircleId { get; set; }
|
public int LessonId { get; set; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Занятия в кружке
|
/// Имя сотрудника
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public List<ReportCircleLessonsViewModel> CircleLessons { get; set; } = new();
|
public string EmployeeName{ get; set; } = string.Empty;
|
||||||
|
/// <summary>
|
||||||
|
/// Стоимость
|
||||||
|
/// </summary>
|
||||||
|
public double Sum { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,24 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.ComponentModel;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace SchoolContracts.ViewModels
|
|
||||||
{
|
|
||||||
public class ReportViewModel
|
|
||||||
{
|
|
||||||
[DisplayName("Имя кружка")]
|
|
||||||
public int CircleNumber { get; set; }
|
|
||||||
[DisplayName("Дата записи")]
|
|
||||||
public DateTime Date { get; set; }
|
|
||||||
[DisplayName("Сумма затрат")]
|
|
||||||
public double Sum { get; set; }
|
|
||||||
[DisplayName("Кол-во занятий")]
|
|
||||||
public int CircleCount { get; set; }
|
|
||||||
[DisplayName("Название затраты")]
|
|
||||||
public List<ReportExpensesViewModel> Expenses{ get; set; }
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
@ -7,7 +7,7 @@ using System.Threading.Tasks;
|
|||||||
namespace SchoolDataModels.Models
|
namespace SchoolDataModels.Models
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Затрата на кружок
|
/// Затраты
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public interface IExpenseModel : IId
|
public interface IExpenseModel : IId
|
||||||
{
|
{
|
||||||
@ -19,5 +19,13 @@ namespace SchoolDataModels.Models
|
|||||||
/// Название
|
/// Название
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string ExpenseName { get; }
|
public string ExpenseName { get; }
|
||||||
|
/// <summary>
|
||||||
|
/// количество
|
||||||
|
/// </summary>
|
||||||
|
public int Count { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// Id сотрудника
|
||||||
|
/// </summary>
|
||||||
|
public int EmployeeId { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -44,6 +44,27 @@ namespace SchoolDatabaseImplements.Implements
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<ReportExpensesInCirclesViewModel> GetExpensesInCircles(CircleExpenseSearchModel model)
|
||||||
|
{
|
||||||
|
if (model.DateFrom == null || model.DateTo == null)
|
||||||
|
{
|
||||||
|
return new();
|
||||||
|
}
|
||||||
|
using var context = new SchoolDatabase();
|
||||||
|
return context.CircleExpenses.Include(x => x.Circle)
|
||||||
|
.Include(x => x.Expense)
|
||||||
|
.ThenInclude(x => x.Employee)
|
||||||
|
.Select(x => new ReportExpensesInCirclesViewModel()
|
||||||
|
{
|
||||||
|
EmployeeName = x.Expense.Employee.EmployeeName,
|
||||||
|
CircleId = x.Circle.Id,
|
||||||
|
ExpenseName = x.Expense.ExpenseName,
|
||||||
|
Count = x.Expense.Count,
|
||||||
|
Sum= x.Expense.Sum
|
||||||
|
})
|
||||||
|
.ToList();
|
||||||
|
}
|
||||||
|
|
||||||
public List<CircleExpenseViewModel> GetFilteredList(CircleExpenseSearchModel model)
|
public List<CircleExpenseViewModel> GetFilteredList(CircleExpenseSearchModel model)
|
||||||
{
|
{
|
||||||
using var context = new SchoolDatabase();
|
using var context = new SchoolDatabase();
|
||||||
|
@ -26,22 +26,11 @@ namespace SchoolDatabaseImplement.Implements
|
|||||||
public List<CircleViewModel> GetFilteredList(CircleSearchModel model)
|
public List<CircleViewModel> GetFilteredList(CircleSearchModel model)
|
||||||
{
|
{
|
||||||
using var context = new SchoolDatabase();
|
using var context = new SchoolDatabase();
|
||||||
if (model.DateFrom.HasValue && model.DateTo.HasValue) // если не ищем по айдишнику, значит ищем по диапазону дат
|
|
||||||
{
|
|
||||||
return context.Circles
|
return context.Circles
|
||||||
.Where(x => model.DateFrom <= x.DateStart.Date && x.DateStart <= model.DateTo)
|
.Where(x => x.Id == model.Id)
|
||||||
.Include(x => x.Client)
|
.Include(x => x.Client)
|
||||||
.Select(x => x.GetViewModel)
|
.Select(x => x.GetViewModel)
|
||||||
.ToList();
|
.ToList();
|
||||||
}
|
|
||||||
if (model.ClientId.HasValue)
|
|
||||||
{
|
|
||||||
return context.Circles
|
|
||||||
.Where(x => x.Client.Id == model.ClientId)
|
|
||||||
.Select(x => x.GetViewModel)
|
|
||||||
.ToList();
|
|
||||||
}
|
|
||||||
return new();
|
|
||||||
}
|
}
|
||||||
public CircleViewModel? GetElement(CircleSearchModel model)
|
public CircleViewModel? GetElement(CircleSearchModel model)
|
||||||
{
|
{
|
||||||
@ -93,7 +82,11 @@ namespace SchoolDatabaseImplement.Implements
|
|||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Получение списка занятий по выбранному кружку
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="model"></param>
|
||||||
|
/// <returns></returns>
|
||||||
public List<ReportCircleLessonsViewModel> GetLessonCircles(CircleSearchModel model)
|
public List<ReportCircleLessonsViewModel> GetLessonCircles(CircleSearchModel model)
|
||||||
{
|
{
|
||||||
if (model.SelectedCirclesIds == null)
|
if (model.SelectedCirclesIds == null)
|
||||||
@ -102,26 +95,23 @@ namespace SchoolDatabaseImplement.Implements
|
|||||||
}
|
}
|
||||||
using var context = new SchoolDatabase();
|
using var context = new SchoolDatabase();
|
||||||
return context.Circles
|
return context.Circles
|
||||||
.Where(c => model.SelectedCirclesIds.Contains(c.Id))
|
.Where(x => model.SelectedCirclesIds.Contains(x.Id))
|
||||||
.Select(c => new ReportCircleLessonsViewModel()
|
.Select(x => new ReportCircleLessonsViewModel()
|
||||||
{
|
{
|
||||||
CircleLessons = GetCircleLessons(context, new() { Id = c.Id })
|
CircleId= x.Id,
|
||||||
})
|
Lessons = context.CircleLessons
|
||||||
.ToList();
|
.Include(x => x.Lesson)
|
||||||
}
|
.ThenInclude(x => x.Employee)
|
||||||
/// <summary>
|
.Where(x => x.CircleId == x.Id)
|
||||||
/// Получение списка занятий по выбранному кружку
|
.Select(x => new ReportLessonCirclesViewModel()
|
||||||
/// </summary>
|
{
|
||||||
/// <param name="model"></param>
|
|
||||||
/// <returns></returns>
|
LessonId = x.Circle.Id,
|
||||||
private static List<ReportLessonCirclesViewModel> GetCircleLessons(SchoolDatabase context, CircleSearchModel model)
|
EmployeeName = x.Lesson.Employee.EmployeeName,
|
||||||
{
|
Sum = x.Lesson.LessonPrice
|
||||||
return context.Circles
|
|
||||||
.Include(wir => wir.CircleLessons)
|
})
|
||||||
.Where(wir => wir.Id == model.Id)
|
.ToList()
|
||||||
.Select(wir => new ReportLessonCirclesViewModel()
|
|
||||||
{
|
|
||||||
LessonId = wir.CircleLessons.Id
|
|
||||||
})
|
})
|
||||||
.ToList();
|
.ToList();
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
using SchoolContracts.BindingModel;
|
using SchoolContracts.BindingModel;
|
||||||
using SchoolContracts.BindingModels;
|
using SchoolContracts.BindingModels;
|
||||||
using SchoolContracts.ViewModels;
|
using SchoolContracts.ViewModels;
|
||||||
|
using SchoolDataModels.Models;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
@ -11,7 +12,7 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace SchoolDatabaseImplement.Models
|
namespace SchoolDatabaseImplement.Models
|
||||||
{
|
{
|
||||||
public class CircleExpense
|
public class CircleExpense
|
||||||
{
|
{
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
[Required]
|
[Required]
|
||||||
|
@ -23,6 +23,8 @@ namespace SchoolDatabaseImplement.Models
|
|||||||
[Required]
|
[Required]
|
||||||
public string EmployeeName { get; set; } = string.Empty;
|
public string EmployeeName { get; set; } = string.Empty;
|
||||||
[ForeignKey("EmployeeId")]
|
[ForeignKey("EmployeeId")]
|
||||||
|
public virtual List<Expense> Expenses { get; set; } = new();
|
||||||
|
[ForeignKey("EmployeeId")]
|
||||||
public virtual List<Lesson> Lessons { get; set; } = new();
|
public virtual List<Lesson> Lessons { get; set; } = new();
|
||||||
public static Employee? Create(EmployeeBindingModel model)
|
public static Employee? Create(EmployeeBindingModel model)
|
||||||
{
|
{
|
||||||
@ -51,9 +53,13 @@ namespace SchoolDatabaseImplement.Models
|
|||||||
EmployeePhone = model.EmployeePhone;
|
EmployeePhone = model.EmployeePhone;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ExpenseViewModel GetViewModel => new()
|
public EmployeeViewModel GetViewModel => new()
|
||||||
{
|
{
|
||||||
Id = Id
|
Id = Id,
|
||||||
|
EmployeeName = EmployeeName,
|
||||||
|
EmployeeEmail = EmployeeEmail,
|
||||||
|
EmployeePassword = EmployeePassword,
|
||||||
|
EmployeePhone = EmployeePhone
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,9 +18,15 @@ namespace SchoolDatabaseImplement.Models
|
|||||||
public string ExpenseName { get; private set; } = string.Empty;
|
public string ExpenseName { get; private set; } = string.Empty;
|
||||||
[Required]
|
[Required]
|
||||||
public double Sum { get; private set; }
|
public double Sum { get; private set; }
|
||||||
|
[Required]
|
||||||
|
public int Count { get; private set; }
|
||||||
|
public int EmployeeId { get; private set; }
|
||||||
|
public int CircleId { get; private set; }
|
||||||
[ForeignKey("ExpenseId")]
|
[ForeignKey("ExpenseId")]
|
||||||
public virtual List<CircleExpense> CircleExpenses { get; set; } = new();
|
public virtual List<CircleExpense> CircleExpenses { get; set; } = new();
|
||||||
public static Expense? Create(ExpenseBindingModel model)
|
[ForeignKey("ExpenseId")]
|
||||||
|
public virtual Employee Employee { get; set; } = new();
|
||||||
|
public static Expense? Create(SchoolDatabase context, ExpenseBindingModel model)
|
||||||
{
|
{
|
||||||
if (model == null)
|
if (model == null)
|
||||||
{
|
{
|
||||||
@ -30,7 +36,9 @@ namespace SchoolDatabaseImplement.Models
|
|||||||
{
|
{
|
||||||
Id = model.Id,
|
Id = model.Id,
|
||||||
ExpenseName = model.ExpenseName,
|
ExpenseName = model.ExpenseName,
|
||||||
Sum = model.Sum
|
Sum = model.Sum,
|
||||||
|
Count = model.Count,
|
||||||
|
Employee = context.Employees.First(x => x.Id == model.EmployeeId)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
public void Update(ExpenseBindingModel model)
|
public void Update(ExpenseBindingModel model)
|
||||||
|
Loading…
Reference in New Issue
Block a user