Files
myoffice/MyOffice.Web/Models/Motion/MotionViewModel.cs
T
2023-06-17 14:16:09 +03:00

34 lines
779 B
C#

namespace MyOffice.Web.Models.Motion
{
using System.ComponentModel.DataAnnotations;
using Core.Extensions;
using MyOffice.Data.Models.Motions;
public class MotionViewModel
{
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 MotionViewModelExtensions
{
public static MotionViewModel ToModel(this MotionAccount input)
{
return new MotionViewModel
{
Id = input.MotionGlobalId.ToShort(),
CategoryId = input.Category.Id.ToShort(),
Category = input.Category.Name,
Name = input.MotionGlobal.Name,
AllowDelete = !input.Motions.Any(),
};
}
}
}