public async Task ExecuteAsync(TransmitRecruitCommandParameters parameters) { if (parameters == null) { throw new ArgumentNullException(nameof(parameters)); } var recruitInfoes = _recruitInfoRepository.Get(parameters.RecruitIds) .ToList() .OrderBy(r => r.Envelope.PassportInfo.PersonInfo.FullName.Surname) .ToList(); using (var firebirdUnitOfWork = _firebirdUnitOfWorkFactory.Create()) using (var sqliteUnitOfWork = _sqliteUnitOfWorkFactory.Create()) { try { var regionalCollectionPoints = recruitInfoes.Select(r => r.ServiceInfo.RegionalCollectionPoint).Distinct().ToList(); var message = $"{CommandSuccess}. Военкоматы - {string.Join(SeparatorConstants.CommaSeparator, regionalCollectionPoints)}"; await _transmitService.MoveAsync(recruitInfoes); foreach (var recruit in recruitInfoes) { ChangePhotoName(recruit); _recruitInfoRepository.Change(recruit); } _eventService.Fire(message); await firebirdUnitOfWork.CommitAsync(); await sqliteUnitOfWork.CommitAsync(); parameters.StateChanged.OnStateChanged(message, StateResult.Success); } catch (Exception ex) { firebirdUnitOfWork.Rollback(); sqliteUnitOfWork.Rollback(); throw ex; } } }
public void UpdateRecruitInfoSQLiteTest() { var recruitInfo = MemoryData.Build(1, 1, _photoExtension); AddRecruitInfo(recruitInfo); var first = _recruitInfoRepository.Get(1); var homeNumber = "123"; first.Envelope.Contacts.ChangeHomeNumber(new PhoneNumber(homeNumber)); using (var unitOfWork = _unitOfWorkFactory.Create()) { _recruitInfoRepository.Change(first); unitOfWork.Commit(); } var updated = _recruitInfoRepository.Get(1); Assert.AreEqual(homeNumber, updated.Envelope.Contacts.HomeNumber.Value); }