Зелёная книга

This commit is contained in:
Danil 2024-04-30 20:37:08 +04:00
parent c7d1606a5b
commit 2460c34822
14 changed files with 236 additions and 0 deletions

View File

@ -0,0 +1,15 @@
using UniversityDataModels;
namespace UniversityContracts.BindingModels
{
public class AccountBindingModel : IAccountModel
{
public int ClientByDisciplineId { get; set; }
public DateOnly DateOfAccount { get; set; } = DateOnly.FromDateTime(DateTime.Now);
public double Price { get; set; }
public int Id { get; set; }
}
}

View File

@ -0,0 +1,14 @@
using UniversityDataModels;
namespace UniversityContracts.BindingModels
{
public class ImplementerBindingModel : IImplementerModel
{
public int Id { get; set; }
public string FirstName { get; set; } = string.Empty;
public string LastName { get; set; } = string.Empty;
public string Login { get; set; } = string.Empty;
public string Password { get; set; } = string.Empty;
public string PhoneNumber { get; set; } = string.Empty;
}
}

View File

@ -0,0 +1,18 @@
using UniversityContracts.BindingModels;
using UniversityContracts.SearchModels;
using UniversityContracts.ViewModels;
namespace UniversityContracts.BusinessLogicContracts
{
public interface IAccountLogic
{
List<AccountViewModel> ReadList(AccountSearchModel model);
AccountViewModel ReadElement(AccountSearchModel model);
bool Create(AccountBindingModel model);
/// <summary>
/// Получение полной и оплаченной стоимости в бизнес логике, по клиенту и дисциплине
/// </summary>
bool GetAccountInfo(AccountSearchModel model, out double fullPrice, out double paidPrice);
}
}

View File

@ -0,0 +1,16 @@
using UniversityContracts.BindingModels;
using UniversityContracts.SearchModels;
using UniversityContracts.ViewModels;
namespace UniversityContracts.BusinessLogicContracts
{
public interface IDisciplineLogic
{
List<DisciplineViewModel> ReadList(DisciplineSearchModel? model = null);
DisciplineViewModel ReadElement(DisciplineSearchModel model);
bool Create(DisciplineBindingModel model);
bool Update(DisciplineBindingModel model);
bool Delete(DisciplineBindingModel model);
}
}

View File

@ -0,0 +1,12 @@
using UniversityContracts.BindingModels;
using UniversityContracts.SearchModels;
using UniversityContracts.ViewModels;
namespace UniversityContracts.BusinessLogicContracts
{
public interface IImplementerLogic
{
ImplementerViewModel ReadElement(ImplementerSearchModel model);
bool Create(ImplementerBindingModel model);
}
}

View File

@ -0,0 +1,13 @@
namespace UniversityContracts.SearchModels
{
public class AccountSearchModel
{
public int? Id { get; set; }
public int? ClientId { get; set; }
public int? DisciplineId { get; set; }
public DateOnly? DateFrom { get; set; }
public DateOnly? DateTo { get; set; }
}
}

View File

@ -0,0 +1,13 @@
namespace UniversityContracts.SearchModels
{
public class DisciplineSearchModel
{
public int? Id { get; set; }
public DateOnly? DateFrom { get; set; }
public DateOnly? DateTo { get; set; }
public List<int>? ClientsIds { get; set; }
public int? ImplementerId { get; set; }
}
}

View File

@ -0,0 +1,9 @@
namespace UniversityContracts.SearchModels
{
public class ImplementerSearchModel
{
public int? Id { get; set; }
public string? Login { get; set; }
public string? Password { get; set; }
}
}

View File

@ -0,0 +1,14 @@
using UniversityContracts.BindingModels;
using UniversityContracts.SearchModels;
using UniversityContracts.ViewModels;
namespace UniversityContracts.StoragesContracts
{
public interface IAccountStorage
{
List<AccountViewModel> GetFullList();
List<AccountViewModel> GetFilteredList(AccountSearchModel model);
AccountViewModel? GetElement(AccountSearchModel model);
AccountViewModel? Insert(AccountBindingModel model);
}
}

View File

@ -0,0 +1,18 @@
using UniversityContracts.BindingModels;
using UniversityContracts.SearchModels;
using UniversityContracts.ViewModels;
namespace UniversityContracts.StoragesContracts
{
public interface IDisciplineStorage
{
List<DisciplineViewModel> GetFullList();
List<DisciplineViewModel> GetFilteredList(DisciplineSearchModel model);
DisciplineViewModel? GetElement(DisciplineSearchModel model);
DisciplineViewModel? Insert(DisciplineBindingModel model);
DisciplineViewModel? Update(DisciplineBindingModel model);
DisciplineViewModel? Delete(DisciplineBindingModel model);
List<AccountViewModel> GetAccountsFromDisciplineAndClient(DisciplineSearchModel modelDiscipline, ClientSearchModel modelClient);
}
}

View File

@ -0,0 +1,12 @@
using UniversityContracts.BindingModels;
using UniversityContracts.SearchModels;
using UniversityContracts.ViewModels;
namespace UniversityContracts.StoragesContracts
{
public interface IImplementerStorage
{
ImplementerViewModel? GetElement(ImplementerSearchModel model);
ImplementerViewModel? Insert(ImplementerBindingModel model);
}
}

View File

@ -0,0 +1,21 @@
using UniversityDataModels;
using System.ComponentModel;
using UniversityDataModels.ProxyModels;
namespace UniversityContracts.ViewModels
{
public class AccountViewModel : IAccountModel
{
public int Id { get; set; }
public int ClientByDisciplineId { get; set; }
public DateOnly DateOfAccount { get; set; } = DateOnly.FromDateTime(DateTime.Now);
public double Price { get; set; }
public ClientByDisciplineModel ClientByDiscipline { get; set; }
public ClientViewModel? Client { get; set; }
public DisciplineViewModel? Discipline { get; set; }
}
}

View File

@ -0,0 +1,45 @@
using UniversityDataModels;
using System.ComponentModel;
using System.Text;
using UniversityDataModels.ProxyModels;
namespace UniversityContracts.ViewModels
{
public class DisciplineViewModel : IDisciplineModel
{
public int Id { get; set; }
public int ImplementerId { get; set; }
public string Name { get; set; } = string.Empty;
public double Price { get; set; }
[DisplayName("Логин клиента")]
public string DirectorLogin { get; set; } = string.Empty;
[DisplayName("Дата получения")]
public DateOnly DateOfReceipt { get; set; } = DateOnly.FromDateTime(DateTime.Now);
[DisplayName("Дата прохождения")]
public DateOnly DateOfPassage { get; set; } = DateOnly.FromDateTime(DateTime.Now);
public Dictionary<int, ClientByDisciplineModel> ClientsModel { get; set; } = new();
public List<RequirementViewModel> RequirementViewModels { get; set; } = new();
public List<ClientViewModel> ClientViewModels { get; set; } = new();
/// <summary>
/// Для отчета по моделям
/// </summary>
/// <returns></returns>
public override string ToString()
{
var result = new StringBuilder(
$"Дисциплина {Name}, созданная {DateOfReceipt}, " +
$"дата обучения {DateOfPassage}, включает в себя группу студентов:");
for (int i = 0; i < ClientViewModels.Count; i++)
{
var discipline = ClientViewModels[i];
result.Append($"\n\t{i + 1}. {discipline.Name} на " +
$"{ClientsModel[discipline.Id].DateOfClient.ToShortDateString()}");
}
return result.ToString();
}
}
}

View File

@ -0,0 +1,16 @@
using UniversityDataModels;
using System.ComponentModel;
namespace UniversityContracts.ViewModels
{
public class ImplementerViewModel : IImplementerModel
{
public int Id { get; set; }
public string LastName { get; set; } = string.Empty;
public string FirstName { get; set; } = string.Empty;
public string Login { get; set; } = string.Empty;
public string Password { get; set; } = string.Empty;
public string PhoneNumber { get; set; } = string.Empty;
}
}