コード例 #1
0
        /// <summary>
        /// Create a new Userdocument object.
        /// </summary>
        /// <param name="userId">Initial value of the userId property.</param>
        /// <param name="documentId">Initial value of the documentId property.</param>
        /// <param name="folderId">Initial value of the folderId property.</param>
        public static Userdocument CreateUserdocument(global::System.Int32 userId, global::System.Int32 documentId, global::System.Int32 folderId)
        {
            Userdocument userdocument = new Userdocument();

            userdocument.userId     = userId;
            userdocument.documentId = documentId;
            userdocument.folderId   = folderId;
            return(userdocument);
        }
コード例 #2
0
 /// <summary>
 /// Adds a userdocument in the givens users root folder
 /// </summary>
 /// <param name="userId">The id of the user</param>
 /// <param name="documentId">The id of the document</param>
 public void AddUserDocumentInRoot(int userId, int documentId)
 {
     using (PieFactoryEntities context = new PieFactoryEntities())
     {
         User         user         = GetUserById(userId);
         Userdocument userdocument = new Userdocument();
         userdocument.documentId = documentId;
         userdocument.folderId   = user.rootFolderId;
         userdocument.userId     = userId;
         context.Userdocuments.AddObject(userdocument);
         context.SaveChanges();
     }
 }
コード例 #3
0
        /// <summary>
        /// Alters a userdocument, effectively moving the document from one folder to another
        /// </summary>
        /// <param name="userId">The id of the user</param>
        /// <param name="documentId">The id of the document</param>
        /// <param name="filepath">the path to the document</param>
        public void AlterUserDocument(int userId, int documentId, String filepath)
        {
            int folderId = GetFolderIdByDirectoryPath(userId, filepath);

            using (PieFactoryEntities context = new PieFactoryEntities())
            {
                var userdocuments = from ud in context.Userdocuments
                                    where ud.userId == userId && ud.documentId == documentId
                                    select ud;
                Userdocument userdocument = userdocuments.First <Userdocument>();
                userdocument.folderId = folderId;
                context.SaveChanges();
            }
        }
コード例 #4
0
        /// <summary>
        /// Adds a reference from a user to a document to the database.
        /// </summary>
        /// <param name="userId">The id of the user</param>
        /// <param name="documentId">The id of the document</param>
        /// <param name="directoryPath">The path of the directory in which the document lies</param>
        public void AddUserDocument(int userId, int documentId, String directoryPath)
        {
            int folderId = GetFolderIdByDirectoryPath(userId, directoryPath);

            using (PieFactoryEntities context = new PieFactoryEntities())
            {
                Userdocument userDocument = new Userdocument();
                userDocument.documentId = documentId;
                userDocument.userId     = userId;
                userDocument.folderId   = folderId;
                context.Userdocuments.AddObject(userDocument);
                context.SaveChanges();
            }
        }
コード例 #5
0
 /// <summary>
 /// Get a userdocument from the database
 /// </summary>
 /// <param name="userId">The userId of the userdocument</param>
 /// <param name="documentId">The documentId of the userdocument</param>
 /// <returns>The Userdocument with the given userId and documentId. Null if none exists</returns>
 public Userdocument GetUserdocument(int userId, int documentId)
 {
     using (PieFactoryEntities context = new PieFactoryEntities())
     {
         var userdocuments = from ud in context.Userdocuments
                             where ud.userId == userId && ud.documentId == documentId
                             select ud;
         Userdocument userdocument = null;
         if (userdocuments.Count <Userdocument>() > 0)
         {
             userdocument = userdocuments.First <Userdocument>();
         }
         return(userdocument);
     }
 }
コード例 #6
0
 /// <summary>
 /// Delete a users reference to a document
 /// </summary>
 /// <param name="userId">The id of the user</param>
 /// <param name="documentId">The id of the document</param>
 public void DeleteDocumentReference(int userId, int documentId)
 {
     using (PieFactoryEntities context = new PieFactoryEntities())
     {
         var userDocuments = from dr in context.Userdocuments
                             where dr.documentId == documentId & dr.userId == userId
                             select dr;
         if (userDocuments.Count <Userdocument>() > 0)
         {
             Userdocument userDocument = userDocuments.First <Userdocument>();
             context.Userdocuments.DeleteObject(userDocument);
             context.SaveChanges();
         }
     }
 }
コード例 #7
0
ファイル: DAO.cs プロジェクト: MikkelFunch/sliceofpie
 /// <summary>
 /// Adds a userdocument in the givens users root folder
 /// </summary>
 /// <param name="userId">The id of the user</param>
 /// <param name="documentId">The id of the document</param>
 public void AddUserDocumentInRoot(int userId, int documentId)
 {
     using (PieFactoryEntities context = new PieFactoryEntities())
     {
         User user = GetUserById(userId);
         Userdocument userdocument = new Userdocument();
         userdocument.documentId = documentId;
         userdocument.folderId = user.rootFolderId;
         userdocument.userId = userId;
         context.Userdocuments.AddObject(userdocument);
         context.SaveChanges();
     }
 }
コード例 #8
0
ファイル: DAO.cs プロジェクト: MikkelFunch/sliceofpie
 /// <summary>
 /// Adds a reference from a user to a document to the database.
 /// </summary>
 /// <param name="userId">The id of the user</param>
 /// <param name="documentId">The id of the document</param>
 /// <param name="directoryPath">The path of the directory in which the document lies</param>
 public void AddUserDocument(int userId, int documentId, String directoryPath)
 {
     int folderId = GetFolderIdByDirectoryPath(userId, directoryPath);
     using (PieFactoryEntities context = new PieFactoryEntities())
     {
         Userdocument userDocument = new Userdocument();
         userDocument.documentId = documentId;
         userDocument.userId = userId;
         userDocument.folderId = folderId;
         context.Userdocuments.AddObject(userDocument);
         context.SaveChanges();
     }
 }
コード例 #9
0
 /// <summary>
 /// Deprecated Method for adding a new object to the Userdocuments EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToUserdocuments(Userdocument userdocument)
 {
     base.AddObject("Userdocuments", userdocument);
 }
コード例 #10
0
 /// <summary>
 /// Create a new Userdocument object.
 /// </summary>
 /// <param name="userId">Initial value of the userId property.</param>
 /// <param name="documentId">Initial value of the documentId property.</param>
 /// <param name="folderId">Initial value of the folderId property.</param>
 public static Userdocument CreateUserdocument(global::System.Int32 userId, global::System.Int32 documentId, global::System.Int32 folderId)
 {
     Userdocument userdocument = new Userdocument();
     userdocument.userId = userId;
     userdocument.documentId = documentId;
     userdocument.folderId = folderId;
     return userdocument;
 }
コード例 #11
0
 /// <summary>
 /// Deprecated Method for adding a new object to the Userdocuments EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToUserdocuments(Userdocument userdocument)
 {
     base.AddObject("Userdocuments", userdocument);
 }