Ejemplo n.º 1
0
        private CharacterCreateViewModel PopulateLists(CharacterCreateViewModel model)
        {
            model.Races     = work.RaceRepository.GetAll().Select(e => RaceModel.GenerateRaceModelFromDTO(e)).ToList();
            model.Classes   = work.ClassRepository.GetAll().Select(e => ClassModel.GenerateClassModelFromDTO(e)).ToList();
            model.BaseStats = work.BaseStatRepository.GetAll().Select(e => BaseStatModel.GeneralBaseStatModelFromDTO(e)).ToList();
            model.Skills    = work.SkillRepository.GetAll().Select(e => SkillModel.GenerateSkillModelFromDTO(e));

            return(model);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Displays the index page.
        /// </summary>
        /// <returns></returns>
        public IActionResult Index()
        {
            var model = new BaseStatIndexViewModel()
            {
                BaseStats = work.BaseStatRepository.GetAll().Select(e => BaseStatModel.GeneralBaseStatModelFromDTO(e))
            };

            return(View(model));
        }
Ejemplo n.º 3
0
        public IActionResult Edit(int id, int?gameID)
        {
            var model = new CharacterEditViewModel();

            model.GameID         = gameID;
            model.CharacterModel = CharacterModel.GenerateCharacterModelFromDTO(work.TemplateCharacterRepository.GetDTO(id));
            model.Classes        = work.ClassRepository.GetAll().Select(e => ClassModel.GenerateClassModelFromDTO(e)).ToList();
            model.Races          = work.RaceRepository.GetAll().Select(e => RaceModel.GenerateRaceModelFromDTO(e)).ToList();
            model.BaseStats      = work.BaseStatRepository.GetAll().Select(e => BaseStatModel.GeneralBaseStatModelFromDTO(e)).ToList();

            return(View(model));
        }
Ejemplo n.º 4
0
        public IActionResult Edit(CharacterEditViewModel model)
        {
            if (!ModelState.IsValid)
            {
                model.Races     = work.RaceRepository.GetAll().Select(e => RaceModel.GenerateRaceModelFromDTO(e)).ToList();
                model.Classes   = work.ClassRepository.GetAll().Select(e => ClassModel.GenerateClassModelFromDTO(e)).ToList();
                model.BaseStats = work.BaseStatRepository.GetAll().Select(e => BaseStatModel.GeneralBaseStatModelFromDTO(e)).ToList();

                return(View(model));
            }

            work.TemplateCharacterRepository.Update(CharacterModel.GenerateCharacterDTOFromModel(model.CharacterModel));
            work.Save();

            if (model.GameID != null)
            {
                return(RedirectToAction("AddCharacter", "Game", new { id = model.GameID }));
            }
            return(RedirectToAction("Index"));
        }