ViewModel were modified and Attribute enum + class were created.

This commit is contained in:
Yuee Shiness 2023-04-23 14:33:53 +04:00
parent b9fb91e4ff
commit d0d4333580
8 changed files with 99 additions and 29 deletions

View File

@ -0,0 +1,27 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DressAtelierContracts.Attributes
{
[AttributeUsage(AttributeTargets.Property)]
public class ColumnAttribute : Attribute
{
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; }
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;
}
}
}

View File

@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DressAtelierContracts.Attributes
{
public enum GridViewAutoSize
{
NotSet = 0,
None = 1,
ColumnHeader = 2,
AllCellsExceptHeader = 4,
AllCells = 6,
DisplayedCellsExceptHeader = 8,
DisplayedCells = 10,
Fill = 16
}
}

View File

@ -1,4 +1,5 @@
using DressAtelierDataModels.Models; using DressAtelierContracts.Attributes;
using DressAtelierDataModels.Models;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel; using System.ComponentModel;
@ -10,14 +11,16 @@ namespace DressAtelierContracts.ViewModels
{ {
public class ClientViewModel : IClientModel public class ClientViewModel : IClientModel
{ {
[Column(visible: false)]
public int ID { get; set; } public int ID { get; set; }
[DisplayName("Client's full name")]
[Column(title: "Client's full name", width: 150)]
public string FullName { get; set; } = string.Empty; public string FullName { get; set; } = string.Empty;
[DisplayName("Login")] [Column(title: "Login", gridViewAutoSize: GridViewAutoSize.Fill,isUseAutoSize: true)]
public string Email { get; set; } = string.Empty; public string Email { get; set; } = string.Empty;
[DisplayName("Password")] [Column(title:"Password", width: 150)]
public string Password { get; set; } = string.Empty; public string Password { get; set; } = string.Empty;
} }

View File

@ -1,4 +1,5 @@
using DressAtelierDataModels.Models; using DressAtelierContracts.Attributes;
using DressAtelierDataModels.Models;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel; using System.ComponentModel;
@ -10,14 +11,16 @@ namespace DressAtelierContracts.ViewModels
{ {
public class DressViewModel : IDressModel public class DressViewModel : IDressModel
{ {
[DisplayName("Name of dress")] [Column(title: "Name of dress", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)]
public string DressName { get; set; } = string.Empty; public string DressName { get; set; } = string.Empty;
[DisplayName("Cost")] [Column(title: "Cost", width: 100)]
public double Price { get; set; } public double Price { get; set; }
[Column(visible: false)]
public Dictionary<int, (IMaterialModel, int)> DressComponents { get; set; } = new(); public Dictionary<int, (IMaterialModel, int)> DressComponents { get; set; } = new();
[Column(visible: false)]
public int ID { get; set; } public int ID { get; set; }
} }
} }

View File

@ -1,4 +1,5 @@
using DressAtelierDataModels.Models; using DressAtelierContracts.Attributes;
using DressAtelierDataModels.Models;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel; using System.ComponentModel;
@ -10,14 +11,15 @@ namespace DressAtelierContracts.ViewModels
{ {
public class EmployeeViewModel : IEmployeeModel public class EmployeeViewModel : IEmployeeModel
{ {
[Column(visible: false)]
public int ID { get; set; } public int ID { get; set; }
[DisplayName("Employee's fullname")] [Column(title:"Employee's fullname",width: 150)]
public string FullName { get; set; } = string.Empty; public string FullName { get; set; } = string.Empty;
[DisplayName("Password")] [Column(title: "Password", width: 150)]
public string Password { get; set; } = string.Empty; public string Password { get; set; } = string.Empty;
[DisplayName("WorkExperience")] [Column(title: "WorkExperience", width: 50)]
public int WorkExperience { get; set; } public int WorkExperience { get; set; }
[DisplayName("Qualification")] [Column(title: "Qualification", width: 50)]
public int Qualification { get; set; } public int Qualification { get; set; }
} }
} }

View File

@ -5,16 +5,19 @@ using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.ComponentModel; using System.ComponentModel;
using DressAtelierContracts.Attributes;
namespace DressAtelierContracts.ViewModels namespace DressAtelierContracts.ViewModels
{ {
public class MaterialViewModel : IMaterialModel public class MaterialViewModel : IMaterialModel
{ {
[DisplayName("Name of component")] [Column(title: "Name of component", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)]
public string ComponentName { get; set; } = string.Empty; public string ComponentName { get; set; } = string.Empty;
[DisplayName("Cost")] [Column(title: "Cost", width: 100)]
public double Cost { get; set; } public double Cost { get; set; }
[Column(visible: false)]
public int ID { get; set; } public int ID { get; set; }
} }
} }

View File

@ -1,4 +1,5 @@
using DressAtelierDataModels.Models; using DressAtelierContracts.Attributes;
using DressAtelierDataModels.Models;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel; using System.ComponentModel;
@ -10,20 +11,22 @@ namespace DressAtelierContracts.ViewModels
{ {
public class MessageInfoViewModel : IMessageInfoModel public class MessageInfoViewModel : IMessageInfoModel
{ {
[Column(visible: false)]
public string ID { get; set; } = string.Empty; public string ID { get; set; } = string.Empty;
[Column(visible: false)]
public int? ClientID { get; set; } public int? ClientID { get; set; }
[DisplayName("Sender's name")] [Column(title: "Sender's name", width: 150)]
public string SenderName { get; set; } = string.Empty; public string SenderName { get; set; } = string.Empty;
[DisplayName("Delivery date")] [Column(title: "Delivery date", width: 150)]
public DateTime DeliveryDate { get; set; } public DateTime DeliveryDate { get; set; }
[DisplayName("Message subject")] [Column(title: "Message subject", width: 150)]
public string Subject { get; set; } = string.Empty; public string Subject { get; set; } = string.Empty;
[DisplayName("Message content")] [Column(title: "Message content", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)]
public string Body { get; set; } = string.Empty; public string Body { get; set; } = string.Empty;
} }
} }

View File

@ -1,4 +1,5 @@
using DressAtelierDataModels.Enums; using DressAtelierContracts.Attributes;
using DressAtelierDataModels.Enums;
using DressAtelierDataModels.Models; using DressAtelierDataModels.Models;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@ -11,32 +12,40 @@ namespace DressAtelierContracts.ViewModels
{ {
public class OrderViewModel : IOrderModel public class OrderViewModel : IOrderModel
{ {
[DisplayName("ID")] [Column(title: "ID", width: 50)]
public int ID { get; set; } public int ID { get; set; }
[Column(visible: false)]
public int DressID { get; set; } public int DressID { get; set; }
[Column(visible: false)]
public int ClientID { get; set; } public int ClientID { get; set; }
[DisplayName("Client's name")]
[Column(title:"Client's name", width: 150)]
public string ClientFullName { get; set; } = string.Empty; public string ClientFullName { get; set; } = string.Empty;
[Column(visible: false)]
public int? EmployeeID { get; set; } public int? EmployeeID { get; set; }
[DisplayName("Employee's name")]
[Column(title:"Employee's name", width: 150)]
public string? EmployeeFullName { get; set; } = string.Empty; public string? EmployeeFullName { get; set; } = string.Empty;
[DisplayName("DressName")] [Column(title: "DressName", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)]
public string DressName { get; set; } = string.Empty; public string DressName { get; set; } = string.Empty;
[DisplayName("Quantity")] [Column(title: "Quantity", width: 50)]
public int Count { get; set; } public int Count { get; set; }
[DisplayName("Overall price")] [Column(title: "Overall price", width: 50)]
public double Sum { get; set; } public double Sum { get; set; }
[DisplayName("Status")] [Column(title: "Status", width: 150)]
public OrderStatus Status { get; set; } = OrderStatus.Unknown; public OrderStatus Status { get; set; } = OrderStatus.Unknown;
[DisplayName("Date of creation")] [Column(title: "Date of creation", width: 150)]
public DateTime DateCreate { get; set; } = DateTime.Now; public DateTime DateCreate { get; set; } = DateTime.Now;
[DisplayName("Date of implementation")] [Column(title: "Date of implementation", width: 150)]
public DateTime? DateImplement { get; set; } public DateTime? DateImplement { get; set; }