refactoring
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
using Core.Extensions;
|
||||
using Data.Models.Accounts;
|
||||
|
||||
public class MotionCategoryViewModel
|
||||
public class AccountCategoryViewModel
|
||||
{
|
||||
public string? Id { get; set; }
|
||||
|
||||
@@ -16,9 +16,9 @@
|
||||
|
||||
public static class AccountCategoryViewModelExtensions
|
||||
{
|
||||
public static MotionCategoryViewModel ToModel(this AccountCategory input)
|
||||
public static AccountCategoryViewModel ToModel(this AccountCategory input)
|
||||
{
|
||||
return new MotionCategoryViewModel
|
||||
return new AccountCategoryViewModel
|
||||
{
|
||||
Id = input.Id.ToShort(),
|
||||
Name = input.Name,
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
namespace MyOffice.Web.Models.Motion
|
||||
namespace MyOffice.Web.Models.Account
|
||||
{
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using Core.Extensions;
|
||||
using Data.Models.Accounts;
|
||||
using User;
|
||||
|
||||
public class AccountViewModel
|
||||
{
|
||||
@@ -16,7 +15,7 @@
|
||||
public string CurrencyId { get; set; } = null!;
|
||||
public string? CurrencyName { get; set; }
|
||||
|
||||
public List<MotionCategoryViewModel>? Categories { get; set; }
|
||||
public List<AccountCategoryViewModel>? Categories { get; set; }
|
||||
|
||||
[Required]
|
||||
public string CategoryId { get; set; } = null!;
|
||||
|
||||
@@ -1,43 +0,0 @@
|
||||
namespace MyOffice.Web.Models.AccountMotion;
|
||||
|
||||
using Data.Models.Accounts;
|
||||
using Services.Account.Domain;
|
||||
|
||||
public class AccountMotionViewModel
|
||||
{
|
||||
public string? Id { get; set; }
|
||||
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 class AccountMotionRequest
|
||||
{
|
||||
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 AccountMotionViewModelExtension
|
||||
{
|
||||
}
|
||||
|
||||
public static class AccountMotionRequestExtension
|
||||
{
|
||||
public static AccountMotionAdd FromModel(this AccountMotionRequest input)
|
||||
{
|
||||
return new AccountMotionAdd
|
||||
{
|
||||
Date = input.Date,
|
||||
Motion = input.Motion,
|
||||
Minus = input.Minus ?? 0,
|
||||
Plus = input.Plus ?? 0,
|
||||
Description = input.Description,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
namespace MyOffice.Web.Models.Item
|
||||
{
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using MyOffice.Core.Extensions;
|
||||
using MyOffice.Data.Models.Items;
|
||||
|
||||
public class ItemCategoryViewModel
|
||||
{
|
||||
public string? Id { get; set; }
|
||||
|
||||
[Required]
|
||||
public string? Name { get; set; }
|
||||
|
||||
public bool AllowDelete { get; set; }
|
||||
public int SortOrder { 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,
|
||||
SortOrder = input.Id == input.UserId ? 1 : 0
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
namespace MyOffice.Web.Models.Motion
|
||||
namespace MyOffice.Web.Models.Item
|
||||
{
|
||||
public class MotionEditModel
|
||||
public class ItemEditModel
|
||||
{
|
||||
public string Id { get; set; } = null!;
|
||||
public string Category { get; set; } = null!;
|
||||
@@ -0,0 +1,33 @@
|
||||
namespace MyOffice.Web.Models.Item
|
||||
{
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using MyOffice.Core.Extensions;
|
||||
using MyOffice.Data.Models.Items;
|
||||
|
||||
public class ItemViewModel
|
||||
{
|
||||
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 static class ItemViewModelExtensions
|
||||
{
|
||||
public static ItemViewModel ToModel(this Item input)
|
||||
{
|
||||
return new ItemViewModel
|
||||
{
|
||||
Id = input.ItemGlobalId.ToShort(),
|
||||
CategoryId = input.Category.Id.ToShort(),
|
||||
Category = input.Category.Name,
|
||||
Name = input.ItemGlobal.Name,
|
||||
AllowDelete = !input.Motions.Any(),
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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,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
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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,
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -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