This commit is contained in:
2023-07-20 21:38:05 +03:00
parent 4bac59f322
commit 2f108bef4f
35 changed files with 1863 additions and 909 deletions
@@ -3,16 +3,18 @@
using System.ComponentModel.DataAnnotations;
using MyOffice.Core.Extensions;
using MyOffice.Data.Models.Items;
using MyOffice.Migrations.Postgres.Migrations;
public class ItemCategoryViewModel
{
public string? Id { get; set; }
[Required]
public string? Name { get; set; }
[Required]
public string Name { get; set; } = null!;
public bool AllowDelete { get; set; }
public int SortOrder { get; set; }
public bool IsInternal { get; set; }
}
public static class ItemCategoryViewModelExtensions
@@ -24,8 +26,21 @@
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)
{
if (input == null)
throw new ArgumentNullException(nameof(input));
return new ItemCategory
{
Name = input.Name,
IsInternal = input.IsInternal,
};
}
}
}