public async Task <ICommandResult> Handle(UserInsertCommand command)
        {
            //FFV
            command.Validate();
            if (command.Invalid)
            {
                return(new GenericCommandResult(false, HttpStatusCode.BadRequest, command.Notifications));
            }

            User _entity = new User();

            _entity.Login    = command.Login;
            _entity.Password = command.Password;
            _entity.Name     = command.Name;
            _entity.Email    = command.Email;
            _entity.Role     = command.Role.ToString();

            var _result = await _contextRepository.Add(_entity);

            //retorna o resultado
            if (!_result)
            {
                return(new GenericCommandResult(false, HttpStatusCode.BadRequest, _result));
            }

            return(new GenericCommandResult(true, HttpStatusCode.Created, _result));
        }
        public async Task <Guid> Handle(CreateContext command)
        {
            var newId = Guid.NewGuid();
            await _repo.Add(new Context(newId, command.Name, command.Description));

            return(newId);
        }
Beispiel #3
0
        public async Task <ICommandResult> Handle(TruckInsertCommand command)
        {
            command.Validate();
            if (command.Invalid)
            {
                return(new GenericCommandResult(false, HttpStatusCode.BadRequest, command.Notifications));
            }

            Truck _entity = new Truck();

            _entity.Description = command.Description;
            _entity.Color       = command.Color;
            _entity.Image       = command.Image;
            _entity.Model       = (EnumModel)command.Model;
            _entity.ModelYear   = command.ModelYear;

            var _result = await _contextRepository.Add(_entity);

            if (!_result)
            {
                return(new GenericCommandResult(false, HttpStatusCode.BadRequest, _result));
            }

            return(new GenericCommandResult(true, HttpStatusCode.Created, _result));
        }
 public async Task Handle(object command)
 {
     switch (command)
     {
     case ContextCommands.Provision cmd:
         var provisioner          = Provision.v0_7(cmd.Token);
         var ctx                  = ContextBuilder.fromScratch(cmd.WalletId, cmd.WalletKey, cmd.VerityApplicationEndpoint);
         var provisioningResponse = provisioner.provision(ctx);
         var context              = new Context(provisioningResponse);
         _repository.Add(context);
         break;
     }
 }