public void Update(IDsdSetUpdateIo input) { this.Description = input.Description; this.IsEnabled = input.IsEnabled; this.Name = input.Name; this.DsdCard = input.DsdCard; }
public DsdSetUpdatedEvent(IAcSession acSession, DsdSetBase source, IDsdSetUpdateIo output) : base(acSession, source) { if (output == null) { throw new System.ArgumentNullException("output"); } this.Output = output; }
internal DsdSetUpdatedEvent(IAcSession acSession, DsdSetBase source, IDsdSetUpdateIo input, bool isPrivate) : this(acSession, source, input) { this.IsPrivate = isPrivate; }
private void Handle(IAcSession acSession, IDsdSetUpdateIo input, bool isCommand) { var acDomain = _set._acDomain; var dsdSetRepository = acDomain.RetrieveRequiredService <IRepository <DsdSet> >(); DsdSetState bkState; if (!acDomain.DsdSetSet.TryGetDsdSet(input.Id, out bkState)) { throw new NotExistException(); } DsdSet entity; bool stateChanged; lock (Locker) { DsdSetState oldState; if (!acDomain.DsdSetSet.TryGetDsdSet(input.Id, out oldState)) { throw new NotExistException(); } if (acDomain.DsdSetSet.Any(a => a.Name.Equals(input.Name, StringComparison.OrdinalIgnoreCase) && a.Id != input.Id)) { throw new ValidationException("重复的静态责任分离角色组名"); } entity = dsdSetRepository.GetByKey(input.Id); if (entity == null) { throw new NotExistException(); } entity.Update(input); var newState = DsdSetState.Create(entity); stateChanged = newState != bkState; if (stateChanged) { Update(newState); } if (isCommand) { try { dsdSetRepository.Update(entity); dsdSetRepository.Context.Commit(); } catch { if (stateChanged) { Update(bkState); } dsdSetRepository.Context.Rollback(); throw; } } } if (isCommand && stateChanged) { acDomain.MessageDispatcher.DispatchMessage(new DsdSetUpdatedEvent(acSession, entity, input, isPrivate: true)); } }