Example #1
0
 public async Task AgregarProdutos(Produto p, List <int> IDPartes)
 {
     foreach (int i in IDPartes)
     {
         Produto pParte = _produtorepo.GetById(i).Result;
         if (pParte != null)
         {
             Agregacao a = new Agregacao(p, pParte);
             if (a.Validar())
             {
                 await _agregacaorepo.Create(a);
             }
         }
     }
 }
Example #2
0
        public async Task <IActionResult> Create([FromBody] AgregacaoCriarDTO agregacaodto)
        {
            var pBase = await _produtoRepository.GetById(agregacaodto.Base);

            var pParte = await _produtoRepository.GetById(agregacaodto.Parte);

            if (pBase == null || pParte == null)
            {
                return(NotFound());
            }

            Agregacao a = new Agregacao(pBase, pParte);
            await _agregacaoRepository.Create(a);

            var dto = _mapper.Map <Agregacao, AgregacaoDTO>(a);

            return(Created("Agregacao Criada", dto));
        }