コード例 #1
0
        public async Task <SocioFamiliareDetailViewModel> CreateSocioFamiliareAsync(SocioFamiliareCreateInputModel inputModel)
        {
            var socioFamiliare = new SocioFamiliare();

            socioFamiliare.ChangeSocioId(inputModel.SocioId);
            socioFamiliare.ChangeFamiliare(inputModel.Familiare);

            dbContext.Add(socioFamiliare);
            await dbContext.SaveChangesAsync();

            return(socioFamiliare.ToSocioFamiliareDetailViewModel());
        }
コード例 #2
0
        public async Task <SocioFamiliareDetailViewModel> EditSocioFamiliareAsync(SocioFamiliareEditInputModel inputModel)
        {
            SocioFamiliare socioFamiliare = await dbContext.SociFamiliari.FindAsync(inputModel.Id);

            if (socioFamiliare == null)
            {
                logger.LogWarning("Socio familiare {id} non trovato", inputModel.Id);
                throw new SocioFamiliareNotFoundException(inputModel.Id);
            }

            socioFamiliare.ChangeSocioId(inputModel.SocioId);
            socioFamiliare.ChangeFamiliare(inputModel.Familiare);

            await dbContext.SaveChangesAsync();

            return(socioFamiliare.ToSocioFamiliareDetailViewModel());
        }