示例#1
0
        public async Task CreateClienteAsync(ClienteJson clienteToCreate, AccountInfo who, When when)
        {
            var createClienteCommand = new CreateCliente(new ClienteId(clienteToCreate.ClienteId),
                                                         new RagioneSociale(clienteToCreate.RagioneSociale), new PartitaIva(clienteToCreate.PartitaIva),
                                                         new CodiceFiscale(clienteToCreate.CodiceFiscale), who, when);

            await this._serviceBus.SendAsync(createClienteCommand);
        }
示例#2
0
        public async Task <IActionResult> CreateCliente([FromBody] ClienteJson cliente)
        {
            try
            {
                await this._clienteOrchestrator.CreateClienteAsync(cliente, this.CommandInfo.Who, this.CommandInfo.When);

                var clienteUri = $"{GetUri(this.Request)}";
                return(this.Created("clienti", new PostResult(clienteUri, "")));
            }
            catch (Exception ex)
            {
                this._logger.LogError($"[ClientiController.CreateCliente] - {CommonServices.GetErrorMessage(ex)}");
                return(this.BadRequest($"[ClientiController.CreateCliente] - {CommonServices.GetErrorMessage(ex)}"));
            }
        }
示例#3
0
        public async Task Cannot_CreateCliente_Without_ClienteRagioneSociale()
        {
            var clienteOrchestrator = this._container.Resolve <IClienteOrchestrator>();
            var clienteJson         = new ClienteJson
            {
                ClienteId      = string.Empty,
                RagioneSociale = string.Empty,
                PartitaIva     = "03466990177",
                CodiceFiscale  = "03466990177"
            };

            Exception ex = await Assert.ThrowsAnyAsync <Exception>(() =>
                                                                   clienteOrchestrator.CreateClienteAsync(clienteJson, this._who, this._when));

            Assert.Equal(DomainExceptions.RagioneSocialeNullException, CommonServices.GetErrorMessage(ex));
        }