34 lines
763 B
C#
34 lines
763 B
C#
namespace MyOffice.Web.Models.Item
|
|
{
|
|
using System.ComponentModel.DataAnnotations;
|
|
using MyOffice.Core.Extensions;
|
|
using MyOffice.Data.Models.Items;
|
|
|
|
public class ItemViewModel
|
|
{
|
|
public string? Id { get; set; }
|
|
|
|
public string CategoryId { get; set; } = null!;
|
|
public string Category { get; set; } = null!;
|
|
[Required]
|
|
public string? Name { get; set; }
|
|
|
|
public bool AllowDelete { get; set; }
|
|
}
|
|
|
|
public static class ItemViewModelExtensions
|
|
{
|
|
public static ItemViewModel ToModel(this Item input)
|
|
{
|
|
return new ItemViewModel
|
|
{
|
|
Id = input.ItemGlobalId.ToShort(),
|
|
CategoryId = input.Category.Id.ToShort(),
|
|
Category = input.Category.Name,
|
|
Name = input.ItemGlobal.Name,
|
|
AllowDelete = !input.Motions.Any(),
|
|
};
|
|
}
|
|
}
|
|
}
|