示例#1
0
        public async Task DelPageImg(int id)
        {
            var pages = await _dbContext.Pages.FirstOrDefaultAsync(n => n.PageID == id);

            if (pages != null)
            {
                if (pages.PageImageName != null && pages.PageImageName != string.Empty)
                {
                    File.Delete(Path.Combine($"{_hostingEnvironment.WebRootPath}/upload/image/", pages.PageImageName));
                    pages.PageImageName = string.Empty;
                    _dbContext.Update(pages);
                    await _dbContext.SaveChangesAsync();
                }
            }
        }
示例#2
0
        public async Task <Pages> GetPage(int id, int language)
        {
            var page = await _dbContext.Pages.AsNoTracking().FirstOrDefaultAsync(p => p.ColumnID == id && p.Language == language);

            if (page != null)
            {
                page.Hit = page.Hit + 1;
                _dbContext.Update(page);
                await _dbContext.SaveChangesAsync();

                return(page);
            }
            else
            {
                return(null);
            }
        }