示例#1
0
        /// <summary>
        /// Returns a new Model.Broker and adds it to the repository
        /// </summary>
        /// <returns></returns>
        private Broker CreateNewBroker()
        {
            var newBroker = new Broker();

            _repository.Add(newBroker);

            return(newBroker);
        }
示例#2
0
 public void Add_ShouldThrowNotImplementedException()
 {
     try
     {
         _brokerRepositoryMock.Add(_brokerListMock.ElementAt(0));
     }
     catch (Exception ex)
     {
         Assert.AreEqual(ex.GetType(), typeof(NotImplementedException));
     }
 }
 public async Task Add(string message, string topic)
 {
     try
     {
         await _repo.Add(message, topic);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
        public Task <bool> Handle(AddNewBrokerCommand message, CancellationToken cancellationToken)
        {
            if (!message.IsValid())
            {
                NotifyValidationErrors(message);
                return(Task.FromResult(false));
            }

            var broker = new Broker(Guid.NewGuid(), message.Name);

            _brokerRepository.Add(broker);

            if (Commit())
            {
                _bus.RaiseEvent(new BrokerAddedEvent(broker.Id, broker.Name));
            }

            return(Task.FromResult(true));
        }
示例#5
0
        public void Add(UserModel model)
        {
            long userId;

            switch (model.RoleType)
            {
            case RoleType.Admin:
                userId = _admins.Add(model.Name, model.Authentication.Login, model.Email, TwoLetterISOLanguageName.English);
                break;

            case RoleType.Manager:
                userId = _managers.Add(model.Name, model.Authentication.Login, model.Email, TwoLetterISOLanguageName.English);
                break;

            case RoleType.Broker:
                userId = _brokers.Add(model.Name, model.Authentication.Login, model.Email, TwoLetterISOLanguageName.English);
                break;

            default:
                throw new ArgumentOutOfRangeException("model", @"Unknown role " + model.RoleType);
            }

            _users.SetPassword(userId, model.Authentication.NewPassword);
        }