public async Task <IActionResult> Edit([Bind("ID,GameID,HoarderID,PriorityID,OwnershipStatusID,Dropped,AchievementsCompleted,Rating,Notes")] PlayDataUpdateViewModel playDataUpdateViewModel) { if (ModelState.IsValid) { try { await playDataViewService.UpdatePlayDataAsync(playDataUpdateViewModel); } catch (DbUpdateConcurrencyException) { if (!PlayDataExists(playDataUpdateViewModel.ID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Details), new { id = playDataUpdateViewModel.ID })); } return(RedirectToAction(nameof(Details), new { id = playDataUpdateViewModel.ID })); }
internal static PlayData ToPlayData(PlayDataUpdateViewModel playDataUpdateViewModel) { var playdata = new PlayData { ID = playDataUpdateViewModel.ID, GameID = playDataUpdateViewModel.GameID, HoarderID = playDataUpdateViewModel.HoarderID, PriorityID = playDataUpdateViewModel.PriorityID, OwnershipStatusID = playDataUpdateViewModel.OwnershipStatusID, Dropped = playDataUpdateViewModel.Dropped, AchievementsCompleted = playDataUpdateViewModel.AchievementsCompleted, Rating = playDataUpdateViewModel.Rating, Notes = playDataUpdateViewModel.Notes }; return(playdata); }
internal static PlayDataUpdateViewModel ToUpdateViewModel(PlayData playData, IEnumerable <Priority> priorityList, IEnumerable <OwnershipStatus> ownershipStatusList) { var vm = new PlayDataUpdateViewModel { ID = playData.ID, GameID = playData.GameID, HoarderID = playData.HoarderID, PriorityID = playData.PriorityID, OwnershipStatusID = playData.OwnershipStatusID, Dropped = playData.Dropped, AchievementsCompleted = playData.AchievementsCompleted, Rating = playData.Rating, Notes = playData.Notes }; vm.OwnershipStatusSelectList = new SelectList(ownershipStatusList, nameof(OwnershipStatus.ID), nameof(OwnershipStatus.Name)); vm.PrioritySelectList = new SelectList(priorityList, nameof(Priority.ID), nameof(Priority.Name)); return(vm); }
public async Task UpdatePlayDataAsync(PlayDataUpdateViewModel playDataUpdateViewModel) { var playData = PlayDataMapper.ToPlayData(playDataUpdateViewModel); await playDataDbService.UpdateAsync(playData); }