//// To check UserHas SPocsor Folder and retrive the values
        //public static int CheckForUserSponsorFolder(int SpocorFolderId, int UserId)
        //{
        //    using (EditorsEntities entity = new EditorsEntities())
        //    {
        //        var UserSposorFolder = (from us in entity.UserHasSponsorFolders
        //                                where us.SponsorFolderId == SpocorFolderId && us.UserId == UserId
        //                                select us).FirstOrDefault();
        //        if (UserSposorFolder == null)
        //        {
        //            return SpocorFolderId;
        //        }
        //        else
        //        {
        //            return 0;
        //        }
        //    }
        //}

        // To Add Sposor folder Id
        //public static bool AddSponsorFolder(int sfid, int userid)
        //{
        //    using (EditorsEntities entity = new EditorsEntities())
        //    {

        //        var CheckForUserHas = (from us in entity.UserHasSponsorFolders
        //                               where us.UserId == userid && us.SponsorFolderId == sfid
        //                               select us).FirstOrDefault();

        //        if (CheckForUserHas != null)
        //        {
        //            return false;
        //        }

        //        var CheckSposorFolderExists = (from s in entity.SponsorFolders
        //                                       where s.id == sfid
        //                                       select s).FirstOrDefault();
        //        if (CheckSposorFolderExists == null)
        //        {
        //            return false;
        //        }



        //        string query = "[lib_CreateSponsorFolderSFE] @UserID,@UserSpecialty,@SponsorFolderID,@TopicFolderID  OUT";
        //        var parameters = new[]
        //        {
        //            new SqlParameter("@UserID", userid),
        //            new SqlParameter("@UserSpecialty", 1),
        //            new SqlParameter("@SponsorFolderID", sfid),
        //            new SqlParameter("@TopicFolderID",SqlDbType.Int){ Direction = ParameterDirection.Output }
        //        };
        //        var AddSponsorFolderResult = entity.Database.SqlQuery<AddSponsorFolderTemp>(query, parameters).FirstOrDefault();

        //        int TopicFolderID;
        //        TopicFolderID = (Int32)parameters[0].Value;


        //        string query1 = "[lib_GetDefaultSubTopic] @UserID,@TopicID,@SubTopicID  OUT";
        //        var parameters1 = new[]
        //        {
        //            new SqlParameter("@UserID", userid),
        //            new SqlParameter("@TopicID", TopicFolderID),
        //            new SqlParameter("@SubTopicID",SqlDbType.Int){ Direction = ParameterDirection.Output }
        //        };
        //        var GetSubTopicResult = entity.Database.SqlQuery<AddSponsorFolderTemp>(query1, parameters1).ToList();

        //        int SubTopicId = (Int32)parameters1[0].Value;

        //        //
        //        if (CheckSposorFolderExists.FolderName == "EUSA")
        //        {
        //            //SearchBL.ManageQuery Model = new SearchBL.ManageQuery();
        //            //Model.SearchId = 0;
        //            //Model.Name="Caphosol(EUSA)";
        //            //Model.Autosearch = true;
        //            //Model.resultFolder2 = 2182;
        //            //Model.ShelfLife = "7";
        //            //Model.Description = "";
        //            //Model.KeepDelete = 0;
        //            //Model.tab

        //            //if (!string.IsNullOrEmpty(Collection["ddlUserSubTopic"]))
        //            //    Model.resultFolder2 = Convert.ToInt32(Collection["ddlUserSubTopic"]);
        //            //TempData["SavedQueryDet"] = SearchBL.UpdateSearchQuery(Model);


        //        }


        //        //   <!--- Create the Auto Query --->
        //        //<!--- we need a search ID no matter what for the update code below --->

        //        UserHasSponsorFolder NewSposorFolder = new UserHasSponsorFolder();
        //        NewSposorFolder.AutoQueryId = 0;
        //        NewSposorFolder.createtime = DateTime.Now;
        //        NewSposorFolder.SponsorFolderId = sfid;
        //        NewSposorFolder.UserFolderId = Convert.ToInt32(SubTopicId);
        //        NewSposorFolder.UserId = userid;

        //        entity.UserHasSponsorFolders.Add(NewSposorFolder);
        //        entity.SaveChanges();
        //        return true;
        //    }
        //}

        // To Get Genes
        public static List <GeneMyLibrary> GetGenesMyLibrary(int PMID)
        {
            using (EditorsEntities entity = new EditorsEntities())
            {
                var Result = entity.lib_GetGenesForCitation(PMID);
                List <GeneMyLibrary> ResultMain = new List <GeneMyLibrary>();
                foreach (var item in Result)
                {
                    GeneMyLibrary Gene = new GeneMyLibrary();
                    Gene.GeneId = item.GeneID;
                    Gene.Name   = item.name;
                    ResultMain.Add(Gene);
                }
                return(ResultMain);
            }
        }