public void Update(ISsdSetUpdateIo input) { this.Description = input.Description; this.IsEnabled = input.IsEnabled; this.Name = input.Name; this.SsdCard = input.SsdCard; }
public SsdSetUpdatedEvent(IAcSession acSession, SsdSetBase source, ISsdSetUpdateIo output) : base(acSession, source) { if (output == null) { throw new System.ArgumentNullException("output"); } this.Output = output; }
internal SsdSetUpdatedEvent(IAcSession acSession, SsdSetBase source, ISsdSetUpdateIo input, bool isPrivate) : this(acSession, source, input) { this.IsPrivate = isPrivate; }
private void Handle(IAcSession acSession, ISsdSetUpdateIo input, bool isCommand) { var acDomain = _set._acDomain; var ssdSetDic = _set._ssdSetDic; var ssdSetRepository = acDomain.RetrieveRequiredService <IRepository <SsdSet, Guid> >(); SsdSetState bkState; if (!acDomain.SsdSetSet.TryGetSsdSet(input.Id, out bkState)) { throw new NotExistException(); } SsdSet entity; var stateChanged = false; lock (Locker) { SsdSetState oldState; if (!acDomain.SsdSetSet.TryGetSsdSet(input.Id, out oldState)) { throw new NotExistException(); } if (acDomain.SsdSetSet.Any(a => a.Name.Equals(input.Name, StringComparison.OrdinalIgnoreCase) && a.Id != input.Id)) { throw new ValidationException("重复的静态责任分离角色组名"); } entity = ssdSetRepository.GetByKey(input.Id); if (entity == null) { throw new NotExistException(); } entity.Update(input); var newState = SsdSetState.Create(entity); stateChanged = newState != bkState; if (stateChanged) { Update(newState); } if (isCommand) { try { ssdSetRepository.Update(entity); ssdSetRepository.Context.Commit(); } catch { if (stateChanged) { Update(bkState); } ssdSetRepository.Context.Rollback(); throw; } } } if (isCommand && stateChanged) { acDomain.MessageDispatcher.DispatchMessage(new SsdSetUpdatedEvent(acSession, entity, input, isPrivate: true)); } }