Ejemplo n.º 1
0
        public IHttpActionResult CreateCharacter([FromBody] CharacterCreateModel characterToCreate)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            var service = CreateCharacterService();

            service.CreateCharacter(characterToCreate);
            return(Ok());
        }
Ejemplo n.º 2
0
        public void CreateCharacter(CharacterCreateModel characterToCreate)
        {
            var entity = new Character()
            {
                FirstName       = characterToCreate.FirstName,
                LastName        = characterToCreate.LastName,
                Species         = characterToCreate.Species,
                Price           = characterToCreate.Price,
                Affiliation     = characterToCreate.Affiliation,
                DefaultWeaponId = characterToCreate.DefaultWeaponId,
                DefaultShipId   = characterToCreate.DefaultShipId
            };

            _ctx.Characters.Add(entity);
            _ctx.SaveChanges();
        }
Ejemplo n.º 3
0
        public IActionResult Create([Bind("Name, Description")] CharacterCreateModel characterCreateModel)
        {
            if (!ModelState.IsValid)
            {
                return(View(characterCreateModel));
            }

            _repository.CreateCharacter(
                Character.CreateCharacter(
                    characterCreateModel.Name,
                    characterCreateModel.Description
                    )
                );

            return(RedirectToAction(nameof(Index)));
        }
Ejemplo n.º 4
0
        public ActionResult Create(CreateCharacterSection section)
        {
            // Setup our view model
            CharacterCreateModel characterData = new CharacterCreateModel();

            characterData.SavedCharacter         = SacredSession.CharCreateModel;
            characterData.SavedCharacter.Section = section;

            // Fill in our view model
            if (section == CreateCharacterSection.Race)
            {
                characterData.Races = RaceApiProxy.GetAll(SSConfiguration.WebApiUrl, User.Identity.Name);
            }
            else if (section == CreateCharacterSection.Class)
            {
                characterData.Classes = ClassApiProxy.GetAll(SSConfiguration.WebApiUrl, User.Identity.Name);
            }
            else if (section == CreateCharacterSection.Heroic)
            {
                characterData.Heroics = HeroicApiProxy.GetAll(SSConfiguration.WebApiUrl, User.Identity.Name);
            }

            return(View(characterData));
        }