public async Task <Results <FTMView> > FTMViewList(DNASearchParamObj searchParams)
        {
            var dupeList = new List <FTMView>();

            var results = new Results <FTMView>();

            int totalRecs = 0;

            try
            {
                var a = new AzureDBContext(_imsConfigHelper.MSGGenDB01);



                var unpaged = a.FTMPersonView.Where(w => w.Surname != "")
                              .WhereIfSurname(searchParams.Surname)
                              .WhereIfLocation(searchParams.Location)
                              .WhereIfYearsBetween(searchParams.YearStart, searchParams.YearEnd)
                              .FTMViewSortIf(searchParams.SortColumn, searchParams.SortOrder);

                totalRecs = unpaged.Count();

                foreach (var app in unpaged.Skip(searchParams.Offset).Take(searchParams.Limit))
                {
                    dupeList.Add(new FTMView()
                    {
                        Id              = app.Id,
                        FirstName       = app.FirstName ?? "",
                        Surname         = app.Surname ?? "",
                        AltLocation     = app.AltLocation ?? "",
                        AltLat          = app.AltLat.GetValueOrDefault(),
                        AltLocationDesc = app.AltLocationDesc ?? "",
                        AltLong         = app.AltLong.GetValueOrDefault(),
                        YearFrom        = app.YearFrom,
                        YearTo          = app.YearTo,
                        BirthLat        = app.BirthLat.GetValueOrDefault(),
                        Location        = app.Location ?? "",
                        BirthLong       = app.BirthLong.GetValueOrDefault(),
                        Origin          = app.Origin ?? "",
                        PersonId        = app.PersonId
                    });
                }
            }
            catch (Exception e)
            {
                results.Error = e.Message;
            }



            results.results       = dupeList;
            results.Page          = searchParams.Offset == 0 ? 0 : searchParams.Offset / searchParams.Limit;
            results.total_pages   = totalRecs / searchParams.Limit;
            results.total_results = totalRecs;

            return(results);
        }
        public async Task <Results <Dupe> > DupeList(DNASearchParamObj searchParams)
        {
            var dupeList = new List <Dupe>();

            var results = new Results <Dupe>();

            int totalRecs = 0;

            try
            {
                var a = new AzureDBContext(_imsConfigHelper.MSGGenDB01);


                var unpaged = a.DupeEntries
                              .WhereIfSurname(searchParams.Surname)
                              .DupeSortIf(searchParams.SortColumn, searchParams.SortOrder);

                totalRecs = unpaged.Count();

                foreach (var app in unpaged.Skip(searchParams.Offset).Take(searchParams.Limit))
                {
                    dupeList.Add(new Dupe()
                    {
                        Id        = app.Id,
                        FirstName = app.FirstName ?? "",
                        Surname   = app.Surname ?? "",
                        YearFrom  = app.YearFrom,
                        YearTo    = app.YearTo,
                        Ident     = app.Ident ?? "",
                        Location  = app.Location ?? "",
                        Origin    = app.Origin ?? "",
                        PersonId  = app.PersonId
                    });
                }
            }
            catch (Exception e)
            {
                results.Error = e.Message;
            }



            results.results       = dupeList;
            results.Page          = searchParams.Offset == 0 ? 0 : searchParams.Offset / searchParams.Limit;
            results.total_pages   = totalRecs / searchParams.Limit;
            results.total_results = totalRecs;

            return(results);
        }
        public async Task <Results <TreeRec> > TreeList(DNASearchParamObj searchParams)
        {
            var dupeList = new List <TreeRec>();
            var results  = new Results <TreeRec>();

            int totalRecs = 0;

            try
            {
                var a = new AzureDBContext(_imsConfigHelper.MSGGenDB01);

                var unpaged = a.TreeRecord.WhereIfOrigin(searchParams.Origin).TreeRecSortIf(searchParams.SortColumn, searchParams.SortOrder);

                totalRecs = unpaged.Count();

                foreach (var app in unpaged.Skip(searchParams.Offset).Take(searchParams.Limit))
                {
                    dupeList.Add(new TreeRec()
                    {
                        Id          = app.ID,
                        CM          = app.CM,
                        Located     = app.Located,
                        Origin      = app.Origin ?? "",
                        PersonCount = app.PersonCount,
                        Name        = app.Name
                    });
                }
            }
            catch (Exception e)
            {
                results.Error = e.Message;
            }



            results.results       = dupeList;
            results.Page          = searchParams.Offset == 0 ? 0 : searchParams.Offset / searchParams.Limit;
            results.total_pages   = totalRecs / searchParams.Limit;
            results.total_results = totalRecs;

            return(results);
        }
        public async Task <Results <PersonOfInterestSubset> > PersonOfInterestList(DNASearchParamObj searchParams)
        {
            var dupeList = new List <PersonOfInterestSubset>();
            var results  = new Results <PersonOfInterestSubset>();

            int totalRecs = 0;

            try
            {
                var a = new AzureDBContext(_imsConfigHelper.MSGGenDB01);

                var unpaged = a.PersonsOfInterest
                              .WhereIfTesterName(searchParams.Name)
                              .WhereIfSurname(searchParams.Surname)
                              .WhereIfLocation(searchParams.Location)
                              .WhereIfMinCM(searchParams.MinCM)
                              .WhereIfYearBetween(searchParams.YearStart, searchParams.YearEnd)
                              .PersonOfInterestSortIf(searchParams.SortColumn, searchParams.SortOrder);

                totalRecs = unpaged.Count();

                foreach (var app in unpaged.Skip(searchParams.Offset).Take(searchParams.Limit))
                {
                    dupeList.Add(new PersonOfInterestSubset()
                    {
                        Id                   = app.Id,
                        BirthCountry         = app.BirthCountry ?? "",
                        BirthCounty          = app.BirthCounty ?? "",
                        BirthPlace           = app.Location ?? "",
                        BirthYear            = app.Year,
                        ChristianName        = app.ChristianName ?? "",
                        Confidence           = app.Confidence,
                        CreatedDate          = app.CreatedDate,
                        KitId                = app.KitId,
                        Memory               = app.Memory ?? "",
                        Name                 = app.Name ?? "",
                        RootsEntry           = app.RootsEntry,
                        SharedCentimorgans   = app.SharedCentimorgans,
                        TestAdminDisplayName = app.TestAdminDisplayName ?? "",
                        TestDisplayName      = app.TestDisplayName ?? "",
                        TestGuid             = app.TestGuid,
                        TreeUrl              = app.TreeUrl ?? "",
                        Surname              = app.Surname ?? "",

                        PersonId = app.PersonId
                    });
                }
            }
            catch (Exception e)
            {
                results.Error = e.Message;
            }



            results.results       = dupeList;
            results.Page          = searchParams.Offset == 0 ? 0 : searchParams.Offset / searchParams.Limit;
            results.total_pages   = totalRecs / searchParams.Limit;
            results.total_results = totalRecs;

            return(results);
        }
Example #5
0
        public DNAQuery(IDNAAnalyseListService service)
        {
            Name = "Dna";

            #region dupesearch
            FieldAsync <DupeResult, Results <Dupe> >(
                "dupesearch",
                arguments: new QueryArguments(
                    new QueryArgument <StringGraphType> {
                Name = "query"
            },
                    new QueryArgument <IntGraphType> {
                Name = "limit"
            },
                    new QueryArgument <IntGraphType> {
                Name = "offset"
            },
                    new QueryArgument <StringGraphType> {
                Name = "sortColumn"
            },
                    new QueryArgument <StringGraphType> {
                Name = "sortOrder"
            },
                    new QueryArgument <StringGraphType> {
                Name = "surname"
            }

                    ),
                resolve: context =>
            {
                ClaimsPrincipal currentUser = null;

                try
                {
                    currentUser = (ClaimsPrincipal)context.UserContext["claimsprincipal"];
                }
                catch (Exception e)
                {
                }

                var obj = new Dictionary <string, string>();

                var query  = context.GetArgument <string>("query");
                var limit  = context.GetArgument <int>("limit");
                var offset = context.GetArgument <int>("offset");

                var sortColumn = context.GetArgument <string>("sortColumn");
                var sortOrder  = context.GetArgument <string>("sortOrder");

                var surname = context.GetArgument <string>("surname");


                var pobj = new DNASearchParamObj();

                pobj.User       = currentUser;
                pobj.Limit      = limit;
                pobj.Offset     = offset;
                pobj.SortColumn = sortColumn;
                pobj.SortOrder  = sortOrder;


                pobj.Surname = surname;



                return(service.DupeList(pobj));
            }
                );

            #endregion


            #region ftmviewsearch

            FieldAsync <FTMViewResult, Results <FTMView> >(
                "ftmviewsearch",
                arguments: new QueryArguments(
                    new QueryArgument <StringGraphType> {
                Name = "query"
            },
                    new QueryArgument <IntGraphType> {
                Name = "limit"
            },
                    new QueryArgument <IntGraphType> {
                Name = "offset"
            },
                    new QueryArgument <StringGraphType> {
                Name = "sortColumn"
            },
                    new QueryArgument <StringGraphType> {
                Name = "sortOrder"
            },
                    new QueryArgument <IntGraphType> {
                Name = "yearStart"
            },
                    new QueryArgument <IntGraphType> {
                Name = "yearEnd"
            },
                    new QueryArgument <StringGraphType> {
                Name = "location"
            },
                    new QueryArgument <StringGraphType> {
                Name = "surname"
            }


                    ),
                resolve: context =>
            {
                ClaimsPrincipal currentUser = null;

                try
                {
                    currentUser = (ClaimsPrincipal)context.UserContext["claimsprincipal"];
                }
                catch (Exception e)
                {
                }

                var obj = new Dictionary <string, string>();

                var query  = context.GetArgument <string>("query");
                var limit  = context.GetArgument <int>("limit");
                var offset = context.GetArgument <int>("offset");

                var sortColumn = context.GetArgument <string>("sortColumn");
                var sortOrder  = context.GetArgument <string>("sortOrder");

                var yearStart = context.GetArgument <int>("yearStart");
                var yearEnd   = context.GetArgument <int>("yearEnd");

                //	var refArg = context.GetArgument<string>("ref");
                //var desc = context.GetArgument<string>("desc");
                var place   = context.GetArgument <string>("location");
                var surname = context.GetArgument <string>("surname");


                var pobj = new DNASearchParamObj();

                pobj.User       = currentUser;
                pobj.Limit      = limit;
                pobj.Offset     = offset;
                pobj.SortColumn = sortColumn;
                pobj.SortOrder  = sortOrder;
                pobj.YearEnd    = yearEnd;
                pobj.YearStart  = yearStart;
                pobj.Location   = place;
                pobj.Surname    = surname;



                return(service.FTMViewList(pobj));
            }
                );

            #endregion

            #region poi search

            FieldAsync <PersonOfInterestResult, Results <PersonOfInterestSubset> >(
                "poisearch",
                arguments: new QueryArguments(
                    new QueryArgument <StringGraphType> {
                Name = "query"
            },
                    new QueryArgument <IntGraphType> {
                Name = "limit"
            },
                    new QueryArgument <IntGraphType> {
                Name = "offset"
            },
                    new QueryArgument <StringGraphType> {
                Name = "sortColumn"
            },
                    new QueryArgument <StringGraphType> {
                Name = "sortOrder"
            },
                    new QueryArgument <IntGraphType> {
                Name = "yearStart"
            },
                    new QueryArgument <IntGraphType> {
                Name = "yearEnd"
            },
                    new QueryArgument <StringGraphType> {
                Name = "location"
            },
                    new QueryArgument <StringGraphType> {
                Name = "surname"
            },
                    new QueryArgument <IntGraphType> {
                Name = "mincm"
            },
                    new QueryArgument <StringGraphType> {
                Name = "country"
            },
                    new QueryArgument <StringGraphType> {
                Name = "name"
            }

                    ),
                resolve: context =>
            {
                ClaimsPrincipal currentUser = null;

                try
                {
                    currentUser = (ClaimsPrincipal)context.UserContext["claimsprincipal"];
                }
                catch (Exception e)
                {
                }

                var obj = new Dictionary <string, string>();

                var query      = context.GetArgument <string>("query");
                var limit      = context.GetArgument <int>("limit");
                var offset     = context.GetArgument <int>("offset");
                var sortColumn = context.GetArgument <string>("sortColumn");
                var sortOrder  = context.GetArgument <string>("sortOrder");
                var yearStart  = context.GetArgument <int>("yearStart");
                var yearEnd    = context.GetArgument <int>("yearEnd");
                var location   = context.GetArgument <string>("location");
                var mincm      = context.GetArgument <int>("mincm");
                var surname    = context.GetArgument <string>("surname");
                var country    = context.GetArgument <string>("country");
                var name       = context.GetArgument <string>("name");

                var pobj = new DNASearchParamObj();

                pobj.User       = currentUser;
                pobj.Limit      = limit;
                pobj.Offset     = offset;
                pobj.SortColumn = sortColumn;
                pobj.SortOrder  = sortOrder;
                pobj.YearEnd    = yearEnd;
                pobj.YearStart  = yearStart;
                pobj.Surname    = surname;
                pobj.Country    = country;
                pobj.MinCM      = mincm;
                pobj.Name       = name;
                pobj.Location   = location;

                return(service.PersonOfInterestList(pobj));
            }
                );

            #endregion

            #region treerecsearch
            FieldAsync <TreeRecResult, Results <TreeRec> >(
                "treerecsearch",
                arguments: new QueryArguments(
                    new QueryArgument <StringGraphType> {
                Name = "query"
            },
                    new QueryArgument <IntGraphType> {
                Name = "limit"
            },
                    new QueryArgument <IntGraphType> {
                Name = "offset"
            },
                    new QueryArgument <StringGraphType> {
                Name = "sortColumn"
            },
                    new QueryArgument <StringGraphType> {
                Name = "sortOrder"
            },
                    new QueryArgument <StringGraphType> {
                Name = "origin"
            }
                    ),
                resolve: context =>
            {
                ClaimsPrincipal currentUser = null;

                try
                {
                    currentUser = (ClaimsPrincipal)context.UserContext["claimsprincipal"];
                }
                catch (Exception e)
                {
                }

                var obj = new Dictionary <string, string>();

                var query  = context.GetArgument <string>("query");
                var limit  = context.GetArgument <int>("limit");
                var offset = context.GetArgument <int>("offset");

                var sortColumn = context.GetArgument <string>("sortColumn");
                var sortOrder  = context.GetArgument <string>("sortOrder");

                var origin = context.GetArgument <string>("origin");

                var pobj = new DNASearchParamObj();

                pobj.User       = currentUser;
                pobj.Limit      = limit;
                pobj.Offset     = offset;
                pobj.SortColumn = sortColumn;
                pobj.SortOrder  = sortOrder;
                pobj.Origin     = origin;

                return(service.TreeList(pobj));
            }
                );

            #endregion
        }