fix
This commit is contained in:
@@ -1,5 +1,8 @@
|
||||
namespace MyOffice.Web.Models.Account;
|
||||
|
||||
using AutoMapper;
|
||||
using MyOffice.Services.Account.Domain;
|
||||
using MyOffice.Services.Identity;
|
||||
using User;
|
||||
|
||||
public class AccessRightsViewModel
|
||||
@@ -11,3 +14,28 @@ public class AccessRightsViewModel
|
||||
public bool AllowDelete { get; set; }
|
||||
public bool IsOwner { get; set; }
|
||||
}
|
||||
|
||||
public class AccessRightsViewModelProfile : Profile
|
||||
{
|
||||
public AccessRightsViewModelProfile()
|
||||
{
|
||||
CreateMap<AccountAccessDto, AccessRightsViewModel>()
|
||||
.AfterMap<AccessRightsViewModelMappingAction>()
|
||||
;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public class AccessRightsViewModelMappingAction : IMappingAction<AccountAccessDto, AccessRightsViewModel>
|
||||
{
|
||||
private readonly IContextProvider _contextProvider;
|
||||
|
||||
public AccessRightsViewModelMappingAction(IContextProvider contextProvider)
|
||||
{
|
||||
_contextProvider = contextProvider;
|
||||
}
|
||||
|
||||
public void Process(AccountAccessDto source, AccessRightsViewModel destination, ResolutionContext context)
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -1,13 +1,21 @@
|
||||
namespace MyOffice.Web.Models.Account;
|
||||
|
||||
using Core.Attributes;
|
||||
using Services.Account.Domain;
|
||||
using AutoMapper;
|
||||
using MyOffice.Services.Account.Domain;
|
||||
|
||||
[LinkFrom(typeof(AccountAccessInviteDto))]
|
||||
[LinkWith(typeof(AccountViewModelProfile))]
|
||||
public class AccountAccessInviteViewModel
|
||||
{
|
||||
public string? Id { get; set; }
|
||||
public string? Account { get; set; }
|
||||
public bool? AllowWrite { get; set; }
|
||||
}
|
||||
|
||||
public class AccountAccessInviteViewModelProfile: Profile
|
||||
{
|
||||
public AccountAccessInviteViewModelProfile()
|
||||
{
|
||||
CreateMap<AccountAccessInviteDto, AccountAccessInviteViewModel>()
|
||||
.ForMember(x => x.AllowWrite, o => o.MapFrom(x => x.IsAllowWrite))
|
||||
;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
using AutoMapper;
|
||||
using MyOffice.Services.Account.Domain;
|
||||
|
||||
namespace MyOffice.Web.Models.Account;
|
||||
|
||||
public class AccountAccessViewModel
|
||||
{
|
||||
public class AccountAccessItemViewModel
|
||||
{
|
||||
public string UserId { get; set; } = null!;
|
||||
public bool AllowWrite { get; set; }
|
||||
}
|
||||
|
||||
public string? Email { get; set; }
|
||||
public bool AllowWrite { get; set; }
|
||||
public List<AccountAccessItemViewModel> Accesses { get; set; } = null!;
|
||||
}
|
||||
|
||||
public class AccountAccessItemViewModelProfile : Profile
|
||||
{
|
||||
public AccountAccessItemViewModelProfile()
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,9 @@
|
||||
namespace MyOffice.Web.Models.Account;
|
||||
|
||||
using MyOffice.Core.Attributes;
|
||||
using MyOffice.Services.Account.Domain;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using AutoMapper;
|
||||
using MyOffice.Services.Account.Domain;
|
||||
|
||||
[Link(typeof(AccountCategoryDto))]
|
||||
public class AccountCategoryViewModel: IResponseModel
|
||||
{
|
||||
public string? Id { get; set; }
|
||||
@@ -13,4 +12,19 @@ public class AccountCategoryViewModel: IResponseModel
|
||||
public string? Name { get; set; }
|
||||
|
||||
public bool? AllowDelete { get; set; }
|
||||
}
|
||||
|
||||
public class AccountCategoryViewModelProfile: Profile
|
||||
{
|
||||
public AccountCategoryViewModelProfile()
|
||||
{
|
||||
CreateMap<AccountAccountCategoryDto, AccountCategoryViewModel>()
|
||||
.ForMember(x => x.Id, o => o.MapFrom(x => x.CategoryId))
|
||||
.ForMember(x => x.Name, o => o.MapFrom(x => x.Category!.Name))
|
||||
;
|
||||
CreateMap<AccountCategoryDto, AccountCategoryViewModel>()
|
||||
.ForMember(x => x.Id, o => o.MapFrom(x => x.Id))
|
||||
.ForMember(x => x.Name, o => o.MapFrom(x => x.Name))
|
||||
;
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,20 @@
|
||||
namespace MyOffice.Web.Models.Account;
|
||||
|
||||
using AutoMapper;
|
||||
using MyOffice.Services.Account.Domain;
|
||||
|
||||
public class AccountDetailedViewModel: BaseViewModel
|
||||
{
|
||||
public AccountViewModel Account { get; set; } = null!;
|
||||
public decimal Rest { get; set; }
|
||||
}
|
||||
|
||||
public class AccountDetailedViewModelProfile: Profile
|
||||
{
|
||||
public AccountDetailedViewModelProfile()
|
||||
{
|
||||
CreateMap<AccountDetailedDto, AccountDetailedViewModel>()
|
||||
.ForMember(x => x.Account, o => o.MapFrom(x => x.Account))
|
||||
;
|
||||
}
|
||||
}
|
||||
@@ -34,27 +34,6 @@ public class AccountViewModel: IResponseModel
|
||||
#endregion Permissions
|
||||
}
|
||||
|
||||
public static class AccountViewModelExtensions
|
||||
{
|
||||
public static List<AccountViewModel> ToViewModel(this List<AccountDto> accounts, IMapper mapper)
|
||||
{
|
||||
return mapper.Map<List<AccountViewModel>>(accounts.OrderBy(x => x.Name));
|
||||
}
|
||||
}
|
||||
|
||||
public class AccountAccessViewModel
|
||||
{
|
||||
public class AccountAccessItemViewModel
|
||||
{
|
||||
public string UserId { get; set; } = null!;
|
||||
public bool AllowWrite { get; set; }
|
||||
}
|
||||
|
||||
public string? Email { get; set; }
|
||||
public bool AllowWrite { get; set; }
|
||||
public List<AccountAccessItemViewModel> Accesses { get; set; } = null!;
|
||||
}
|
||||
|
||||
public class AccountViewModelProfile : Profile
|
||||
{
|
||||
public AccountViewModelProfile()
|
||||
@@ -64,31 +43,19 @@ public class AccountViewModelProfile : Profile
|
||||
.ForMember(x => x.CurrencyName, o => o.MapFrom(x => x.Currency!.Name))
|
||||
.AfterMap<AccountViewModelMappingAction>()
|
||||
;
|
||||
|
||||
CreateMap<AccountAccessDto, AccessRightsViewModel>()
|
||||
.AfterMap<AccessRightsViewModelMappingAction>()
|
||||
;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public class AccountViewModelMappingAction : IMappingAction<AccountDto, AccountViewModel>
|
||||
{
|
||||
public void Process(AccountDto source, AccountViewModel destination, ResolutionContext context)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public class AccessRightsViewModelMappingAction : IMappingAction<AccountAccessDto, AccessRightsViewModel>
|
||||
{
|
||||
private readonly IContextProvider _contextProvider;
|
||||
|
||||
public AccessRightsViewModelMappingAction(IContextProvider contextProvider)
|
||||
public AccountViewModelMappingAction(IContextProvider contextProvider)
|
||||
{
|
||||
_contextProvider = contextProvider;
|
||||
}
|
||||
|
||||
public void Process(AccountAccessDto source, AccessRightsViewModel destination, ResolutionContext context)
|
||||
public void Process(AccountDto source, AccountViewModel destination, ResolutionContext context)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,79 +30,19 @@ using MyOffice.Services.Identity;
|
||||
}
|
||||
}*/
|
||||
|
||||
public class PublicationSystemResolver : IMemberValueResolver<object, object, string, bool>
|
||||
/*public class PublicationSystemResolver : IMemberValueResolver<object, object, string, bool>
|
||||
{
|
||||
private readonly IContextProvider _contextProvider;
|
||||
private readonly IContextProvider _contextProvider;
|
||||
|
||||
public PublicationSystemResolver(
|
||||
public PublicationSystemResolver(
|
||||
IContextProvider contextProvider
|
||||
)
|
||||
{
|
||||
this._contextProvider = contextProvider;
|
||||
}
|
||||
|
||||
public bool Resolve(object source, object destination, string sourceMember, bool destMember, ResolutionContext context)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public class AccountViewModelGeneralProfile : Profile
|
||||
{
|
||||
public AccountViewModelGeneralProfile()
|
||||
{
|
||||
CreateMap<AccountDetailedDto, AccountDetailedViewModel>()
|
||||
.ForMember(x => x.Account, o => o.MapFrom(x => x.Account))
|
||||
;
|
||||
|
||||
CreateMap<UserDto, UserViewModel>();
|
||||
|
||||
CreateMap<MyOffice.Data.Models.Users.User, UserViewModel>();
|
||||
|
||||
CreateMap<AccountAccountCategoryDto, AccountCategoryViewModel>()
|
||||
.ForMember(x => x.Id, o => o.MapFrom(x => x.CategoryId))
|
||||
.ForMember(x => x.Name, o => o.MapFrom(x => x.Category!.Name))
|
||||
;
|
||||
|
||||
CreateMap<AccountAccessViewModel.AccountAccessItemViewModel, AccountAccessDto>()
|
||||
.ForMember(x => x.IsAllowWrite, o => o.MapFrom(x => x.AllowWrite))
|
||||
;
|
||||
|
||||
CreateMap<AccountCategoryDto, AccountCategoryViewModel>()
|
||||
;
|
||||
|
||||
CreateMap<AccountAccessInviteDto, AccountAccessInviteViewModel>()
|
||||
.ForMember(x => x.AllowWrite, o => o.MapFrom(x => x.IsAllowWrite))
|
||||
;
|
||||
|
||||
CreateMap<MotionDto, MotionViewModel>()
|
||||
;
|
||||
|
||||
CreateMap<ItemDto, ItemViewModel>()
|
||||
.ForMember(x => x.Category, o => o.MapFrom(x => x.Category!.Name))
|
||||
;
|
||||
|
||||
CreateMap<ItemCategoryDto, ItemCategoryViewModel>()
|
||||
.ForMember(x => x.Internal, o => o.MapFrom(x => x.IsInternal))
|
||||
.ForMember(x => x.AllowDelete, o => o.MapFrom(x => !x.Items.Any() && x.Id != x.UserId))
|
||||
.ForMember(x => x.SortOrder, o => o.MapFrom(x => x.Id == x.UserId ? 1 : 0))
|
||||
;
|
||||
|
||||
CreateMap<CurrencyGlobalDto, CurrencyGlobalViewModel>();
|
||||
|
||||
CreateMap<CurrencyDto, CurrencyViewModel>();
|
||||
|
||||
CreateMap<CurrencyRateDto, CurrencyRateViewModel>();
|
||||
|
||||
CreateMap<CurrencyWithRateDto, CurrencyViewModel>()
|
||||
.ForMember(x => x.Id, o => o.MapFrom(x => x.Currency.Id))
|
||||
.ForMember(x => x.Code, o => o.MapFrom(x => x.Currency.CurrencyGlobalId))
|
||||
.ForMember(x => x.Name, o => o.MapFrom(x => x.Currency.Name))
|
||||
.ForMember(x => x.ShortName, o => o.MapFrom(x => x.Currency.ShortName))
|
||||
.ForMember(x => x.Rate, o => o.MapFrom(x => x.Rate == null ? (decimal?)null : x.Rate.Rate))
|
||||
.ForMember(x => x.IsPrimary, o => o.MapFrom(x => x.Currency.IsPrimary))
|
||||
.ForMember(x => x.Quantity, o => o.MapFrom(x => x.Rate == null ? (int?)null : x.Rate.Quantity))
|
||||
.ForMember(x => x.RateDate, o => o.MapFrom(x => x.Rate == null ? (DateTime?)null : x.Rate.DateTime))
|
||||
;
|
||||
this._contextProvider = contextProvider;
|
||||
}
|
||||
}
|
||||
|
||||
public bool Resolve(object source, object destination, string sourceMember, bool destMember, ResolutionContext context)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}*/
|
||||
Reference in New Issue
Block a user