public async Task <IActionResult> Edit(int id, [Bind("Id,Title,Description,ExternalReference,ProjectId")] PortfolioItemViewModel portfolioItemViewModel) { if (id != portfolioItemViewModel.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(portfolioItemViewModel.ToEntity(_context)); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!PortfolioItemExists(portfolioItemViewModel.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(portfolioItemViewModel)); }
public async Task <IActionResult> Create([Bind("Id,Title,Description,ExternalReference,ProjectId")] PortfolioItemViewModel portfolioItemViewModel) { if (ModelState.IsValid) { _context.Add(portfolioItemViewModel.ToEntity(_context)); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(portfolioItemViewModel)); }