refactoring

This commit is contained in:
2023-06-22 10:01:27 +03:00
parent e9d4053e65
commit d549877567
116 changed files with 1216 additions and 11709 deletions
@@ -1,33 +0,0 @@
namespace MyOffice.Web.Models.Motion
{
using System.ComponentModel.DataAnnotations;
using Core.Extensions;
using Data.Models.Accounts;
using MyOffice.Data.Models.Motions;
public class AccountMotionViewModel
{
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 AccountMotionViewModelExtensions
{
public static AccountMotionViewModel ToModel(this AccountMotion input)
{
return new AccountMotionViewModel
{
Id = input.Id.ToShort(),
Date = input.DateTime,
Motion = input.Motion.MotionGlobal.Name,
Description = input.Description,
Plus = input.AmountPlus,
Minus = input.AmountMinus,
};
}
}
}
@@ -1,12 +0,0 @@
namespace MyOffice.Web.Models.Motion
{
using System.ComponentModel.DataAnnotations;
public class AccountMotionsGetModel
{
[Required]
public DateTime From { get; set; }
[Required]
public DateTime To { get; set; }
}
}
@@ -1,33 +0,0 @@
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
};
}
}
}
@@ -1,8 +0,0 @@
namespace MyOffice.Web.Models.Motion
{
public class MotionEditModel
{
public string Id { get; set; } = null!;
public string Category { get; set; } = null!;
}
}
@@ -0,0 +1,27 @@
namespace MyOffice.Web.Models.Motion;
using MyOffice.Services.Account.Domain;
public class MotionRequest
{
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 MotionRequestExtension
{
public static MotionAdd FromModel(this MotionRequest input)
{
return new MotionAdd
{
Date = input.Date,
Motion = input.Motion,
Minus = input.Minus ?? 0,
Plus = input.Plus ?? 0,
Description = input.Description,
};
}
}
+15 -17
View File
@@ -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,
};
}
}