示例#1
0
        public VentilatorStatesTransaction(string code, string description, VentilatorState from, VentilatorState to) : this()
        {
            if (string.IsNullOrEmpty(code = code?.Trim()))
            {
                throw new ArgumentNullException("code cannot be null or empty");
            }

            if (string.IsNullOrEmpty(description = description?.Trim()))
            {
                throw new ArgumentNullException("description cannot be null or empty");
            }

            From        = VentilatorStatesList.AllVentilatorStates.FirstOrDefault(s => s.Code == from?.Code) ?? throw new ArgumentNullException($"state with code {from?.Code} not found");
            To          = VentilatorStatesList.AllVentilatorStates.FirstOrDefault(s => s.Code == to?.Code) ?? throw new ArgumentNullException($"state with code {to?.Code} not found");
            Code        = code;
            Description = description;
        }
        private void ChangeState(VentilatorState from, VentilatorState to, int idUser)
        {
            var transaction = VentilatorStatesTransactionsList.AllVentilatorStates.FirstOrDefault(t => t.From.Equals(from) && t.To.Equals(to)) ?? throw new InvalidOperationException($"transaction from state {from.Code} to {to.Code} not found");

            _stateHistories.Add(new VentilatorStateHistory(ventilator: this, transaction: transaction, idUser: idUser));
        }