namespace MyOffice.Web.Models.Motion
{
	using Core.Extensions;
	using Data.Models.Accounts;

	public class MotionViewModel
	{
		public string Id { get; set; } = null!;
		public DateTime Date { get; set; }
		public string AccountId { get; set; } = null!;
		public string Item { 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 Motion input)
		{
			return new MotionViewModel
			{
				Id = input.Id.ToShort(),
				Date = input.DateTime,
				Item = input.Item.ItemGlobal.Name,
				Description = input.Description,
				Plus = input.AmountPlus,
				Minus = input.AmountMinus,
			};
		}
	}
}
