48 lines
1.4 KiB
C#
48 lines
1.4 KiB
C#
using System.ComponentModel;
|
|
|
|
namespace LDBproject.Entities;
|
|
|
|
public class Order
|
|
{
|
|
public int OrderID { get; private set; }
|
|
[Browsable(false)]
|
|
public int CardID { get; private set; }
|
|
[Browsable(false)]
|
|
public int LibrarianID { get; private set; }
|
|
[DisplayName("Reader")]
|
|
public string ReaderName { get; private set; } = string.Empty;
|
|
[DisplayName("Librarian")]
|
|
public string EmployeeName { get; private set; } = string.Empty;
|
|
|
|
[DisplayName("Book")]
|
|
public string BookInfo { get; private set; } = string.Empty;
|
|
|
|
[DisplayName("Date of borrow")]
|
|
public DateTime BorrowDate { get; private set; }
|
|
[DisplayName("List of borrowed books")]
|
|
public string BookList => Registrations != null ? string.Join(", ", Registrations.Select(x => $"{x.BookID} {x.Note}")) : string.Empty;
|
|
[Browsable(false)]
|
|
public IEnumerable<Registration> Registrations { get; set; } = [];
|
|
|
|
public static Order NewOrder(
|
|
int orderIndex, int ticketIndex, int librarian, IEnumerable<Registration> list, DateTime borrow)
|
|
{
|
|
return new Order
|
|
{
|
|
OrderID = orderIndex,
|
|
CardID = ticketIndex,
|
|
LibrarianID = librarian,
|
|
Registrations = list,
|
|
BorrowDate = borrow
|
|
};
|
|
}
|
|
|
|
public void SetRegs(IEnumerable<Registration> regs)
|
|
{
|
|
if (regs != null && regs.Any())
|
|
{
|
|
Registrations = regs;
|
|
}
|
|
}
|
|
}
|