Example #1
0
        private async Task <List <ProfilesAndTestModelOeModel> > GetProfileAndTestOeModelFromSearchResultsAsync
            (GenericTwoListModel searchResults)
        {
            var profileAndTestOeDataList = new List <ProfilesAndTestModelOeModel>();
            var profiles     = (List <ProfileDatabaseModel>)searchResults.T1;      //Liver
            var ProfileTests = (List <ProfileTestsDatabaseModel>)searchResults.U1; //TBIL, DBIL, ....

            return(await Task.Run(() =>
            {
                foreach (var profile in profiles)
                {
                    var profileAndTestOeData = new ProfilesAndTestModelOeModel();

                    profileAndTestOeData.Id = profile.Id;
                    profileAndTestOeData.Description = profile.Description;
                    profileAndTestOeData.IsProfile = profile.IsProfile;

                    //Get Tests in profile
                    var testsInProfile = ProfileTests.Where((pt) =>
                    {
                        return pt.ProfileId == profile.Id;
                    }).ToList();


                    foreach (var test in testsInProfile)
                    {
                        var readyTestsInProfile = new TestsModel()
                        {
                            Id = test.TestId,
                            Description = test.Test,
                            IsReportable = test.IsReportable,
                            Mask = test.Mask,
                            ResultDataType = test.ResultDataType
                        };

                        profileAndTestOeData.TestsInProfile.Add(readyTestsInProfile);
                    }

                    profileAndTestOeDataList.Add(profileAndTestOeData);
                }

                return profileAndTestOeDataList;
            }));
        }
Example #2
0
        /// <summary>
        /// NOTE: T should be the first type of data set returned by the query / procedure
        /// NOTE: U should be the second type of data set returned by the query / procedure
        /// MEANS that the generic classes should be passed in the order that is expected to be returned by the query.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <typeparam name="U"></typeparam>
        /// <param name="storedProcedure"></param>
        /// <returns>returns a class with List<T> AND List<U> as public properties</returns>
        internal async Task <GenericTwoListModel> LoadStaticDataTwoSetsAsync <T, U>
            (string storedProcedure)
        {
            var genericTwoList = new GenericTwoListModel();
            var returnData     = genericTwoList.GetLists <T, U>();

            List <T> ListT = null;
            List <U> ListU = null;

            using (IDbConnection connection = new SqlConnection(helper.GetConnectionString()))
            {
                using (var lists = await connection.QueryMultipleAsync(storedProcedure, CommandType.StoredProcedure))
                {
                    ListT = lists.Read <T>().ToList();
                    ListU = lists.Read <U>().ToList();
                }
            }

            returnData.T1 = ListT;
            returnData.U1 = ListU;
            return(returnData);
        }