public void UpdateInfo(CharacterVM character)
        {
            var model = new CharacterVM()
            {
                Id     = character.Id,
                Name   = character.Name,
                Region = character.Region,
                Weapon = character.Weapon,
                Vision = character.Vision
            };

            CharacterDALMapper.Update(model);
        }
        public ActionResult CharacterDetails(int id, string viewName)
        {
            CharacterVM model = CharacterDALMapper.FindById(id);

            if (model == null)
            {
                return(HttpNotFound());
            }

            //Get actual name and save it in a temporary state object
            TempData[ACTUAL_NAME_KEY] = model.Name;

            return(View(viewName, model));
        }
        private bool IsNameAvailable(string name)
        {
            if (CharacterDALMapper.FindByName(name) is null)
            {
                return(true);
            }
            else
            {
                //Get actual name
                var actualName = TempData.ContainsKey(ACTUAL_NAME_KEY)
                                                        ? TempData[ACTUAL_NAME_KEY].ToString()
                                                        : String.Empty;

                //Store the actual name again for further invalid requests
                TempData[ACTUAL_NAME_KEY] = actualName;

                if (name.Equals(actualName, StringComparison.OrdinalIgnoreCase))
                {
                    return(true);
                }
            }

            return(false);
        }
Esempio n. 4
0
 public HomeController()
 {
     //Instancio por única vez el DALMapper
     var mapper = new CharacterDALMapper(new CharactersDAL());
 }
        public ActionResult GetCharacters()
        {
            var characters = CharacterDALMapper.List();

            return(View(characters));
        }