fix
This commit is contained in:
@@ -1,9 +1,7 @@
|
||||
namespace MyOffice.Web.Models.Item
|
||||
{
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using MyOffice.Core.Extensions;
|
||||
using MyOffice.Data.Models.Items;
|
||||
using MyOffice.Migrations.Postgres.Migrations;
|
||||
using Services.Account.Domain;
|
||||
|
||||
public class ItemCategoryViewModel
|
||||
{
|
||||
@@ -14,32 +12,20 @@
|
||||
|
||||
public bool AllowDelete { get; set; }
|
||||
public int SortOrder { get; set; }
|
||||
public bool IsInternal { get; set; }
|
||||
public bool Internal { 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,
|
||||
IsInternal = input.IsInternal,
|
||||
SortOrder = input.Id == input.UserId ? 1 : 0
|
||||
};
|
||||
}
|
||||
|
||||
public static ItemCategory FromModel(this ItemCategoryViewModel input)
|
||||
public static ItemCategoryDto FromModel(this ItemCategoryViewModel input)
|
||||
{
|
||||
if (input == null)
|
||||
throw new ArgumentNullException(nameof(input));
|
||||
|
||||
return new ItemCategory
|
||||
return new ItemCategoryDto
|
||||
{
|
||||
Name = input.Name,
|
||||
IsInternal = input.IsInternal,
|
||||
IsInternal = input.Internal,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user