Esempio n. 1
0
        public async Task <IActionResult> OnGetAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            FileKeywordDTO = await _context.FileKeywordDTO
                             .Include(f => f.File)
                             .Include(f => f.Keyword).FirstOrDefaultAsync(m => m.FIleKeywordId == id);

            if (FileKeywordDTO == null)
            {
                return(NotFound());
            }
            return(Page());
        }
Esempio n. 2
0
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            FileKeywordDTO = await _context.FileKeywordDTO.FindAsync(id);

            if (FileKeywordDTO != null)
            {
                _context.FileKeywordDTO.Remove(FileKeywordDTO);
                await _context.SaveChangesAsync();
            }

            return(RedirectToPage("./Index"));
        }
Esempio n. 3
0
        public async Task <IActionResult> OnGetAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            FileKeywordDTO = await _context.FileKeywordDTO
                             .Include(f => f.File)
                             .Include(f => f.Keyword).FirstOrDefaultAsync(m => m.FIleKeywordId == id);

            if (FileKeywordDTO == null)
            {
                return(NotFound());
            }
            ViewData["FileId"]    = new SelectList(_context.FileDTO, "FileId", "FileId");
            ViewData["KeywordId"] = new SelectList(_context.Set <KeywordDTO>(), "Id", "Id");
            return(Page());
        }
Esempio n. 4
0
        public async Task OnGetAsync()
        {
            var files = await client.GetAllFilesAsync();

            foreach (var file in files)
            {
                FileDTO fileDTO = new FileDTO();
                fileDTO.FileId       = file.FileId;
                fileDTO.Created_at   = file.Created_at;
                fileDTO.Location     = file.Location;
                fileDTO.Path         = file.Path;
                fileDTO.Type         = file.Type;
                fileDTO.Path_changed = file.Path_changed;
                ServiceReferenceClientWeb.Keyword[] keywordList = await client.GetKeywordsOfFileAsync(file.Path);

                foreach (var keyword in keywordList)
                {
                    FileKeywordDTO fkDTO      = new FileKeywordDTO();
                    KeywordDTO     keywordDTO = new KeywordDTO();
                    keywordDTO.Id       = keyword.Id;
                    keywordDTO.Kword    = keyword.Kword;
                    fkDTO.File          = fileDTO;
                    fkDTO.FileId        = fileDTO.FileId;
                    fkDTO.FIleKeywordId = keywordDTO.Id;
                    fkDTO.Keyword       = keywordDTO;
                    fileDTO.Keywords.Add(fkDTO);
                }
                if (FilterLocation == null && FilterKeyword == null)
                {
                    fileDTOList.Add(fileDTO);
                }
                else
                {
                    if (FilterLocation == null)
                    {
                        bool find = false;
                        foreach (var item in fileDTO.Keywords)
                        {
                            if (item.Keyword.Kword == FilterKeyword)
                            {
                                find = true;
                            }
                        }
                        if (find)
                        {
                            fileDTOList.Add(fileDTO);
                        }
                    }
                    else if (FilterKeyword == null)
                    {
                        if (fileDTO.Location == FilterLocation)
                        {
                            fileDTOList.Add(fileDTO);
                        }
                    }
                    else
                    {
                        bool find = false;
                        foreach (var item in fileDTO.Keywords)
                        {
                            if (item.Keyword.Kword == FilterKeyword && fileDTO.Location == FilterLocation)
                            {
                                find = true;
                            }
                        }
                        if (find)
                        {
                            fileDTOList.Add(fileDTO);
                        }
                    }
                }
                Number = fileDTOList.Count.ToString();
            }
        }