コード例 #1
0
        // For Deleting Specialty

        public static bool DeleteSpecialty(int specid, int UserId)
        {
            using (EditorsEntities entity = new EditorsEntities())
            {
                var Topics = (from s in entity.Topics
                              where s.UserID == UserId && s.Type == 2 && s.SpecialtyID == specid
                              select s.TopicID).ToList();

                foreach (var TopicId in Topics)
                {
                    DeleteUserTopic(entity, TopicId, UserId);
                }


                //Nuke all auto-queries associated with this specialty

                entity.lib_DeleteUserAutoQueries(specid, UserId); // Executing lib_DeleteUserAutoQueries stored procedure

                // Finally, delete the enclosing specialty itself

                var UserSpecialtyToBeDelete = entity.UserSpecialties.Where(s => s.SpecialtyID == specid && s.UserID == UserId).FirstOrDefault();
                if (UserSpecialtyToBeDelete != null)
                {
                    entity.UserSpecialties.Remove(UserSpecialtyToBeDelete);
                }
                entity.SaveChanges();
                return(true);
            }
        }
コード例 #2
0
        // For Deleting User SubTopic Calling from above
        static void DeleteUserSubTopic(EditorsEntities entity, int SubTopicId, int UserId)
        {
            // First, delete UserCitations for this SubTopic
            var UserCitationsToBeDeleted = entity.UserCitations.Where(u => u.SubTopicID == SubTopicId && u.UserID == UserId).ToList();

            foreach (UserCitation UC in UserCitationsToBeDeleted)
            {
                entity.UserCitations.Remove(UC);
            }

            // Deleted UserCitations by above statement

            // Second, delete searches for this SubTopic

            entity.lib_DeleteSearchesFromSubTopic(SubTopicId, UserId);   // Executing lib_DeleteSearchesFromSubTopic Stored Procedure.

            // Delete searches for this SubTopic by above stored procedure

            // Third, delete this SubTopic from subtopics and userhas sponsersubtopic
            var UserSubTopicToBeDeleted = entity.SubTopics.Where(s => s.SubTopicID == SubTopicId && s.UserID == UserId && s.Type == 2).FirstOrDefault();

            if (UserSubTopicToBeDeleted != null)
            {
                entity.SubTopics.Remove(UserSubTopicToBeDeleted);
            }

            var UserSponsorFolderToBeDeleted = entity.UserHasSponsorFolders.Where(s => s.UserFolderId == SubTopicId && s.UserId == UserId).FirstOrDefault();

            if (UserSponsorFolderToBeDeleted != null)
            {
                entity.UserHasSponsorFolders.Remove(UserSponsorFolderToBeDeleted);
            }
            entity.SaveChanges();
        }
コード例 #3
0
 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);
     }
 }
コード例 #4
0
        // To Hide UserTopic

        public static bool HideTopics(List <int> TopicIds, int UserId)
        {
            using (EditorsEntities entity = new EditorsEntities())
            {
                foreach (var TopicId in TopicIds)
                {
                    HideTopic(entity, TopicId, UserId);
                }
                entity.SaveChanges();
                return(true);
            }
        }
コード例 #5
0
 // To Add User Specialty
 public static bool AddUserSpecialty(GetUserSpecialtyModel Model, int UserId)
 {
     using (EditorsEntities entity = new EditorsEntities())
     {
         UserSpecialty UsNew = new UserSpecialty();
         UsNew.SpecialtyID = (Int32)Model.SelectedSpecialtyId;
         UsNew.UserID      = UserId;
         UsNew.DateAdded   = DateTime.Now;
         entity.UserSpecialties.Add(UsNew);
         entity.SaveChanges();
         return(true);
     }
 }
コード例 #6
0
 // For Delete ACR Document Relation
 public static bool DeleteACRDocumentRelation(int RelId)
 {
     using (EditorsEntities entity = new EditorsEntities())
     {
         doc_in_subtopic docRelation = entity.doc_in_subtopic.Find(RelId);
         if (docRelation != null)
         {
             entity.doc_in_subtopic.Remove(docRelation);
             entity.SaveChanges();
         }
         return(true);
     }
 }
コード例 #7
0
        // For delete ACR Document

        public static bool DeleteACRDocument(int docId)
        {
            using (EditorsEntities entity = new EditorsEntities())
            {
                doc DeleteDoc = entity.docs.Find(docId);
                if (DeleteDoc != null)
                {
                    entity.docs.Remove(DeleteDoc);
                    entity.SaveChanges();
                }
                return(true);
            }
        }
コード例 #8
0
        static void DeleteUserSposorTopic(EditorsEntities entity, int TopicId, int UserId)
        {
            // First need to Get and delete SubTopics in the Topic which is going to Delete
            var Subtopics = (from s in entity.SubTopics
                             where s.TopicID == TopicId && (((s.Type == 2) && s.UserID == UserId) || s.Type == 3)
                             select s.SubTopicID).ToList();

            foreach (var SubTopicId in Subtopics)
            {
                DeleteUserSubTopic(entity, SubTopicId, UserId);
            }
            entity.lib_RemoveSponsorTopic(UserId, TopicId);
            entity.SaveChanges();
        }
コード例 #9
0
 // To Delete UserCitation
 public static bool DeleteCitation(int fid, int mid, int userid)
 {
     using (EditorsEntities entity = new EditorsEntities())
     {
         UserCitation UC = entity.UserCitations.Where(c => c.UserID == userid && c.PMID == mid && c.SubTopicID == fid).FirstOrDefault();
         if (UC != null)
         {
             UC.Deleted             = true;
             entity.Entry(UC).State = EntityState.Modified;
             entity.SaveChanges();
         }
         return(true);
     }
 }
コード例 #10
0
 public static bool AddDocument(ACRDocumentsModel ModelAddDocument)
 {
     using (EditorsEntities entity = new EditorsEntities())
     {
         doc newDoc = new doc();
         newDoc.source          = ModelAddDocument.Source;
         newDoc.nm              = ModelAddDocument.Name;
         newDoc.last_updated_dt = ModelAddDocument.LastUpdatedDate;
         newDoc.clicks_count    = ModelAddDocument.ClicksCount;
         newDoc.auto_upd        = ModelAddDocument.IsAutoUpdate;
         entity.docs.Add(newDoc);
         entity.SaveChanges();
     }
     return(true);
 }
コード例 #11
0
 // To Add User Topic
 public static bool AddTopic(int SpecId, string TopicName, int UserId)
 {
     using (EditorsEntities entity = new EditorsEntities())
     {
         Topic NewUserTopic = new Topic();
         NewUserTopic.TopicName   = TopicName;
         NewUserTopic.SpecialtyID = SpecId;
         NewUserTopic.Type        = 2; // 2 Represents User Topic
         NewUserTopic.UserID      = UserId;
         NewUserTopic.createtime  = DateTime.Now;
         entity.Topics.Add(NewUserTopic);
         entity.SaveChanges();
         return(true);
     }
 }
コード例 #12
0
 public static bool ShowSubTopics(List <int> SubTopicIds, int UserId)
 {
     using (EditorsEntities entity = new EditorsEntities())
     {
         foreach (var SubTopicId in SubTopicIds)
         {
             HiddenSubTopic HT = entity.HiddenSubTopics.Where(h => h.UserID == UserId && h.SubTopicID == SubTopicId).FirstOrDefault();
             if (HT != null)
             {
                 entity.HiddenSubTopics.Remove(HT);
             }
         }
         entity.SaveChanges();
         return(true);
     }
 }
コード例 #13
0
 public static bool UpdateACRDocClickCount(int Id)
 {
     using (EditorsEntities entity = new EditorsEntities())
     {
         doc Result = (from ad in entity.docs
                       where
                       ad.id == Id
                       select ad).FirstOrDefault();
         if (Result != null)
         {
             Result.clicks_count++;
             entity.Entry(Result).State = EntityState.Modified;
             entity.SaveChanges();
         }
         return(true);
     }
 }
コード例 #14
0
        // for update ACR Document

        public static bool EditDocument(ACRDocumentsModel EditDocumentModel)
        {
            using (EditorsEntities entity = new EditorsEntities())
            {
                doc editDoc = entity.docs.Find(EditDocumentModel.Id);
                if (editDoc != null)
                {
                    editDoc.source              = EditDocumentModel.Source;
                    editDoc.nm                  = EditDocumentModel.Name;
                    editDoc.last_updated_dt     = EditDocumentModel.LastUpdatedDate;
                    editDoc.clicks_count        = EditDocumentModel.ClicksCount;
                    editDoc.auto_upd            = EditDocumentModel.IsAutoUpdate;
                    entity.Entry(editDoc).State = EntityState.Modified;
                    entity.SaveChanges();
                }

                return(true);
            }
        }
コード例 #15
0
        // To add ACRDocument Relation

        public static bool AddACRDocumentRelation(ACRDocumentRelationshipModel NewRelation, string subtopicId)
        {
            using (EditorsEntities entity = new EditorsEntities())
            {
                doc ACRDocument = entity.docs.Find(NewRelation.DocId);
                if (ACRDocument != null)
                {
                    doc_in_subtopic newRelationDB = new doc_in_subtopic();
                    newRelationDB.doc_id      = NewRelation.DocId;
                    newRelationDB.subtopic_id = Convert.ToInt32(subtopicId);
                    entity.doc_in_subtopic.Add(newRelationDB);
                    entity.SaveChanges();
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
        }
コード例 #16
0
 // To Add User Sub Topic
 public static bool AddSubTopic(string TopicId, string SubTopicName, int UserId)
 {
     using (EditorsEntities entity = new EditorsEntities())
     {
         try
         {
             SubTopic NewUserSubTopic = new SubTopic();
             NewUserSubTopic.TopicID      = Convert.ToInt32(TopicId);
             NewUserSubTopic.UserID       = UserId;
             NewUserSubTopic.SubTopicName = SubTopicName;
             NewUserSubTopic.Type         = 2; // 2 Represents User SubTopic
             NewUserSubTopic.createtime   = DateTime.Now;
             entity.SubTopics.Add(NewUserSubTopic);
             entity.SaveChanges();
             return(true);
         }
         catch (Exception)
         {
             return(false);
         }
     }
 }
コード例 #17
0
        static void DeleteUserTopic(EditorsEntities entity, int TopicId, int UserId)
        {
            // First need to Get and delete SubTopics in the Topic which is going to Delete
            var Subtopics = (from s in entity.SubTopics
                             where s.TopicID == TopicId && (((s.Type == 2) && s.UserID == UserId) || s.Type == 3)
                             select s.SubTopicID).ToList();

            foreach (var SubTopicId in Subtopics)
            {
                DeleteUserSubTopic(entity, SubTopicId, UserId);
            }

            // Completed Deleting Subtopics in Topics


            // Need to Delete UserTopic
            var UserTopicToBeDeleted = entity.Topics.Where(s => s.TopicID == TopicId && s.UserID == UserId && s.Type == 2).FirstOrDefault();

            if (UserTopicToBeDeleted != null)
            {
                entity.Topics.Remove(UserTopicToBeDeleted);
            }
            entity.SaveChanges();
        }