/// <summary>
 /// 转换为账户实体
 /// </summary>
 /// <param name="dto">账户数据传输对象</param>
 public static Account ToEntity(this AccountDto dto)
 {
     if (dto == null)
     {
         return(new Account());
     }
     return(dto.MapTo(new Account(dto.Id.ToGuid())));
 }
Exemple #2
0
        public async Task <AccountDto> AddAsync(AccountDto accountDto)
        {
            Debug.Assert(accountDto == null);
            var entity = await BalanceManagementDbContext.Accounts.AddAsync(accountDto.MapTo <Account>());

            await SaveChangesAsync();

            return(entity.Entity.MapTo <AccountDto>());
        }
Exemple #3
0
        public async Task <AccountDto> UpdateAsync(AccountDto accountDto)
        {
            Debug.Assert(accountDto == null);
            var currentAccount = await GetEntityByIdAsync(accountDto.Id);

            var newAccount = accountDto.MapTo <Account>();

            BalanceManagementDbContext.Entry(currentAccount).CurrentValues.SetValues(newAccount);
            await SaveChangesAsync();

            return(newAccount.MapTo <AccountDto>());
        }