public AppMutation(IRepository repository) : base(repository)
        {
            // Lista de end point the devem ser ignorados nomomento da criação das queries
            var ignoreFields = new List <System.Type> {
                typeof(LoginType),
                typeof(UsuarioType),
                typeof(CotacaoType),
                typeof(ApoliceType),
                typeof(PagamentoDtoType),
                typeof(PlanoObjectivoComercialType),
                typeof(CanalType),
                typeof(PessoaType),
                typeof(PessoaSingularType),
                typeof(PessoaColectivaType)
            };

            #region Base Fields

            // Adicionanado as classes a serem ignoradas que são partilhadas
            ignoreFields.AddRange(ignoreTypesShared);

            //// Percorrendo os tipos do graphql
            foreach (var item in GetGraphTypesAndInputTypes())
            {
                var type      = item.Item1;
                var inputType = item.Item2;

                // Verificando o nome do tipo
                if (ignoreFields.Any(x => x == type))
                {
                    // Pulando
                    continue;
                }
                if (type.BaseType.Name.EndsWith("Type") && !type.BaseType.Name.EndsWith("GraphType"))
                {
                    typeof(AppMutation).GetMethod(nameof(AppMutation.FieldGenericAsync))
                    .MakeGenericMethod(type, inputType, type.BaseType.BaseType.GenericTypeArguments[0])
                    .Invoke(this, null);
                }
                else
                {
                    // Instanciando
                    typeof(AppMutation).GetMethod(nameof(AppMutation.FieldGenericAsync))
                    .MakeGenericMethod(type, inputType, type.BaseType.GenericTypeArguments[0])
                    .Invoke(this, null);
                }
            }
            #endregion

            FieldNormalAsync <CanalType, CanalInputType, Canal>();

            // --------------------- GraphQL types personalizadas ---------------------
            FieldAsync <UsuarioType, UsuarioInputType, Usuario>(param: new Param <Usuario>
            {
                Add = async(usuario, context) =>
                {
                    return(await repository.ExecuteAsync(async provider =>
                    {
                        var userRepo = provider.GetRequiredService <IUsuarioRepository>();
                        return await userRepo.AddUsuarioAsync(usuario);
                    }));
                }
            });

            Field <ListGraphType <StringGraphType> >(
                "upload", arguments: new QueryArguments(
                    new QueryArgument <FileDtoInputType> {
                Name = "obj"
            },
                    new QueryArgument <StringGraphType> {
                Name = "url"
            }
                    ),

                resolve: context =>
            {
                var url = context.GetArgument <String>("url");
                var obj = context.GetArgument <FileDto>("obj");
                FileSystemManager Read = new FileSystemManager();
                return(Read.Upload($"pessoaDocumento/{url}", obj));
            });

            Field <StringGraphType>(
                "createdir",
                arguments: new QueryArguments(
                    new QueryArgument <FileSystInputType> {
                Name = "obj"
            }),
                resolve: context =>
            {
                var obj = context.GetArgument <FileSyst>("obj");
                FileSystemManager Read = new FileSystemManager();
                return(Read.CreateUserDirStruct(obj.url, obj.dirprincipal));
            });

            Field <StringGraphType>(
                "download",
                arguments: new QueryArguments(new QueryArgument <FileSystInputType> {
                Name = "obj"
            }),
                resolve: context =>
            {
                var obj = context.GetArgument <FileSyst>("obj");
                FileSystemManager Read = new FileSystemManager();
                return(Read.DownloadFile(obj.url));
            });

            Field <StringGraphType>(
                "removerfile",
                arguments: new QueryArguments(new QueryArgument <FileSystInputType> {
                Name = "obj"
            }),
                resolve: context =>
            {
                var obj = context.GetArgument <FileSyst>("obj");
                FileSystemManager Read = new FileSystemManager();
                return(Read.DeleteFile(obj.url));
            });

            FieldAsync <StringGraphType>(
                "excelenviado",
                arguments: new QueryArguments(new QueryArgument <StringGraphType> {
                Name = "obj"
            }),
                resolve: async context =>
            {
                var obj  = context.GetArgument <string>("obj");
                var Read = new Excel();
                var tr   = Read.dt(obj);
                foreach (var itens in tr)
                {
                    var pessoa = await Repo.GetAsync <Pessoa>(itens.PROPRETARIO, nameof(Pessoa.IdPessoa));
                    if (pessoa != null)
                    {
                        await Repo.AddAsync(new Automovel()
                        {
                            Matricula              = itens.MATRICULA,
                            NumeroChassi           = itens.NUMEROCHASSI,
                            ProprietarioId         = itens.PROPRETARIO,
                            NumLugares             = itens.NUMERODELUGARES,
                            NumMotor               = itens.NUMERODOMOTOR,
                            Potencia               = itens.POTENCIA,
                            PesoBruto              = itens.PESOBRUTO,
                            ValorEmNovo            = itens.VALOREMNOVO,
                            ValorActual            = itens.VALOREACTUAL,
                            AnoConstrucao          = itens.ANODOVEICULO,
                            CilindragemAutomovelId = itens.CILINDRAGEM,
                            //ClassificacaoAutomovelId = itens.CLASSIFICACAO,
                            PaisMatriculaId = itens.PAISDAMATRICULA
                        });
                    }
                    else
                    {
                        await Repo.AddAsync(new Automovel()
                        {
                            Matricula    = itens.MATRICULA,
                            NumeroChassi = itens.NUMEROCHASSI,
                            Potencia     = itens.POTENCIA,
                            PesoBruto    = itens.PESOBRUTO,
                            ValorEmNovo  = itens.VALOREMNOVO,
                            Proprietario = new Pessoa()
                            {
                                NomeCompleto = "testexceltest"
                            },
                            CilindragemAutomovelId   = itens.CILINDRAGEM,
                            ClassificacaoAutomovelId = itens.CLASSIFICACAO,
                            MotoristaAutomovel       = new List <MotoristaAutomovel>()
                            {
                                new MotoristaAutomovel
                                {
                                    MotoristaId = itens.CONDUTOR
                                }
                            }
                        });
                    }
                }
                return("Arquivo Enviado Com sucesso");
            });

            /*Field<StringGraphType>(
             *   "excel",
             * arguments: new QueryArguments(new QueryArgument<FileSystInputType> { Name = "obj" }),
             * resolve: context =>
             * {
             *  var Read = new ISS.GraphQL.Excel.Excel();
             * Read.Gerarar(@"D:\ter.xlsx");
             *  //  var marcas = Read.sqlrt<MarcaAutomovel>(nameof(MarcaAutomovel));
             *  // var models = Read.sqlrt<ModeloAutomovel>(nameof(ModeloAutomovel));
             *  // string[] cabecalho = {"MARCA","MODELO","CILINDRAGEM"};
             *  // string[] valor = {marcas.Select(x => x.Marca).ToString(), models.Select(x => x.Modelo).ToString(), "CILINDRAGEM" };
             *
             *  // Read.CreatePanilha(@"D:\ter.xlsx", "teste", cabecalho,valor);
             *  return "feito"; s
             * });
             */


            FieldAsync <RegisterType>("registrar",
                                      arguments: new QueryArguments(Arg <NonNullGraphType <RegisterInputType> >("obj")),
                                      resolve: async context =>
            {
                var result = await repository.ExecuteAsync(async provider =>
                {
                    var credenciais = context.GetArgument <RegisterViewModel>("obj");
                    var userRepo    = provider.GetService <IUsuarioRepository>();
                    var rs          = await userRepo.RegisterAsync(credenciais);
                    return(rs);
                });

                return(context.Resolve(result));
            });

            // Inserção para movimento com paridade
            FieldListAsync <MovimentoType, Movimento>("addMovimentoPar", async(context, repo) =>
            {
                try
                {
                    var retorno = await repo.ExecuteAsync(async provider =>
                    {
                        return(await Task.FromResult(new ISS.Application.Movimentos.Movimentos(provider.GetService <DapperContext>(), provider.GetService <LinqDbContext>()).
                                                     CreateMovParidadeContabilidade(context.GetArgument <Movimento>("obj"))));
                    });

                    return(retorno);
                }
                catch (Exception ex)
                {
                    context.Errors.Add(new ExecutionError(ex.Message));
                    if (ex.InnerException != null)
                    {
                        context.Errors.Add(new ExecutionError(ex.InnerException.Message));
                    }
                    return(null);
                }
            }, Arg <MovimentoInputType>("obj"));

            //// Insercção de movimento impar
            FieldListAsync <MovimentoType, Movimento>("addMovimentoImpar", async(context, repo) =>
            {
                try
                {
                    var retorno = await repo.ExecuteAsync(async provider =>
                    {
                        return(await Task.FromResult(new ISS.Application.Movimentos.Movimentos(provider.GetService <DapperContext>(), provider.GetService <LinqDbContext>()).
                                                     CreateMovImparidadeContabilidade(context.GetArgument <Movimento>("obj"))));
                    });
                    return(retorno);
                }
                catch (Exception ex)
                {
                    context.Errors.Add(new ExecutionError(ex.Message));
                    if (ex.InnerException != null)
                    {
                        context.Errors.Add(new ExecutionError(ex.InnerException.Message));
                    }
                    return(null);
                }
            }, Arg <MovimentoInputType>("obj"));

            // Função auxiliar para efectuar o calculo de uma cotacao
            CalculoModel Calcular(Cotacao data, bool movimento = false)
            {
                var qs = Repo.GetAsync <QualidadeSegura>(data.QualidadeEmQueSeguraId, nameof(QualidadeSegura.IdQualidadeSegura)).Await();

                if (qs?.CodQualidadeSegura == "Q005")
                {
                    var membro = new MembroAssegurado {
                        PessoaId = data.TomadorId
                    };
                    if (data.MembroAssegurado == null)
                    {
                        data.MembroAssegurado = new MembroAssegurado[] { membro }
                    }
                    ;
                    else
                    {
                        data.MembroAssegurado.Add(membro);
                    }
                }

                // Efectuando os calculos
                var result = Repo.ExecuteAsync(async provider =>
                {
                    return(await Task.FromResult(new Calculos(provider.GetService <DapperContext>(), provider.GetService <IRepository>())));
                }).Await();

                var calculo = result.CalculoGeral(new CalculoModel
                {
                    Cotacao = data
                }, movimento);

                #region Setters
                // Preenchendo os campos do object de cotacao
                data.PremioBase      = calculo.PremioBase;
                data.PremioRisco     = calculo.PremioRisco;
                data.PremioSimples   = calculo.PremioSimples;
                data.PremioComercial = calculo.PremioComercial;
                data.PremioBruto     = calculo.PremioBruto;
                data.PremioTotal     = calculo.PremioCobrado;

                data.EncargosAdministrativos = calculo.Agravamentos;
                data.Despesas     = calculo.Despesas;
                data.Descontos    = calculo.Descontos;
                data.Ofertas      = calculo.Ofertas;
                data.Comissoes    = calculo.Comissoes;
                data.Agravamentos = calculo.Agravamentos;
                data.Impostos     = calculo.Impostos;
                #endregion

                data.MembroAssegurado = data.MembroAssegurado.Select(m =>
                {
                    var analiseRisco = calculo.AnaliseRisco.FirstOrDefault(x => x.Pessoa.IdPessoa == m.PessoaId);
                    if (analiseRisco == null)
                    {
                        return(m);
                    }

                    #region Setters
                    m.PremioBase      = analiseRisco.PremioBase;
                    m.PremioRisco     = analiseRisco.PremioRisco;
                    m.PremioSimples   = analiseRisco.PremioSimples;
                    m.PremioComercial = analiseRisco.PremioComercial;
                    m.PremioCobrado   = analiseRisco.PremioCobrado;

                    m.Agravamentos         = analiseRisco.Agravamentos;
                    m.AgravamentosPorIdade = analiseRisco.AgravamentosPorIdade;
                    m.Arseg                 = analiseRisco.Arseg;
                    m.CapitalSeguro         = analiseRisco.CapitalSeguro;
                    m.EncargoAdministrativo = analiseRisco.EncargosAdministrativos;
                    m.Descontos             = analiseRisco.Descontos;
                    m.DescontosPorIdade     = analiseRisco.DescontosPorIdade;
                    m.Despesas              = analiseRisco.Despesas;
                    m.Impostos              = analiseRisco.Impostos;
                    m.Iva              = analiseRisco.Iva;
                    m.Ofertas          = analiseRisco.Ofertas;
                    m.SinistroEsperado = analiseRisco.SinistroEsperado;
                    #endregion

                    return(m);
                }).ToList();

                return(calculo);
            }

            // Criação de uma cotação
            FieldAsync <CotacaoType, CotacaoInputType, Cotacao>(param: new Param <Cotacao>
            {
                Add = async(data, context) =>
                {
                    // Efectuando os calculos
                    var cal = Calcular(data);


                    // Verificando se os calculos foram bem feitos
                    if (!cal.Status)
                    {
                        context.Errors.Add(new ExecutionError(cal.Message));
                        return(null);
                    }
                    await Repo.AddAsync(data);

                    var rabbit = new RabbitMQClient(Repo);
                    if (rabbit.CheckConn())
                    {
                        rabbit.Send(Exchange.MQExchange, "Cotacao", "A", data);
                    }

                    return(new RepoResponse <Cotacao> {
                        Data = data
                    });
                },
                Update = async(data, id, context) =>
                {
                    var cal = await repository.ExecuteAsync(async provider =>
                    {
                        return(await Task.FromResult(new Calculos(provider.GetService <DapperContext>(), provider.GetService <IRepository>())
                                                     .CalculoGeral(new CalculoModel {
                            Cotacao = data
                        })));
                    });

                    // Verificando se os calculos foram bem feitos
                    if (!cal.Status)
                    {
                        context.Errors.Add(new ExecutionError(cal.Message));
                        return(null);
                    }
                    await Repo.UpdateAsync(id, data);
                    return(default);