Пример #1
0
        /// <summary>
        /// Get Users Specific Access Entry
        /// </summary>
        /// <param name="db">NotesDbContext</param>
        /// <param name="userId">ID of logged in user</param>
        /// <param name="fileId">NoteFileID</param>
        /// <returns>NoteAcess Object</returns>
        public static async Task <NoteAccess> GetOneAccess(NotesDbContext db, string userId, int fileId, int arcId)
        {
            NoteAccess na = await db.NoteAccess
                            .Where(p => p.UserID == userId && p.NoteFileId == fileId && p.ArchiveId == arcId).FirstOrDefaultAsync();

            return(na);
        }
Пример #2
0
        /// <summary>
        /// All access checks call this
        /// </summary>
        /// <param name="db">NotesDbContext</param>
        /// <param name="userId">ID of logged in user</param>
        /// <param name="fileId">NoteFileID</param>
        /// <returns>NoteAcess Object</returns>
        public static async Task <NoteAccess> GetAccess(NotesDbContext db, string userId, int fileId, int arcId)
        {
            // Next we check for this user specifically
            NoteAccess na = await db.NoteAccess
                            .Where(p => p.UserID == userId && p.NoteFileId == fileId && p.ArchiveId == arcId).FirstOrDefaultAsync();

            if (na != null)
            {
                return(na);
            }

            // If specific user not in list use "Other"
            return(await db.NoteAccess
                   .Where(p => p.UserID == "Other" && p.NoteFileId == fileId && p.ArchiveId == arcId).FirstOrDefaultAsync());
        }
Пример #3
0
        private static async Task <bool> Create(NotesDbContext db, string userId, int noteFileId, bool read, bool respond,
                                                bool write, bool setTag, bool deleteEdit, bool director, bool editAccess)
        {
            NoteAccess na = new NoteAccess()
            {
                UserID     = userId,
                NoteFileId = noteFileId,

                ReadAccess = read,
                Respond    = respond,
                Write      = write,
                SetTag     = setTag,
                DeleteEdit = deleteEdit,
                ViewAccess = director,
                EditAccess = editAccess
            };

            db.NoteAccess.Add(na);
            return((await db.SaveChangesAsync()) == 1);
        }