コード例 #1
0
        public IActionResult OnGet(int?id)
        {
            //判断是否已授权
            var isAuthorized = User.IsInRole(Constants.ContactAdministratorsRole);

            if (!isAuthorized)
            {
                return(new ChallengeResult());
            }

            if (id == null)
            {
                return(NotFound());
            }

            var sourceCode = _identitycontext.SourceCodes.FirstOrDefault(m => m.ID == id);

            if (sourceCode == null)
            {
                return(NotFound());
            }

            sourceCodeForDisPlay = new SourceCodeForDisPlay(sourceCode);

            return(Page());
        }
コード例 #2
0
        public async Task <IActionResult> OnPostAsync(int id)
        {
            //判断是否已授权
            var isAuthorized = User.IsInRole(Constants.ContactAdministratorsRole);

            if (!isAuthorized)
            {
                return(new ChallengeResult());
            }

            //确认对应代码
            sourceCodeForDisplay = _sourceCodeManager.FindSourceCode(id);

            if (sourceCodeForDisplay == null)
            {
                return(NotFound());
            }

            //删除FileList中的记录
            _detectManager.DeleteItemFromInitList(sourceCodeForDisplay.GetFileName());

            //删除文件
            FileInfo file = new FileInfo("SourceCodeData//" + sourceCodeForDisplay.GetFileName());

            if (file.Exists)
            {
                file.Delete();
            }

            //删除对应的数据库记录
            await _sourceCodeManager.RemoveSourceCode(sourceCodeForDisplay);

            return(RedirectToPage("./Index"));
        }
コード例 #3
0
        public async Task <bool> AddSourceCode(SourceCodeForDisPlay temp)
        {
            if (!VaildationCheck(temp))
            {
                return(false);
            }

            _identityContext.SourceCodes.Add(new SourceCode(temp, false));
            await _identityContext.SaveChangesAsync();

            return(true);
        }
コード例 #4
0
        public async Task <bool> RemoveSourceCode(SourceCodeForDisPlay temp)
        {
            var sourceCode = _identityContext.SourceCodes.FirstOrDefault(m => m.ID == temp.ID);

            if (sourceCode == null)
            {
                return(true);
            }
            _identityContext.SourceCodes.Remove(sourceCode);
            await _identityContext.SaveChangesAsync();

            return(true);
        }
コード例 #5
0
        public IActionResult OnGet()
        {
            //判断是否已授权
            var isAuthorized = User.IsInRole(Constants.ContactAdministratorsRole);

            if (!isAuthorized)
            {
                return(new ChallengeResult());
            }

            sourceCodeForDisPlay = new SourceCodeForDisPlay();
            return(Page());
        }
コード例 #6
0
        //检查重名信息
        public bool VaildationCheck(SourceCodeForDisPlay temp)
        {
            SourceCode sourceCode;

            //检查昵称
            sourceCode = _identityContext.SourceCodes.FirstOrDefault(m => m.Name == temp.Name);
            if (sourceCode != null)
            {
                return(false);
            }
            //检查英文名
            sourceCode = _identityContext.SourceCodes.FirstOrDefault(m => m.EnglishName == temp.EnglishName);
            if (sourceCode != null)
            {
                return(false);
            }

            return(true);
        }
コード例 #7
0
        public IActionResult OnGet(int?id)
        {
            //判断是否已授权
            var isAuthorized = User.IsInRole(Constants.ContactAdministratorsRole);

            if (!isAuthorized)
            {
                return(new ChallengeResult());
            }

            int sourceCodeid = (int)id;

            sourceCodeForDisplay = _sourceCodeManager.FindSourceCode(sourceCodeid);
            if (sourceCodeForDisplay == null)
            {
                return(NotFound());
            }

            return(Page());
        }
コード例 #8
0
        public async Task <bool> UpdateSourceCode(SourceCodeForDisPlay temp)
        {
            var sourceCode = _identityContext.SourceCodes.FirstOrDefault(m => m.ID == temp.ID);

            if (sourceCode == null)
            {
                return(false);
            }
            else
            {
                sourceCode.LastEditDate = temp.LastEditTime;
                sourceCode.Name         = temp.Name;
                sourceCode.EnglishName  = temp.EnglishName;
                sourceCode.DocURL       = temp.DocURL;
                sourceCode.SearchTime   = temp.SearchTime;

                await _identityContext.SaveChangesAsync();

                return(true);
            }
        }