fix
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
namespace MyOffice.Web.Models.Account
|
||||
{
|
||||
using Data.Models.Accounts;
|
||||
using User;
|
||||
|
||||
public class AccessRightsViewModel
|
||||
{
|
||||
public UserViewModel User { get; set; } = null!;
|
||||
public bool IsAllowRead { get; set; }
|
||||
public bool IsAllowWrite { get; set; }
|
||||
public bool IsAllowManage { get; set; }
|
||||
}
|
||||
|
||||
public static class AccessRightsViewModelExtensions
|
||||
{
|
||||
public static AccessRightsViewModel ToModel(this AccountAccess accountAccess)
|
||||
{
|
||||
return new AccessRightsViewModel
|
||||
{
|
||||
User = accountAccess.User!.ToModel(),
|
||||
IsAllowManage = accountAccess.IsAllowManage,
|
||||
IsAllowRead = accountAccess.IsAllowRead,
|
||||
IsAllowWrite = accountAccess.IsAllowWrite,
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
namespace MyOffice.Web.Models.Account
|
||||
{
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using Core.Extensions;
|
||||
using Data.Models.Accounts;
|
||||
|
||||
public class MotionCategoryViewModel
|
||||
{
|
||||
public string? Id { get; set; }
|
||||
|
||||
[Required]
|
||||
public string? Name { get; set; }
|
||||
|
||||
public bool? AllowDelete { get; set; }
|
||||
}
|
||||
|
||||
public static class AccountCategoryViewModelExtensions
|
||||
{
|
||||
public static MotionCategoryViewModel ToModel(this AccountCategory input)
|
||||
{
|
||||
return new MotionCategoryViewModel
|
||||
{
|
||||
Id = input.Id.ToShort(),
|
||||
Name = input.Name,
|
||||
AllowDelete = !input.Accounts?.Any(),
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
namespace MyOffice.Web.Models.Account;
|
||||
|
||||
using Data.Models.Accounts;
|
||||
|
||||
public class AccountDetailedViewModel
|
||||
{
|
||||
public AccountViewModel Account { get; set; } = null!;
|
||||
public decimal Rest { get; set; }
|
||||
}
|
||||
|
||||
public static class AccountDetailedViewModelExtensions
|
||||
{
|
||||
public static AccountDetailedViewModel ToModel(this AccountDetailed input)
|
||||
{
|
||||
return new AccountDetailedViewModel
|
||||
{
|
||||
Account = input.Account.ToModel(),
|
||||
Rest = input.Rest,
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
namespace MyOffice.Web.Models.Account;
|
||||
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
public class AccountEditRequestModel
|
||||
{
|
||||
[Required]
|
||||
public string Name { get; set; } = null!;
|
||||
[Required]
|
||||
public string CurrencyId { get; set; } = null!;
|
||||
public string? CategoryId { get; set; } = null!;
|
||||
public string? UserId { get; set; } = null!;
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
namespace MyOffice.Web.Models.Account
|
||||
{
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using Core.Extensions;
|
||||
using Data.Models.Accounts;
|
||||
using User;
|
||||
|
||||
public class AccountViewModel
|
||||
{
|
||||
public string? Id { get; set; }
|
||||
|
||||
[Required]
|
||||
public string Name { get; set; } = null!;
|
||||
|
||||
[Required]
|
||||
public string CurrencyId { get; set; } = null!;
|
||||
public string? CurrencyName { get; set; }
|
||||
|
||||
public List<MotionCategoryViewModel>? Categories { get; set; }
|
||||
|
||||
[Required]
|
||||
public string CategoryId { get; set; } = null!;
|
||||
|
||||
public List<AccessRightsViewModel>? AccessRights { get; set; }
|
||||
}
|
||||
|
||||
public static class AccountViewModelExtensions
|
||||
{
|
||||
public static AccountViewModel ToModel(this Account input)
|
||||
{
|
||||
return new AccountViewModel
|
||||
{
|
||||
Id = input.Id.ToShort(),
|
||||
Name = input.Name,
|
||||
CurrencyId = input.CurrencyGlobalId,
|
||||
CurrencyName = input.CurrencyGlobal!.Name,
|
||||
Categories = input.Categories!
|
||||
.Select(x => x.Category!.ToModel())
|
||||
.ToList(),
|
||||
AccessRights = input.AccessRights!
|
||||
.Select(x => x.ToModel())
|
||||
.ToList(),
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user