public IActionResult Pages(int id) { var page = pages.GetByID(id); if (page != null) { page.Visit += 1; pages.Update(page); pages.Save(); } return(View(page)); }
public async Task <IActionResult> Edit(int id, [Bind("PageID,GroupID,PageText,PageDescription,Title,Tags,Visit,ImageName,CreateTime,ShowSlider")] Pages pages, IFormFile IMGup) { if (id != pages.PageID) { return(NotFound()); } if (ModelState.IsValid) { try { if (IMGup != null) { if (pages.ImageName == null) { pages.ImageName = Guid.NewGuid().ToString() + Path.GetExtension(IMGup.FileName); } string pathname = Path.Combine( Directory.GetCurrentDirectory(), "wwwroot/ImagesFolder", pages.ImageName ); using (var stream = new FileStream(pathname, FileMode.Create)) { await IMGup.CopyToAsync(stream); } } pagess.Update(pages); pagess.Save(); } catch (DbUpdateConcurrencyException) { if (!PagesExists(pages.PageID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["GroupID"] = new SelectList(pageGroup.Getallpagegroup(), "GroupID", "GroupTitle", pages.GroupID); return(View(pages)); }