public IActionResult LikesDown(int id) { FreelancerPortfolio freelancerPortfolio = _context.FreelancerPortfolios.Where(m => m.Id == id).SingleOrDefault(); if (freelancerPortfolio == null) { return(NotFound()); } string currentuserid = _userManager.GetUserId(User); if (currentuserid != freelancerPortfolio.ApplicationUserId) { freelancerPortfolio.Likes -= 1; _context.Update(freelancerPortfolio); _context.SaveChanges(); } return(RedirectToAction("Details/" + id)); }
public async Task <IActionResult> Create([Bind("Id,ApplicationUserId,Title,Skills,Description,ExternalLink,Image,File,Likes,Views,DateOfRecord,DateOfAchievement")] FreelancerPortfolio freelancerPortfolio, IFormFile myfile, IFormFile myfile2) { if (ModelState.IsValid) { freelancerPortfolio.Image = await UserFile.UploadeNewImageAsync(freelancerPortfolio.Image, myfile, _environment.WebRootPath, Properties.Resources.Images, 500, 500); freelancerPortfolio.File = await UserFile.UploadeNewFileAsync(freelancerPortfolio.File, myfile2, _environment.WebRootPath, Properties.Resources.Files); freelancerPortfolio.DateOfRecord = DateTime.Now; _context.Add(freelancerPortfolio); await _context.SaveChangesAsync(); //return RedirectToAction(nameof(Index)); return(RedirectToAction("FreelancerDetails", "ApplicationUsers", new { /* routeValues, for example: */ id = freelancerPortfolio.ApplicationUserId })); } ViewData["ApplicationUserId"] = new SelectList(_context.ApplicationUsers, "Id", "Id", freelancerPortfolio.ApplicationUserId); return(View(freelancerPortfolio)); }
public async Task <IActionResult> Edit(int id, [Bind("Id,ApplicationUserId,Title,Skills,Description,ExternalLink,Image,File,Likes,Views,DateOfRecord,DateOfAchievement")] FreelancerPortfolio freelancerPortfolio, IFormFile myfile, IFormFile myfile2) { if (id != freelancerPortfolio.Id) { return(NotFound()); } if (ModelState.IsValid) { try { freelancerPortfolio.Image = await UserFile.UploadeNewImageAsync(freelancerPortfolio.Image, myfile, _environment.WebRootPath, Properties.Resources.Images, 500, 500); freelancerPortfolio.File = await UserFile.UploadeNewFileAsync(freelancerPortfolio.File, myfile2, _environment.WebRootPath, Properties.Resources.Files); _context.Update(freelancerPortfolio); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!FreelancerPortfolioExists(freelancerPortfolio.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["ApplicationUserId"] = new SelectList(_context.ApplicationUsers, "Id", "Id", freelancerPortfolio.ApplicationUserId); return(View(freelancerPortfolio)); }