Beispiel #1
0
        public IActionResult Shownews(int newsid)
        {
            var page = pageRepository.GetPageById(newsid);

            if (page != null)
            {
                page.PageVisit += 1;
                pageRepository.UpdatePage(page);
                pageRepository.Save();
            }
            return(View(page));
        }
Beispiel #2
0
 public async Task <IActionResult> Create([Bind("PageID,GroupID,PageTitle,ShortDescription,PageVisit,ImageName,PageTags,ShowInSlider,CreateDate")] Page page, IFormFile Imgup)
 {
     if (ModelState.IsValid)
     {
         page.PageVisit  = 0;
         page.CreateDate = DateTime.Now;
         if (Imgup != null)
         {
             page.ImageName = Guid.NewGuid().ToString() + Path.GetExtension(Imgup.FileName);
             string savepath = Path.Combine(
                 Directory.GetCurrentDirectory(), "WWWroot/Image", page.ImageName);
             using (var stream = new FileStream(savepath, FileMode.Create))
             {
                 await Imgup.CopyToAsync(stream);
             }
         }
         PageRepository.InsertPage(page);
         PageRepository.Save();
         return(RedirectToAction(nameof(Index)));
     }
     ViewData["GroupID"] = new SelectList(PageGroupRepository.GetAllPageGroup(), "GroupID", "GroupTitle", page.GroupID);
     return(View(page));
 }