コード例 #1
0
ファイル: PlaythroughMapper.cs プロジェクト: Meintje/Hoard
        internal static PlaythroughCreateUpdateViewModel ToCreateViewModel(int playDataID, IEnumerable <PlayStatus> playStatusList)
        {
            var playthroughCreateViewModel = new PlaythroughCreateUpdateViewModel
            {
                PlayDataID = playDataID
            };

            playthroughCreateViewModel.PlayStatusSelectList = new SelectList(playStatusList, nameof(PlayStatus.ID), nameof(PlayStatus.Name));

            return(playthroughCreateViewModel);
        }
コード例 #2
0
        public async Task <IActionResult> CreatePlaythrough([Bind("PlayDataID,OrdinalNumber,PlayStatusID,DateStart,DateEnd,PlaytimeDays,PlaytimeHours,PlaytimeMinutes,SideContentCompleted,Notes")] PlaythroughCreateUpdateViewModel playthroughCreateViewModel)
        {
            if (ModelState.IsValid)
            {
                await playDataViewService.CreatePlaythroughAsync(playthroughCreateViewModel);

                return(RedirectToAction(nameof(Details), new { id = playthroughCreateViewModel.PlayDataID }));
            }

            // TODO: If this point is reached, something went wrong while saving data. Redirect to related PlayData and show error message.
            // Or reload the form and input data into the modal
            return(PartialView("_PlaythroughCreateModalPartial", playthroughCreateViewModel));
        }
コード例 #3
0
ファイル: PlaythroughMapper.cs プロジェクト: Meintje/Hoard
        internal static Playthrough ToPlaythrough(PlaythroughCreateUpdateViewModel playthroughCreateUpdateViewModel)
        {
            var playtime = new TimeSpan(playthroughCreateUpdateViewModel.PlaytimeDays, playthroughCreateUpdateViewModel.PlaytimeHours, playthroughCreateUpdateViewModel.PlaytimeMinutes, 0);

            var playthrough = new Playthrough
            {
                PlayDataID           = playthroughCreateUpdateViewModel.PlayDataID,
                OrdinalNumber        = (int)playthroughCreateUpdateViewModel.OrdinalNumber,
                PlayStatusID         = playthroughCreateUpdateViewModel.PlayStatusID,
                DateStart            = playthroughCreateUpdateViewModel.DateStart,
                DateEnd              = playthroughCreateUpdateViewModel.DateEnd,
                PlaytimeInMinutes    = (int)playtime.TotalMinutes,
                SideContentCompleted = playthroughCreateUpdateViewModel.SideContentCompleted,
                Notes = playthroughCreateUpdateViewModel.Notes
            };

            return(playthrough);
        }
コード例 #4
0
ファイル: PlaythroughMapper.cs プロジェクト: Meintje/Hoard
        internal static PlaythroughCreateUpdateViewModel ToUpdateViewModel(Playthrough playthrough, IEnumerable <PlayStatus> playStatusList)
        {
            var playtime = new TimeSpan(0, playthrough.PlaytimeInMinutes, 0);

            var playthroughUpdateViewModel = new PlaythroughCreateUpdateViewModel
            {
                PlayDataID           = playthrough.PlayDataID,
                OrdinalNumber        = playthrough.OrdinalNumber,
                PlayStatusID         = playthrough.PlayStatusID,
                DateStart            = playthrough.DateStart,
                DateEnd              = playthrough.DateEnd,
                PlaytimeDays         = playtime.Days,
                PlaytimeHours        = playtime.Hours,
                PlaytimeMinutes      = playtime.Minutes,
                SideContentCompleted = playthrough.SideContentCompleted,
                Notes = playthrough.Notes
            };

            playthroughUpdateViewModel.PlayStatusSelectList = new SelectList(playStatusList, nameof(PlayStatus.ID), nameof(PlayStatus.Name));

            return(playthroughUpdateViewModel);
        }
コード例 #5
0
ファイル: PlayDataViewService.cs プロジェクト: Meintje/Hoard
        public async Task UpdatePlaythroughAsync(PlaythroughCreateUpdateViewModel playthroughUpdateViewModel)
        {
            var playthrough = PlaythroughMapper.ToPlaythrough(playthroughUpdateViewModel);

            await playthroughDbService.UpdateAsync(playthrough);
        }