コード例 #1
0
        public async Task ModificaDescrizioneArticoloAsync(ArticoloJson articolo, AccountInfo who, When when)
        {
            var modificaDescrizioneCommand = new ModificaDescrizioneArticolo(new ArticoloId(articolo.ArticoloId),
                                                                             new ArticoloDescrizione(articolo.ArticoloDescrizione), who, when);

            await this._serviceBus.SendAsync(modificaDescrizioneCommand);
        }
コード例 #2
0
        public async Task CreateArticoloAsync(ArticoloJson articoloToCreate, AccountInfo who, When when)
        {
            var articoloId = new ArticoloId(articoloToCreate.ArticoloId);

            var createArticoloCommand = new CreateArticolo(articoloId,
                                                           new ArticoloDescrizione(articoloToCreate.ArticoloDescrizione),
                                                           new UnitaMisura(articoloToCreate.UnitaMisura), new ScortaMinima(articoloToCreate.ScortaMinima),
                                                           who, when);

            await this._serviceBus.SendAsync(createArticoloCommand);
        }
コード例 #3
0
        public async Task <IActionResult> CreateArticolo([FromBody] ArticoloJson articoloToCreate)
        {
            try
            {
                await this._articoloOrchestrator.CreateArticoloAsync(articoloToCreate, this.CommandInfo.Who, this.CommandInfo.When);

                return(this.Created("articoli", new PostResult("/", "")));
            }
            catch (Exception ex)
            {
                this._logger.LogError($"[ArticoliController.CreateArticolo] - {CommonServices.GetErrorMessage(ex)}");
                return(this.BadRequest($"[ArticoliController.CreateArticolo] - {CommonServices.GetErrorMessage(ex)}"));
            }
        }
コード例 #4
0
        public async Task <IActionResult> ModificaDescrizione([FromBody] ArticoloJson articolo)
        {
            try
            {
                await this._articoloOrchestrator.ModificaDescrizioneArticoloAsync(articolo, this.CommandInfo.Who,
                                                                                  this.CommandInfo.When);

                return(this.NoContent());
            }
            catch (Exception ex)
            {
                this._logger.LogError($"[ArticoliController.GetArticoloDetailsById] - {CommonServices.GetErrorMessage(ex)}");
                throw new Exception($"[ArticoliController.GetArticoloDetailsById] - {CommonServices.GetErrorMessage(ex)}");
            }
        }
コード例 #5
0
        public async Task Cannot_CreateArticolo_Without_ArticoloDescrizione()
        {
            var articoloOrchestrator = this._container.Resolve <IArticoloOrchestrator>();
            var articoloJson         = new ArticoloJson
            {
                ArticoloId          = string.Empty,
                ArticoloDescrizione = string.Empty,
                UnitaMisura         = "NR",
                ScortaMinima        = 1
            };

            Exception ex = await Assert.ThrowsAnyAsync <Exception>(() =>
                                                                   articoloOrchestrator.CreateArticoloAsync(articoloJson, this._who, this._when));

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