fix
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
namespace MyOffice.Web.Models.Motion
|
||||
{
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using Core.Extensions;
|
||||
using Data.Models.Accounts;
|
||||
using MyOffice.Data.Models.Motions;
|
||||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||
|
||||
public class MotionCategoryViewModel
|
||||
{
|
||||
public string? Id { get; set; }
|
||||
|
||||
[Required]
|
||||
public string? Name { get; set; }
|
||||
|
||||
public bool AllowDelete { get; set; }
|
||||
public int SortOrder { get; set; }
|
||||
}
|
||||
|
||||
public static class MotionCategoryViewModelExtensions
|
||||
{
|
||||
public static MotionCategoryViewModel ToModel(this MotionCategory input)
|
||||
{
|
||||
return new MotionCategoryViewModel
|
||||
{
|
||||
Id = input.Id.ToShort(),
|
||||
Name = input.Name,
|
||||
AllowDelete = !input.Motions.Any() && input.Id != input.UserId,
|
||||
SortOrder = input.Id == input.UserId ? 1 : 0
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
namespace MyOffice.Web.Models.Motion
|
||||
{
|
||||
public class MotionEditModel
|
||||
{
|
||||
public string Id { get; set; } = null!;
|
||||
public string Category { get; set; } = null!;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
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(),
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user