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(),
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
namespace MyOffice.Web.Models.AccountMotion;
|
||||
|
||||
using Data.Models.Accounts;
|
||||
|
||||
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 AccountMotion FromModel(this AccountMotionRequest input)
|
||||
{
|
||||
/*return new AccountMotion
|
||||
{
|
||||
CreatedOn = input.Date,
|
||||
mo
|
||||
};*/
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
namespace MyOffice.Web.Models.Currency
|
||||
{
|
||||
public class CurrencyAddModel
|
||||
{
|
||||
public string Id { get; set; } = null!;
|
||||
public string Name { get; set; } = null!;
|
||||
public string ShortName { get; set; } = null!;
|
||||
public int Quantity { get; set; }
|
||||
public decimal Rate { get; set; }
|
||||
public DateTime RateDate { get; set; }
|
||||
}
|
||||
|
||||
public class CurrencyRateModel
|
||||
{
|
||||
public int Quantity { get; set; }
|
||||
public decimal Rate { get; set; }
|
||||
public DateTime RateDate { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
namespace MyOffice.Web.Models.Currency
|
||||
{
|
||||
using Data.Models.Currencies;
|
||||
using Microsoft.AspNetCore.Mvc.ModelBinding.Binders;
|
||||
|
||||
public class CurrencyGlobalViewModel
|
||||
{
|
||||
public string Id { get; set; } = null!;
|
||||
public string Name { get; set; } = null!;
|
||||
public int Quantity { get; set; }
|
||||
public string Symbol { get; set; } = null!;
|
||||
}
|
||||
|
||||
public static class CurrencyGlobalViewModelExtensions
|
||||
{
|
||||
public static CurrencyGlobalViewModel ToModel(this CurrencyGlobal input)
|
||||
{
|
||||
return new CurrencyGlobalViewModel
|
||||
{
|
||||
Id = input.Id,
|
||||
Name = input.Name,
|
||||
Quantity = input.DefaultQuantity,
|
||||
Symbol = input.Symbol,
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
namespace MyOffice.Web.Models.Currency
|
||||
{
|
||||
using Core.Extensions;
|
||||
using Data.Models.Currencies;
|
||||
using Microsoft.AspNetCore.Mvc.ModelBinding.Binders;
|
||||
|
||||
public class CurrencyViewModel
|
||||
{
|
||||
public string Id { get; set; } = null!;
|
||||
public string Code { get; set; } = null!;
|
||||
public string Name { get; set; } = null!;
|
||||
public decimal? Rate { get; set; }
|
||||
public int? Quantity { get; set; }
|
||||
public DateTime? RateDate { get; set; }
|
||||
}
|
||||
|
||||
public static class CurrencyViewModelExtensions
|
||||
{
|
||||
public static CurrencyViewModel ToModel(this Currency input, CurrencyRate? rate = null)
|
||||
{
|
||||
return new CurrencyViewModel
|
||||
{
|
||||
Id = input.Id.ToShort(),
|
||||
Code = input.CurrencyGlobal!.Id,
|
||||
Name = input.Name,
|
||||
Quantity = rate?.Quantity,
|
||||
Rate = rate?.Rate,
|
||||
RateDate = rate?.DateTime,
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
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,8 @@
|
||||
namespace MyOffice.Web.Models.Motion
|
||||
{
|
||||
public class MotionEditModel
|
||||
{
|
||||
public string Id { get; set; } = null!;
|
||||
public string Category { get; set; } = null!;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
namespace MyOffice.Web.Models.Motion
|
||||
{
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using Core.Extensions;
|
||||
using MyOffice.Data.Models.Motions;
|
||||
|
||||
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 static class MotionViewModelExtensions
|
||||
{
|
||||
public static MotionViewModel ToModel(this MotionAccount 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(),
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
namespace MyOffice.Web.Models.User
|
||||
{
|
||||
using Core.Extensions;
|
||||
using MyOffice.Data.Models.Users;
|
||||
|
||||
public class UserViewModel
|
||||
{
|
||||
public string Id { get; set; } = null!;
|
||||
public string UserName { get; set; } = null!;
|
||||
public string Email { get; set; } = null!;
|
||||
}
|
||||
|
||||
public static class UserViewModelExtensions
|
||||
{
|
||||
public static UserViewModel ToModel(this User user)
|
||||
{
|
||||
return new UserViewModel
|
||||
{
|
||||
Id = user.Id.ToShort(),
|
||||
UserName = user.UserName,
|
||||
Email = user.Email,
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user