public async Task <long> Handle(CreateOrUpdateGeneralTemplateCommand command, CancellationToken cancellationToken) { var transaction = _context.GetTransaction(); try { Account accountTemplate; if (command.Id > 0) { accountTemplate = await UpdateTemplate(command, cancellationToken); } else { accountTemplate = await CreateTemplate(command, cancellationToken); } await _context.SaveChangesAsync(cancellationToken); transaction.Commit(); return(accountTemplate.Id); } catch (Exception e) { transaction.Rollback(); throw; } }