This commit is contained in:
2023-12-16 21:18:01 +02:00
parent 775146ee86
commit 2feaf50802
46 changed files with 641 additions and 429 deletions
@@ -1,14 +1,9 @@
namespace MyOffice.Services.Account.Domain;
using AutoMapper;
using Core.Attributes;
using Data.Models.Accounts;
using Data.Models.Users;
using Mapper;
using MyOffice.Services.Identity;
[Link(typeof(AccountAccess))]
[Link(typeof(AccountServiceProfile))]
public class AccountAccessDto
{
public Guid AccountId { get; set; }
@@ -33,7 +28,7 @@ public class AccountAccessDto
public string? Name { get; set; }
}
public class AccountAccessDtoProfile: Profile
public class AccountAccessDtoProfile : Profile
{
public AccountAccessDtoProfile()
{
@@ -43,7 +38,7 @@ public class AccountAccessDtoProfile: Profile
}
}
public class AccountAccessDtoMappingAction: IMappingAction<AccountAccess, AccountAccessDto>
public class AccountAccessDtoMappingAction : IMappingAction<AccountAccess, AccountAccessDto>
{
private readonly IContextProvider _contextProvider;
public AccountAccessDtoMappingAction(IContextProvider contextProvider)
@@ -51,8 +46,8 @@ public class AccountAccessDtoMappingAction: IMappingAction<AccountAccess, Accoun
_contextProvider = contextProvider;
}
public void Process(AccountAccess source, AccountAccessDto destination, ResolutionContext context)
{
public void Process(AccountAccess source, AccountAccessDto destination, ResolutionContext context)
{
destination.IsOwner = destination.OwnerId == _contextProvider.UserId;
}
}
}
@@ -1,12 +1,22 @@
namespace MyOffice.Services.Account.Domain;
/// <see cref="MyOffice.Data.Models.Accounts.AccountAccessInvite"/>
namespace MyOffice.Services.Account.Domain;
using Core.Attributes;
using AutoMapper;
using Data.Models.Accounts;
[Link(typeof(AccountAccessInvite))]
public class AccountAccessInviteDto
{
public string Id { get; set; } = null!;
public string Account { get; set; } = null!;
public bool IsAllowWrite { get; set; }
}
public class AccountAccessInviteDtoProfile: Profile
{
public AccountAccessInviteDtoProfile()
{
CreateMap<AccountAccessInvite, AccountAccessInviteDto>()
.ForMember(x => x.Account, o => o.MapFrom(x => x.Account!.Name))
;
}
}
@@ -1,7 +1,19 @@
namespace MyOffice.Services.Account.Domain;
/// <see cref="MyOffice.Data.Models.Accounts.AccountAccountCategory"/>
namespace MyOffice.Services.Account.Domain;
using AutoMapper;
using MyOffice.Data.Models.Accounts;
public class AccountAccountCategoryDto
{
public Guid CategoryId { get; set; }
public AccountCategoryDto? Category { get; set; } = null!;
}
public class AccountAccountCategoryDtoProfile: Profile
{
public AccountAccountCategoryDtoProfile()
{
CreateMap<AccountAccountCategory, AccountAccountCategoryDto>();
}
}
@@ -1,4 +1,8 @@
namespace MyOffice.Services.Account.Domain;
/// <see cref="MyOffice.Data.Models.Accounts.AccountCategory"/>
namespace MyOffice.Services.Account.Domain;
using AutoMapper;
using MyOffice.Data.Models.Accounts;
public class AccountCategoryDto
{
@@ -6,4 +10,15 @@ public class AccountCategoryDto
public Guid UserId { get; set; }
public string Name { get; set; } = null!;
public bool AllowDelete { get; set; }
}
public class AccountCategoryDtoProfile: Profile
{
public AccountCategoryDtoProfile()
{
CreateMap<AccountCategory, AccountCategoryDto>()
.ForMember(x => x.Id, o => o.MapFrom(x => x.Id))
.ForMember(x => x.AllowDelete, o => o.MapFrom(x => !x.Accounts!.Any()))
;
}
}
@@ -1,9 +1,10 @@
using AutoMapper;
/// <see cref="MyOffice.Data.Models.Accounts.Account"/>
namespace MyOffice.Services.Account.Domain;
using AutoMapper;
using MyOffice.Core;
using MyOffice.Data.Models.Accounts;
namespace MyOffice.Services.Account.Domain;
public class AccountDetailedDto: IDataModelDto<AccountDetailed>
{
public AccountDto Account { get; set; } = null!;
@@ -1,5 +1,7 @@
namespace MyOffice.Services.Account.Domain;
/// <see cref="MyOffice.Data.Models.Items.ItemCategory"/>
namespace MyOffice.Services.Account.Domain;
using AutoMapper;
using MyOffice.Data.Models.Items;
public class ItemCategoryDto
@@ -10,4 +12,12 @@ public class ItemCategoryDto
public string Name { get; set; } = null!;
public List<ItemDto> Items { get; set; } = null!;
public bool IsInternal { get; set; }
}
public class ItemCategoryDtoProfile: Profile
{
public ItemCategoryDtoProfile()
{
CreateMap<ItemCategory, ItemCategoryDto>();
}
}
+15 -1
View File
@@ -1,5 +1,7 @@
namespace MyOffice.Services.Account.Domain;
/// <see cref="MyOffice.Data.Models.Items.Item"/>
namespace MyOffice.Services.Account.Domain;
using AutoMapper;
using MyOffice.Data.Models.Items;
public class ItemDto
@@ -11,3 +13,15 @@ public class ItemDto
public Guid CategoryId { get; set; }
public ItemCategoryDto? Category { get; set; }
}
public class ItemDtoProfile: Profile
{
public ItemDtoProfile()
{
CreateMap<Item, ItemDto>()
.ForMember(x => x.Id, o => o.MapFrom(x => x.ItemGlobalId))
.ForMember(x => x.Name, o => o.MapFrom(x => x.ItemGlobal.Name))
.ForMember(x => x.AllowDelete, o => o.MapFrom(x => !x.Motions!.Any()))
;
}
}
@@ -1,14 +1,22 @@
namespace MyOffice.Services.Account.Domain
namespace MyOffice.Services.Account.Domain;
using AutoMapper;
public class MotionAddUpdate
{
public class MotionAddUpdate
{
public DateTime Date { get; set; }
public string Item { get; set; } = null!;
public string? ItemId { get; set; } = null!;
public string? AccountId { get; set; } = null!;
public string? Description { get; set; }
public decimal Plus { get; set; }
public decimal Minus { get; set; }
public decimal AmountBalancing { get; set; }
}
public DateTime Date { get; set; }
public string Item { get; set; } = null!;
public string? ItemId { get; set; } = null!;
public string? AccountId { get; set; } = null!;
public string? Description { get; set; }
public decimal Plus { get; set; }
public decimal Minus { get; set; }
public decimal AmountBalancing { get; set; }
}
public class MotionAddUpdateProfile: Profile
{
public MotionAddUpdateProfile()
{
}
}
+12 -1
View File
@@ -1,5 +1,8 @@
namespace MyOffice.Services.Account.Domain;
/// <see cref="MyOffice.Data.Models.Users.User"/>
namespace MyOffice.Services.Account.Domain;
using AutoMapper;
using MyOffice.Data.Models.Users;
using MyOffice.Services.Currency.Domain;
public class UserDto
@@ -15,3 +18,11 @@ public class UserDto
public string CurrencyId { get; set; } = null!;
public CurrencyGlobalDto? Currency { get; set; }
}
public class UserDtoProfile : Profile
{
public UserDtoProfile()
{
CreateMap<User, UserDto>();
}
}