private async Task <bool> CadastrarOcorrenciaAtivo(Guid ocorrenciaId, ICollection <AtivoOcorrenciaPostDto> listaAtivosODTO)
 {
     foreach (AtivoOcorrenciaPostDto itemAtivoDto in listaAtivosODTO)
     {
         OcorrenciaAtivo ocorrenciaAtivo = new OcorrenciaAtivo(ocorrenciaId,
                                                               itemAtivoDto.Id,
                                                               itemAtivoDto.Principal);
         await _ocorrenciaAtivoRepository.CadastrarOcorrenciaAtivo(ocorrenciaAtivo);
     }
     return(true);
 }
Exemple #2
0
        public async Task <bool> CadastrarOcorrenciaAtivo(OcorrenciaAtivo ocorrenciaAtivo)
        {
            try
            {
                _context.OcorrenciaAtivos.Add(ocorrenciaAtivo);
                await _context.SaveChangesAsync();

                return(true);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemple #3
0
        public async Task <bool> ExcluirOcorrenciaAtivo(OcorrenciaAtivo ocorrenciaAtivo)
        {
            try
            {
                var result = await _context.OcorrenciaAtivos.SingleOrDefaultAsync(oa => oa.OcorrenciaId.Equals(ocorrenciaAtivo.OcorrenciaId) && oa.AtivoId.Equals(ocorrenciaAtivo.AtivoId));

                if (result != null)
                {
                    _context.OcorrenciaAtivos.Remove(result);
                    await _context.SaveChangesAsync();

                    return(true);
                }
                return(false);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemple #4
0
        public async Task <bool> EditarPrincipalOcorrenciaAtivo(OcorrenciaAtivo ocorrenciaAtivo)
        {
            try
            {
                var result = await _context.OcorrenciaAtivos.SingleOrDefaultAsync(oa => oa.OcorrenciaId.Equals(ocorrenciaAtivo.OcorrenciaId) && oa.AtivoId.Equals(ocorrenciaAtivo.AtivoId));

                if (result != null)
                {
                    result.Principal = ocorrenciaAtivo.Principal;
                    await _context.SaveChangesAsync();

                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }