public async Task <AccountCryptoModelBussines <int> > CreateAsync(AccountCryptoModelBussines <int> model) { var accCrypto = await _context.AccountCryptos.AddAsync( AutoMapperConfig.Mapper.Map <AccountCryptoModel <int> >(model) ); await _context.SaveChangesAsync(); return(await GetByIdAsync(accCrypto.Entity.Id)); }
public async Task <AccountCryptoModelBussines <int> > CreateAsync(int userId) { var accCrypto = new AccountCryptoModelBussines <int> { AccountId = userId, TokenKeySecondPart = "emotyToDo", AESKeySecondPart = AESKeyGeneratorEncryptionHelper.GetAESKey() }; var generated = await this.CreateAsync(accCrypto); return(generated); }
public async Task <AccountCryptoModelBussines <int> > UpdateAsync(int id, AccountCryptoModelBussines <int> model) { var accCrypto = await GetRawByIdAsync(model.Id); if (model.AESKeySecondPart != null) { accCrypto.AESKeySecondPart = model.AESKeySecondPart; } if (model.TokenKeySecondPart != null) { accCrypto.TokenKeySecondPart = model.TokenKeySecondPart; } _context.AccountCryptos.Update(accCrypto); await _context.SaveChangesAsync(); return(await GetByIdAsync(model.Id)); }