refactoring

This commit is contained in:
2023-06-22 10:01:27 +03:00
parent e9d4053e65
commit d549877567
116 changed files with 1216 additions and 11709 deletions
@@ -0,0 +1,31 @@
namespace MyOffice.Web.Models.Item
{
using System.ComponentModel.DataAnnotations;
using MyOffice.Core.Extensions;
using MyOffice.Data.Models.Items;
public class ItemCategoryViewModel
{
public string? Id { get; set; }
[Required]
public string? Name { get; set; }
public bool AllowDelete { get; set; }
public int SortOrder { get; set; }
}
public static class ItemCategoryViewModelExtensions
{
public static ItemCategoryViewModel ToModel(this ItemCategory input)
{
return new ItemCategoryViewModel
{
Id = input.Id.ToShort(),
Name = input.Name,
AllowDelete = !input.Items.Any() && input.Id != input.UserId,
SortOrder = input.Id == input.UserId ? 1 : 0
};
}
}
}
@@ -0,0 +1,8 @@
namespace MyOffice.Web.Models.Item
{
public class ItemEditModel
{
public string Id { get; set; } = null!;
public string Category { get; set; } = null!;
}
}
+33
View File
@@ -0,0 +1,33 @@
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(),
};
}
}
}