public async Task <IActionResult> Edit(int id, [Bind("Id,Nome,Codinome,Lancamento")] HeroiViewModel heroiViewModel) { if (id != heroiViewModel.Id) { return(NotFound()); } if (ModelState.IsValid) { try { await _heroiAppService.EditAsync(heroiViewModel); } catch (DbUpdateConcurrencyException) { if (!HeroiViewModelExists(heroiViewModel.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(heroiViewModel)); }
public async Task <int> AddAsync(HeroiViewModel heroiViewModel) { var heroiEntity = _mapper.Map <HeroiEntity>(heroiViewModel); var id = await _heroiService.AddAsync(heroiEntity); return(id); }
public async Task <IActionResult> Create([Bind("Id,Nome,Codinome,Lancamento")] HeroiViewModel heroiViewModel) { if (ModelState.IsValid) { await _heroiAppService.AddAsync(heroiViewModel); return(RedirectToAction(nameof(Index))); } return(View(heroiViewModel)); }
public async Task RemoveAsync(HeroiViewModel heroiViewModel) { var heroiEntity = _mapper.Map <HeroiEntity>(heroiViewModel); await _heroiService.RemoveAsync(heroiEntity); }