/// <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()))); }
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>()); }
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>()); }