From 677190ee63654ba3cee3a4c1f5b427b71fffcf29 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9F=D0=BE=D0=BB=D0=B8=D0=BD=D0=B0=20=D0=A7=D1=83=D0=B1?= =?UTF-8?q?=D1=8B=D0=BA=D0=B8=D0=BD=D0=B0?= Date: Sun, 19 May 2024 12:15:07 +0400 Subject: [PATCH] =?UTF-8?q?=D0=BD=D0=B0=D1=87=D0=B0=D0=BB=D0=BE=20=D1=80?= =?UTF-8?q?=D0=B0=D0=B1=D0=BE=D1=82=D1=8B=20=D0=BD=D0=B0=D0=B4=20=D0=BB?= =?UTF-8?q?=D0=B0=D0=B1=D0=BE=D0=B9=208?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Attributes/ColumnAttribute.cs | 26 ++++++++++++++++++ .../Attributes/GridViewAutoSize.cs | 27 +++++++++++++++++++ .../ViewModels/ClientViewModel.cs | 8 +++--- .../ViewModels/ComponentViewModel.cs | 6 +++-- .../ViewModels/ImplementerViewModel.cs | 12 +++++---- .../ViewModels/MessageInfoViewModel.cs | 16 +++++++---- .../ViewModels/PastryViewModel.cs | 6 +++-- .../Models/IMessageInfoModel.cs | 2 +- 8 files changed, 85 insertions(+), 18 deletions(-) create mode 100644 Confectionery/ConfectionaryContracts/Attributes/ColumnAttribute.cs create mode 100644 Confectionery/ConfectionaryContracts/Attributes/GridViewAutoSize.cs diff --git a/Confectionery/ConfectionaryContracts/Attributes/ColumnAttribute.cs b/Confectionery/ConfectionaryContracts/Attributes/ColumnAttribute.cs new file mode 100644 index 0000000..d9b6220 --- /dev/null +++ b/Confectionery/ConfectionaryContracts/Attributes/ColumnAttribute.cs @@ -0,0 +1,26 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConfectioneryContracts.Attributes +{ + [AttributeUsage(AttributeTargets.Property)] + public class ColumnAttribute : Attribute + { + public ColumnAttribute(string title = "", bool visible = true, int width = 0, GridViewAutoSize gridViewAutoSize = GridViewAutoSize.None, bool isUseAutoSize = false) + { + Title = title; + Visible = visible; + Width = width; + GridViewAutoSize = gridViewAutoSize; + IsUseAutoSize = isUseAutoSize; + } + public string Title { get; private set; } + public bool Visible { get; private set; } + public int Width { get; private set; } + public GridViewAutoSize GridViewAutoSize { get; private set; } + public bool IsUseAutoSize { get; private set; } + }s +} diff --git a/Confectionery/ConfectionaryContracts/Attributes/GridViewAutoSize.cs b/Confectionery/ConfectionaryContracts/Attributes/GridViewAutoSize.cs new file mode 100644 index 0000000..a7d7365 --- /dev/null +++ b/Confectionery/ConfectionaryContracts/Attributes/GridViewAutoSize.cs @@ -0,0 +1,27 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConfectioneryContracts.Attributes +{ + public enum GridViewAutoSize + { + NotSet = 0, + + None = 1, + + ColumnHeader = 2, + + AllCellsExceptHeader = 4, + + AllCells = 6, + + DisplayedCellsExceptHeader = 8, + + DisplayedCells = 10, + + Fill = 16 + } +} diff --git a/Confectionery/ConfectionaryContracts/ViewModels/ClientViewModel.cs b/Confectionery/ConfectionaryContracts/ViewModels/ClientViewModel.cs index ad7ba69..847ced1 100644 --- a/Confectionery/ConfectionaryContracts/ViewModels/ClientViewModel.cs +++ b/Confectionery/ConfectionaryContracts/ViewModels/ClientViewModel.cs @@ -5,17 +5,19 @@ using System.Text; using System.Threading.Tasks; using ConfectioneryDataModels.Models; using System.ComponentModel; +using ConfectioneryContracts.Attributes; namespace ConfectioneryContracts.ViewModels { public class ClientViewModel : IClientModel { + [Column(visible: false)] public int Id { get; set; } - [DisplayName("ФИО клиента")] + [Column(title: "ФИО клиента", width: 150)] public string ClientFIO { get; set; } = string.Empty; - [DisplayName("Логин (эл. почта)")] + [Column(title: "Логин (эл. почта)", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)] public string Email { get; set; } = string.Empty; - [DisplayName("Пароль")] + [Column(title: "Пароль", width: 150)] public string Password { get; set; } = string.Empty; } } diff --git a/Confectionery/ConfectionaryContracts/ViewModels/ComponentViewModel.cs b/Confectionery/ConfectionaryContracts/ViewModels/ComponentViewModel.cs index c0c7c2a..698bbf0 100644 --- a/Confectionery/ConfectionaryContracts/ViewModels/ComponentViewModel.cs +++ b/Confectionery/ConfectionaryContracts/ViewModels/ComponentViewModel.cs @@ -5,15 +5,17 @@ using System.Text; using System.Threading.Tasks; using ConfectioneryDataModels.Models; using System.ComponentModel; +using ConfectioneryContracts.Attributes; namespace ConfectioneryContracts.ViewModels { public class ComponentViewModel : IComponentModel { + [Column(visible: false)] public int Id { get; set; } - [DisplayName("Название компонента")] + [Column(title: "Название компонента", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)] public string ComponentName { get; set; } = string.Empty; - [DisplayName("Цена")] + [Column(title: "Цена", width: 150)] public double Cost { get; set; } } } diff --git a/Confectionery/ConfectionaryContracts/ViewModels/ImplementerViewModel.cs b/Confectionery/ConfectionaryContracts/ViewModels/ImplementerViewModel.cs index 8b63f11..129f0f8 100644 --- a/Confectionery/ConfectionaryContracts/ViewModels/ImplementerViewModel.cs +++ b/Confectionery/ConfectionaryContracts/ViewModels/ImplementerViewModel.cs @@ -1,4 +1,5 @@ -using ConfectioneryDataModels.Models; +using ConfectioneryContracts.Attributes; +using ConfectioneryDataModels.Models; using System; using System.Collections.Generic; using System.ComponentModel; @@ -10,18 +11,19 @@ namespace ConfectioneryContracts.ViewModels { public class ImplementerViewModel : IImplementerModel { + [Column(visible: false)] public int Id { get; set; } - [DisplayName("ФИО исполнителя")] + [Column(title: "ФИО исполнителя", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)] public string ImplementerFIO { get; set; } = string.Empty; - [DisplayName("Пароль")] + [Column(title: "Пароль", width: 100)] public string Password { get; set; } = string.Empty; - [DisplayName("Стаж работы")] + [Column(title: "Стаж работы", width: 100)] public int WorkExperience { get; set; } - [DisplayName("Квалификация")] + [Column(title: "Квалификация", width: 100)] public int Qualification { get; set; } } } diff --git a/Confectionery/ConfectionaryContracts/ViewModels/MessageInfoViewModel.cs b/Confectionery/ConfectionaryContracts/ViewModels/MessageInfoViewModel.cs index 0924d66..92daf52 100644 --- a/Confectionery/ConfectionaryContracts/ViewModels/MessageInfoViewModel.cs +++ b/Confectionery/ConfectionaryContracts/ViewModels/MessageInfoViewModel.cs @@ -1,24 +1,30 @@ -using ConfectioneryDataModels.Models; +using ConfectioneryContracts.Attributes; +using ConfectioneryDataModels.Models; using System.ComponentModel; namespace ConfectioneryContracts.ViewModels { public class MessageInfoViewModel : IMessageInfoModel { + [Column(visible: false)] + public int Id { get; set; } + + [Column(visible: false)] public string MessageId { get; set; } = string.Empty; + [Column(visible: false)] public int? ClientId { get; set; } - [DisplayName("Отправитель")] + [Column(title: "Отправитель", width: 150)] public string SenderName { get; set; } = string.Empty; - [DisplayName("Дата письма")] + [Column(title: "Дата письма", width: 120)] public DateTime DateDelivery { get; set; } - [DisplayName("Заголовок")] + [Column(title: "Дата письма", width: 150)] public string Subject { get; set; } = string.Empty; - [DisplayName("Текст")] + [Column(title: "Текст", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)] public string Body { get; set; } = string.Empty; } } \ No newline at end of file diff --git a/Confectionery/ConfectionaryContracts/ViewModels/PastryViewModel.cs b/Confectionery/ConfectionaryContracts/ViewModels/PastryViewModel.cs index 11fc7c4..fdf7ca8 100644 --- a/Confectionery/ConfectionaryContracts/ViewModels/PastryViewModel.cs +++ b/Confectionery/ConfectionaryContracts/ViewModels/PastryViewModel.cs @@ -5,15 +5,17 @@ using System.Text; using System.Threading.Tasks; using ConfectioneryDataModels.Models; using System.ComponentModel; +using ConfectioneryContracts.Attributes; namespace ConfectioneryContracts.ViewModels { public class PastryViewModel : IPastryModel { + [Column(visible: false)] public int Id { get; set; } - [DisplayName("Название визделия")] + [Column(title: "Название выпечки", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)] public string PastryName { get; set; } = string.Empty; - [DisplayName("Цена")] + [Column(title: "Цена", width: 150)] public double Price { get; set; } public Dictionary PastryComponents { diff --git a/Confectionery/ConfectionaryDataModels/Models/IMessageInfoModel.cs b/Confectionery/ConfectionaryDataModels/Models/IMessageInfoModel.cs index eedf7cc..62a8da3 100644 --- a/Confectionery/ConfectionaryDataModels/Models/IMessageInfoModel.cs +++ b/Confectionery/ConfectionaryDataModels/Models/IMessageInfoModel.cs @@ -6,7 +6,7 @@ using System.Threading.Tasks; namespace ConfectioneryDataModels.Models { - public interface IMessageInfoModel + public interface IMessageInfoModel : IId { string MessageId { get; }