public IActionResult FanArts() { //ViewData["Message"] = "Your application description page."; var images = _context.Images.Where(a => !a.isAvatar).ToList(); var viewModel = new FanArtViewModel() { Imagelist = images }; return(View(viewModel)); }
public IActionResult FanArts(FanArtViewModel viewModel) { //ViewData["Message"] = "Your application description page."; var newImag = new Image(); newImag.Name = viewModel.name; newImag.Path = viewModel.path; newImag.isAvatar = false; _context.Images.Add(newImag); _context.SaveChanges(); var images = _context.Images.Where(a => !a.isAvatar).ToList(); viewModel = new FanArtViewModel() { Imagelist = images }; return(View(viewModel)); }