Ejemplo n.º 1
0
        // GET: NoteAccesses
        /// <summary>
        /// Index of Access Controls for a NoteFile
        /// </summary>
        /// <param name="id">NoteFileID</param>
        /// <returns></returns>
        public async Task <IActionResult> Index(int id)
        {
            int arcId = (int)HttpContext.Session.GetInt32("ArchiveID");

            //Check if user has right to Edit or View the List
            NoteAccess myaccess = await GetMyAccess(id, arcId);

            if (!myaccess.EditAccess && !myaccess.ViewAccess)
            {
                return(RedirectToAction("Index", "Home"));
            }

            // Get the Object for the NoteFile
            ViewBag.NoteFileID = id;
            NoteFile nf = await NoteDataManager.GetFileById(_db, id);

            ViewBag.NoteFileName = nf.NoteFileName;

            // Get the list of entries
            List <NoteAccess> thelist = await AccessManager.GetAccessListForFile(_db, nf.Id, arcId);

            List <string> names = new List <string>();
            List <string> ds    = new List <string>();

            foreach (NoteAccess item in thelist)
            {
                names.Add(GetUserNameFromID(item.UserID));
            }

            ds.Add(_userManager.GetUserId(User));
            ds.Add(Globals.AccessOtherId());

            ViewBag.names = names;
            ViewBag.IDs   = ds;

            return(View(thelist));
        }