This commit is contained in:
2023-07-31 08:50:05 +03:00
parent cca943f37d
commit c5d9ae7b93
49 changed files with 546 additions and 398 deletions
+12 -31
View File
@@ -1,36 +1,17 @@
namespace MyOffice.Web.Models.Item
namespace MyOffice.Web.Models.Item;
using System.ComponentModel.DataAnnotations;
public class ItemViewModel : BaseViewModel
{
using System.ComponentModel.DataAnnotations;
using Data.Models.Accounts;
using MyOffice.Core.Extensions;
using MyOffice.Data.Models.Items;
public string? Id { get; set; }
[Required]
public string? Name { get; set; }
public class ItemViewModel
{
public string? Id { get; set; }
public bool AllowDelete { get; set; }
public string CategoryId { get; set; } = null!;
public string? Category { get; set; } = null!;
[Required]
public string? Name { get; set; }
public string CategoryId { get; set; } = null!;
public string? Category { get; set; } = null!;
public bool AllowDelete { get; set; }
public string? AccountId { get; set; }
}
public static class ItemViewModelExtensions
{
public static ItemViewModel ToModel(this Item input, Account? account = null)
{
return new ItemViewModel
{
Id = input.ItemGlobal.Id.ToShort(),
CategoryId = input.CategoryId.ToShort(),
Category = input.Category?.Name,
Name = input.ItemGlobal.Name,
AllowDelete = input.Motions != null && !input.Motions.Any(),
AccountId = account?.Id.ToShort(),
};
}
}
public string? AccountId { get; set; }
}