public ActionResult Abstract(int specid = 0, int oid = 0, int fid = 0, string selaction = null, string sort = "date", string searchfolder = "", int MID = 0)
        {
            int            qsSpecId           = specid;
            MyLibraryModel MainMyLibraryModel = new MyLibraryModel();
            var            UserSpecialityList = MyLibraryBL.GetUserSpecialities(CurrentUser.UserId);

            if (qsSpecId == 0)
            {
                qsSpecId = UserSpecialityList.Select(n => n.SpecialityId).FirstOrDefault();
            }
            var UserFolderList = MyLibraryBL.GetUserFolderList(qsSpecId, CurrentUser.UserId);

            MainMyLibraryModel.AllUserFolders      = UserFolderList;
            MainMyLibraryModel.AllUserSpecialities = UserSpecialityList;
            ViewBag.SpecId = qsSpecId;
            ViewBag.PrimarySpecialityId = UserSpecialityList.Select(n => n.SpecialityId).FirstOrDefault();

            if (MID != 0)
            {
                CitationsModel pmid = new CitationsModel();
                pmid.pmid = MID;
                List <CitationsModel> PMIDCitation = new List <CitationsModel>();
                PMIDCitation.Add(pmid);
                MainMyLibraryModel.CitationDetails        = MyLibraryBL.GetCitationDetails(PMIDCitation, sort, CurrentUser.UserId, 2, true);
                MainMyLibraryModel.UserComment            = MyLibraryBL.GetUserComment(MID, CurrentUser.UserId);
                MainMyLibraryModel.AbstractCommentsECList = MyLibraryBL.GetAbstractCommentsEC(MID);
            }
            return(View(MainMyLibraryModel));
        }
        public ActionResult AbstractPrintable(int specid = 0, int oid = 0, int fid = 0, string selaction = null, string sort = "date", string searchfolder = "", int MID = 0)
        {
            int            qsSpecId           = specid;
            MyLibraryModel MainMyLibraryModel = new MyLibraryModel();

            if (MID != 0)
            {
                CitationsModel pmid = new CitationsModel();
                pmid.pmid = MID;
                List <CitationsModel> PMIDCitation = new List <CitationsModel>();
                PMIDCitation.Add(pmid);
                MainMyLibraryModel.CitationDetails        = MyLibraryBL.GetCitationDetails(PMIDCitation, sort, CurrentUser.UserId, 2, true);
                MainMyLibraryModel.UserComment            = MyLibraryBL.GetUserComment(MID, CurrentUser.UserId);
                MainMyLibraryModel.AbstractCommentsECList = MyLibraryBL.GetAbstractCommentsEC(MID);
            }
            return(View(MainMyLibraryModel));
        }
        //
        // GET: /mylibrary/
        public ActionResult Index(int specid = 0, int oid = 0, int fid = 0, string selaction = null, string sort = "date", string searchfolder = "", string page = "", int start = 1)
        {
            int            qsSpecId           = specid;
            MyLibraryModel MainMyLibraryModel = new MyLibraryModel();
            var            UserSpecialityList = MyLibraryBL.GetUserSpecialities(CurrentUser.UserId);

            if (qsSpecId == 0)
            {
                qsSpecId = UserSpecialityList.Select(n => n.SpecialityId).FirstOrDefault();
            }
            var UserFolderList = MyLibraryBL.GetUserFolderList(qsSpecId, CurrentUser.UserId);

            MainMyLibraryModel.AllUserFolders      = UserFolderList;
            MainMyLibraryModel.AllUserSpecialities = UserSpecialityList;
            ViewBag.SpecId = qsSpecId;
            ViewBag.PrimarySpecialityId = UserSpecialityList.Select(n => n.SpecialityId).FirstOrDefault();

            // For Citation

            if (selaction == "saved")
            {
                MainMyLibraryModel.Citations = MyLibraryBL.GetCitations(fid, CurrentUser.UserId);
                if (MainMyLibraryModel.Citations.Count > 0)
                {
                    MainMyLibraryModel.CitationDetails = MyLibraryBL.GetCitationDetails(MainMyLibraryModel.Citations, sort, CurrentUser.UserId, 2);
                }
                else
                {
                    MainMyLibraryModel.CitationDetails = null;
                }
            }
            else if (selaction == "editor")
            {
                MainMyLibraryModel.PMIDs     = MyLibraryBL.GetEditorsChoicePMids(fid);
                MainMyLibraryModel.Citations = MyLibraryBL.GetEditorsChoiceCitations(fid, CurrentUser.UserId);
                if (MainMyLibraryModel.Citations.Count > 0)
                {
                    MainMyLibraryModel.CitationDetails = MyLibraryBL.GetCitationDetails(MainMyLibraryModel.Citations, sort, CurrentUser.UserId, 2);
                }
                else
                {
                    MainMyLibraryModel.CitationDetails = null;
                }
            }

            else if (selaction == "seminal")
            {
                MainMyLibraryModel.PMIDs     = MyLibraryBL.GetSeminalPMids(fid);
                MainMyLibraryModel.Citations = MyLibraryBL.GetSeminalCitations(fid, CurrentUser.UserId);
                if (MainMyLibraryModel.Citations.Count > 0)
                {
                    MainMyLibraryModel.CitationDetails = MyLibraryBL.GetCitationDetails(MainMyLibraryModel.Citations, sort, CurrentUser.UserId, 2);
                }
                else
                {
                    MainMyLibraryModel.CitationDetails = null;
                }
            }

            else if (selaction == "sponsor")
            {
                MainMyLibraryModel.PMIDs     = MyLibraryBL.GetSponsorPMids(fid);
                MainMyLibraryModel.Citations = MyLibraryBL.GetSponsorCitations(fid, CurrentUser.UserId);
                if (MainMyLibraryModel.Citations.Count > 0)
                {
                    MainMyLibraryModel.CitationDetails = MyLibraryBL.GetCitationDetails(MainMyLibraryModel.Citations, sort, CurrentUser.UserId, 2);
                }
                else
                {
                    MainMyLibraryModel.CitationDetails = null;
                }
            }

            else if (selaction == "acr")
            {
                MainMyLibraryModel.AcrDocumentsMyLibraryList = MyLibraryBL.getAcrDocumentsList(fid);
            }

            if (!string.IsNullOrEmpty(searchfolder))
            {
                MainMyLibraryModel.CitationDetails = MainMyLibraryModel.CitationDetails.Where(c => c.pmid.ToString() == searchfolder || (c.AuthorList ?? "").Contains(searchfolder) || (c.ArticleTitle ?? "").Contains(searchfolder) || (c.MedlinePgn ?? "").Contains(searchfolder) || (c.MedlineTA ?? "").Contains(searchfolder)).ToList();
            }

            if (MainMyLibraryModel.CitationDetails != null)
            {
                MainMyLibraryModel.CitationDetailsTotal = MainMyLibraryModel.CitationDetails;
                MainMyLibraryModel.CitationDetails      = MainMyLibraryModel.CitationDetailsTotal.Skip(start - 1).Take(25).ToList();

                using (Cogent3Entities entity = new Cogent3Entities())
                {
                    foreach (var item in MainMyLibraryModel.CitationDetails)
                    {
                        if ((!item.unicodeFixed.HasValue) || (item.unicodeFixed == false))
                        {
                            if ((item.ArticleTitle ?? "").Contains("?") || (item.ArticleTitle ?? "").Contains("="))
                            {
                                List <string> ArticleTitleWithNoIssue = MyLibraryBL.GetAbstractWithNoIssue(item.pmid);

                                if (ArticleTitleWithNoIssue.Count == 2)
                                {
                                    item.ArticleTitle = ArticleTitleWithNoIssue[1];

                                    int PMID       = Convert.ToInt32(item.pmid);
                                    var IwideTable = (from iw in entity.iWides where iw.PMID == item.pmid select iw).FirstOrDefault();

                                    if (IwideTable != null)
                                    {                                    //AbstractArticleTitleNew[0] is for Abstract Text and AbstractArticleTitleNew[1] is for Article Title;;
                                        item.ArticleTitle              = ArticleTitleWithNoIssue[1];
                                        IwideTable.ArticleTitle        = ArticleTitleWithNoIssue[1];
                                        entity.Entry(IwideTable).State = EntityState.Modified;
                                    }

                                    var IwideNewTable = (from iw in entity.iWideNews where iw.PMID == item.pmid select iw).FirstOrDefault();

                                    if (IwideNewTable != null)
                                    {
                                        item.ArticleTitle                 = ArticleTitleWithNoIssue[1];
                                        IwideNewTable.ArticleTitle        = ArticleTitleWithNoIssue[1];
                                        entity.Entry(IwideNewTable).State = EntityState.Modified;
                                    }
                                }
                            }
                        }
                    }

                    entity.SaveChanges();
                }
            }

            return(View(MainMyLibraryModel));
        }
        //
        // GET: /MyQueries/

        #region

        public ActionResult MyQueries(int?FID, int?searchid, string SearchName, string searchfolder = "", int start = 1)
        {
            int userid = AJA_Core.CurrentUser.UserId;

            SearchBL.MyQueryForm        myQyeryForm   = new SearchBL.MyQueryForm();
            List <SearchBL.MyQueryForm> myQueriesList = new List <SearchBL.MyQueryForm>();

            myQueriesList             = SearchBL.MyQueriesList(userid);
            myQyeryForm.myQueriesList = myQueriesList;
            myQyeryForm.Isendemail    = SearchBL.GetIsSendEmail(userid);
            if (searchid != 0 && !string.IsNullOrEmpty(SearchName))
            {
                myQyeryForm.queryDetails = SearchBL.GetSearchQuery(userid, SearchName, searchid);
                myQyeryForm.searchInfo   = SearchBL.GetSearchInfo(userid, SearchName, Convert.ToInt32(searchid));
                SearchBL.ManageQuery MQ = new SearchBL.ManageQuery();
                MQ.SearchId    = searchid; MQ.QueryDetails = myQyeryForm.searchInfo.QueryDetails; MQ.Name = myQyeryForm.queryDetails.SearchName;
                MQ.Description = myQyeryForm.queryDetails.Description; MQ.Autosearch = Convert.ToBoolean(myQyeryForm.queryDetails.AutoSearch);
                MQ.KeepDelete  = Convert.ToInt32(myQyeryForm.queryDetails.KeepDelete);
                MQ.ShelfLife   = myQyeryForm.queryDetails.ShelfLife.ToString();

                if (FID != 0)
                {
                    myQyeryForm.queryDestination = SearchBL.GetQueryDestination(Convert.ToInt32(FID));
                    MQ.FolderID = FID;
                    if (myQyeryForm.queryDestination != null)
                    {
                        MQ.DestinationFolder = myQyeryForm.queryDestination.SpecialtyName + " / " + myQyeryForm.queryDestination.TopicName + " / " + myQyeryForm.queryDestination.SubTopicName;
                    }

                    myQyeryForm.Citations = SearchBL.GetSearchCitations(Convert.ToInt32(searchid), CurrentUser.UserId);

                    if (myQyeryForm.Citations.Count > 0)
                    {
                        myQyeryForm.CitationDetails = MyLibraryBL.GetCitationDetails(myQyeryForm.Citations, "date", CurrentUser.UserId, 1);
                        TimeSpan timespan = (DateTime.Now - Convert.ToDateTime(myQyeryForm.Citations[0].expiredate));
                        if (myQyeryForm.Citations[0].keepdelete)
                        {
                            myQyeryForm.TrackDays = timespan.Days.ToString() + " days until keep";
                        }
                        else
                        {
                            myQyeryForm.TrackDays = timespan.Days.ToString() + " days until delete";
                        }
                    }
                    else
                    {
                        myQyeryForm.CitationDetails = null;
                    }
                }
                if (!string.IsNullOrEmpty(searchfolder))
                {
                    myQyeryForm.CitationDetails = myQyeryForm.CitationDetails.Where(c => c.pmid.ToString() == searchfolder || (c.AuthorList ?? "").Contains(searchfolder) || (c.ArticleTitle ?? "").Contains(searchfolder) || (c.MedlinePgn ?? "").Contains(searchfolder) || (c.MedlineTA ?? "").Contains(searchfolder)).ToList();
                }
                if (myQyeryForm.CitationDetails != null)
                {
                    myQyeryForm.CitationDetailsTotal = myQyeryForm.CitationDetails;
                    myQyeryForm.CitationDetails      = myQyeryForm.CitationDetailsTotal.Skip(start - 1).Take(15).ToList();
                }

                Session["ManageQuery"] = MQ;
            }
            return(View(myQyeryForm));
        }