public ServiceResponse <GetNonConfDto> AddNonConfCorrActions(NonConfCorrActionsDto nonConfCorrActions)
        {
            NonConf    nonConf    = _context.nonConfs.Find(nonConfCorrActions.NonconfId);
            CorrAction corrAction = _context.corrActions.Find(nonConfCorrActions.CorractionId);

            if (NonConfCorrActionsValidator(nonConf, corrAction) == false)
            {
                return(serviceResponse);
            }

            try
            {
                NonConfCorrActions newNonConfCorrActions = new NonConfCorrActions
                {
                    NonConf    = nonConf,
                    CorrAction = corrAction
                };

                _context.nonConfCorrActions.Add(newNonConfCorrActions);
                _context.SaveChanges();

                serviceResponse.Data = _mapper.Map <GetNonConfDto>(nonConf);
            }
            catch (Exception ex)
            {
                serviceResponse.Success = false;
                serviceResponse.Message = "Não foi possível processar a requisição. Exception: " + ex.Message;
            }

            return(serviceResponse);
        }
        private bool NonConfCorrActionsValidator(NonConf nonConf, CorrAction corrAction)
        {
            if (nonConf == null)
            {
                serviceResponse.Success = false;
                serviceResponse.Message = "A NC não existe.";
                return(false);
            }
            else if (corrAction == null)
            {
                serviceResponse.Success = false;
                serviceResponse.Message = "A Ação não existe.";
                return(false);
            }
            else if (nonConf.Status != 0)
            {
                serviceResponse.Success = false;
                serviceResponse.Message = "Esta NC está encerrada e não pode ser alterada.";
                return(false);
            }

            return(true);
        }