예제 #1
0
        // GET: NoteAccesses/Delete/5
        /// <summary>
        /// Delete an Accese Control Object
        /// </summary>
        /// <param name="id">UserID</param>
        /// <param name="id2">NoteFileID</param>
        /// <returns></returns>
        public async Task <IActionResult> Delete(string id, int id2)
        {
            if (id == "")
            {
                return(NotFound());
            }
            int arcId = (int)HttpContext.Session.GetInt32("ArchiveID");

            NoteAccess myaccess = await GetMyAccess(id2, arcId);

            if (!myaccess.EditAccess)
            {
                return(RedirectToAction("Index", "Home"));
            }
            ViewBag.MyAccess = myaccess;
            // Get Access Control Object
            NoteAccess noteAccess = await AccessManager.GetOneAccess(_db, id, id2, arcId);

            if (noteAccess == null)
            {
                return(NotFound());
            }
            // Get NoteFile Object
            ViewBag.NoteFileName = _db.NoteFile
                                   .FirstOrDefault(p => p.Id == id2)
                                   ?.NoteFileName;

            ViewBag.NoteUserName = GetUserNameFromID(id);
            // Send Access Control Object to View
            return(View(noteAccess));
        }
예제 #2
0
        // GET: NoteAccesses/Edit/5
        /// <summary>
        /// Edit an access control for a user and file
        /// </summary>
        /// <param name="id">UserID</param>
        /// <param name="id2">NoteFileID</param>
        /// <returns></returns>
        public async Task <IActionResult> Edit(string id, int id2)
        {
            int arcId = (int)HttpContext.Session.GetInt32("ArchiveID");

            NoteAccess myaccess = await GetMyAccess(id2, arcId);

            if (!myaccess.EditAccess)
            {
                return(RedirectToAction("Index"));
            }
            ViewBag.MyAccess = myaccess;

            // get the Object for the User/NoteFile
            NoteAccess noteAccess = await AccessManager.GetOneAccess(_db, id, id2, arcId);

            if (noteAccess == null)
            {
                return(NotFound());
            }
            // Get the NoteFile Name
            NoteFile nf = await NoteDataManager.GetFileById(_db, id2);

            ViewBag.NoteFileName = nf.NoteFileName;
            ViewBag.NoteUserName = GetUserNameFromID(id);

            // Pass Access Control Object to View
            return(View(noteAccess));
        }
예제 #3
0
        public async Task <IActionResult> DeleteConfirmed(string id, int id2)
        {
            int arcId = (int)HttpContext.Session.GetInt32("ArchiveID");

            NoteAccess noteAccess = await AccessManager.GetOneAccess(_db, id, id2, arcId);

            _db.NoteAccess.Remove(noteAccess);
            await _db.SaveChangesAsync();

            return(RedirectToAction("Index", new { id = noteAccess.NoteFileId }));
        }
        public async Task CreateAnnounce()
        {
            await CreateNoteFile("announce", "Notes 2021 Announcements");

            NoteFile nf4 = await NoteDataManager.GetFileByName(_db, "announce");

            int        padid  = nf4.Id;
            NoteAccess access = await AccessManager.GetOneAccess(_db, Globals.AccessOtherId(), padid, 0);

            access.ReadAccess = true;

            _db.Entry(access).State = EntityState.Modified;
            await _db.SaveChangesAsync();
        }
        public async Task CreatePad()
        {
            await CreateNoteFile("pad", "Traditional Pad");

            NoteFile nf4 = await NoteDataManager.GetFileByName(_db, "pad");

            int        padid  = nf4.Id;
            NoteAccess access = await AccessManager.GetOneAccess(_db, Globals.AccessOtherId(), padid, 0);

            access.ReadAccess = true;
            access.Respond    = true;
            access.Write      = true;

            _db.Entry(access).State = EntityState.Modified;
            await _db.SaveChangesAsync();
        }
        public async Task <IActionResult> CreateNoteshelp()
        {
            await CreateNoteFile("noteshelp", "Help with Notes 2021");

            NoteFile nf4 = await NoteDataManager.GetFileByName(_db, "noteshelp");

            int        padid  = nf4.Id;
            NoteAccess access = await AccessManager.GetOneAccess(_db, Globals.AccessOtherId(), padid, 0);

            access.ReadAccess = true;
            access.Respond    = true;
            access.Write      = true;

            _db.Entry(access).State = EntityState.Modified;
            await _db.SaveChangesAsync();

            return(RedirectToAction("Index"));
        }