refactoring
This commit is contained in:
@@ -1,32 +1,30 @@
|
||||
namespace MyOffice.Web.Models.Motion
|
||||
namespace MyOffice.Web.Models.AccountMotion
|
||||
{
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using Core.Extensions;
|
||||
using MyOffice.Data.Models.Motions;
|
||||
using Data.Models.Accounts;
|
||||
|
||||
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 string Id { get; set; } = null!;
|
||||
public DateTime Date { get; set; }
|
||||
public string Motion { get; set; } = null!;
|
||||
public string? Description { get; set; }
|
||||
public decimal Plus { get; set; }
|
||||
public decimal Minus { get; set; }
|
||||
}
|
||||
|
||||
public static class MotionViewModelExtensions
|
||||
{
|
||||
public static MotionViewModel ToModel(this MotionAccount input)
|
||||
public static MotionViewModel ToModel(this Motion 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(),
|
||||
Id = input.Id.ToShort(),
|
||||
Date = input.DateTime,
|
||||
Motion = input.Item.ItemGlobal.Name,
|
||||
Description = input.Description,
|
||||
Plus = input.AmountPlus,
|
||||
Minus = input.AmountMinus,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user