public ActionResult CopyCitation(MyLibraryModel Model, int specid, string actionFirst, string actionSecond, int oid, int fid, int MID, FormCollection Collection, int start = 1)
 {
     if (actionFirst != null)
     {
         if (!string.IsNullOrEmpty(Collection["ddlUserSubTopic"]))
         {
             var Result = MyLibraryBL.CopyCitation(MID, Collection["ddlUserSubTopic"], CurrentUser.UserId);
             return(RedirectToAction("index", "mylibrary", new { specid = Result, oid = Collection["SelectedTopic"], fid = Collection["ddlUserSubTopic"], selaction = "saved", start = start }));
         }
         else
         {
             return(RedirectToAction("abstract", "mylibrary", new { specid = specid, oid = oid, fid = fid, MID = MID }));
         }
     }
     else
     {
         if (!string.IsNullOrEmpty(Collection["ddlUserSubTopicSecond"]))
         {
             var Result = MyLibraryBL.CopyCitation(MID, Collection["ddlUserSubTopicSecond"], CurrentUser.UserId);
             return(RedirectToAction("index", "mylibrary", new { specid = Result, oid = Collection["SelectedTopicSecond"], fid = Collection["ddlUserSubTopicSecond"], selaction = "saved", start = start }));
         }
         else
         {
             return(RedirectToAction("abstract", "mylibrary", new { specid = specid, oid = oid, fid = fid, MID = MID }));
         }
     }
 }
        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 static bool Annotate(MyLibraryModel Model, int pmid, int UserId)
 {
     using (EditorsEntities entity = new EditorsEntities())
     {
         UserComment UpdateComment = (from u in entity.UserComments where u.userid == UserId && u.pmid == pmid select u).FirstOrDefault();
         if (UpdateComment == null)
         {
             UserComment NewUserComment = new UserComment();
             NewUserComment.pmid       = pmid;
             NewUserComment.userid     = UserId;
             NewUserComment.nickname   = Model.UserComment.nickname;
             NewUserComment.comment    = Model.UserComment.comment;
             NewUserComment.updatedate = DateTime.Now;
             NewUserComment.createdate = DateTime.Now;
             entity.UserComments.Add(NewUserComment);
         }
         else
         {
             UpdateComment.userid              = UserId;
             UpdateComment.nickname            = Model.UserComment.nickname;
             UpdateComment.comment             = Model.UserComment.comment;
             UpdateComment.updatedate          = DateTime.Now;
             entity.Entry(UpdateComment).State = EntityState.Modified;
         }
         entity.SaveChanges();
         return(true);
     }
 }
        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));
        }
        public ActionResult EditLibrary(int specid = 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.GetUserFolderListEdit(qsSpecId, CurrentUser.UserId);

            MainMyLibraryModel.AllUserFoldersEdit  = UserFolderList;
            MainMyLibraryModel.AllUserSpecialities = UserSpecialityList;
            MainMyLibraryModel.HiddenTopicIds      = MyLibraryBL.GetHiddenTopicIds(CurrentUser.UserId);
            MainMyLibraryModel.HiddenSubTopicIds   = MyLibraryBL.GetHiddenSubTopicIds(CurrentUser.UserId);
            ViewBag.SpecId        = qsSpecId;
            ViewBag.DefaultSpecId = UserSpecialityList.Select(n => n.SpecialityId).FirstOrDefault();
            return(View(MainMyLibraryModel));
        }
        public ActionResult LinkOut(int PMID = 0, int SpecialityID = 0, int oid = 0, int fid = 0)
        {
            int            qsSpecId           = SpecialityID;
            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();


            string Query = "http://eutils.ncbi.nlm.nih.gov/entrez/eutils/elink.fcgi?tool=CogentMedicineWebSite&[email protected]&dbfrom=pubmed&id=" + PMID + "&cmd=llinkslib";

            EditorsChoicemodel citations = UserBL.DisplayPMIDS(CurrentUser.UserId, PMID.ToString(), 2, 1);

            citations.SpecialtyID = Convert.ToInt32(SpecialityID);
            XmlDocument xdoc = new XmlDocument();

            xdoc.Load(Query);
            XDocument doc = XDocument.Load(Query);

            if (xdoc != null)
            {
                XmlNodeList xNodes = xdoc.DocumentElement.GetElementsByTagName("ObjUrl");

                List <FullTextLinkOuts> XMLDataList     = new List <FullTextLinkOuts>();
                List <FullTextLinkOuts> Aggregatorslist = new List <FullTextLinkOuts>();
                List <FullTextLinkOuts> ProvList        = new List <FullTextLinkOuts>();

                string str = string.Empty;

                foreach (XmlNode dStr in xNodes)
                {
                    try
                    {
                        FullTextLinkOuts XMLData = new FullTextLinkOuts();

                        XmlNode SubTypeNode = dStr.SelectSingleNode("SubjectType");

                        if (SubTypeNode.InnerText.ToLower() == "publishers/providers")
                        {
                            var Description = xdoc.SelectNodes("eLinkResult/LinkSet/IdUrlList/IdUrlSet/ObjUrl/Attribute");
                            XMLData.ProviderName = ((dStr.LastChild).FirstChild).InnerText;
                            XMLData.URLS         = (dStr.FirstChild).InnerText;
                            ProvList.Add(XMLData);
                        }
                        else if (SubTypeNode.InnerText.ToLower() == "aggregators")
                        {
                            string Description = xdoc.SelectSingleNode("eLinkResult/LinkSet/IdUrlList/IdUrlSet/ObjUrl/Attribute").InnerText;

                            XMLData.ProviderName = ((dStr.LastChild).FirstChild).InnerText;
                            XMLData.URLS         = (dStr.FirstChild).InnerText;
                            Aggregatorslist.Add(XMLData);
                        }
                        else
                        {
                            str = (dStr.FirstChild).InnerText;

                            if (str.Substring(0, 1) == "/")
                            {
                                str = "http://www.ncbi.nlm.nih.gov" + str;
                            }
                            XMLData.URLS         = str;
                            XMLData.ProviderName = ((dStr.LastChild).FirstChild).InnerText;

                            XMLDataList.Add(XMLData);
                        }
                    }
                    catch (Exception)
                    {
                    }
                }
                citations.linklist       = XMLDataList;
                citations.ProviderPublis = ProvList;
                citations.Aggregator     = Aggregatorslist;
            }
            citations.SpecialtyID = Convert.ToInt32(SpecialityID);
            citations.PMID        = Convert.ToInt32(PMID);


            MainMyLibraryModel.LinkoutModelVar = citations;
            return(View(MainMyLibraryModel));
        }
        public ActionResult Annotate(MyLibraryModel Model, int specid, int pmid, int oid, int fid, string selaction)
        {
            var Result = MyLibraryBL.Annotate(Model, pmid, CurrentUser.UserId);

            return(RedirectToAction("abstract", "mylibrary", new { specid = specid, oid = oid, fid = fid, MID = pmid, selaction = selaction }));
        }
        //
        // 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));
        }