예제 #1
0
        public ActionResult AddAssassin([FromBody] CreateAssassinRequest request)
        {
            if (!_validator.Validate(request))
            {
                return(BadRequest(new { error = "Assassins must have a Codename, Catchphrase, and Preferred Weapon" }));
            }

            var newAssassin = _repository.AddAssassin(request.CodeName, request.CatchPhrase, request.PreferredWeapon);

            return(Created($"api/assassin/{newAssassin.Id}", newAssassin));
        }
예제 #2
0
        public ActionResult AddAssassin(CreateAssassinRequest request)
        {
            if (!_validator.Validate(request))
            {
                return(BadRequest());
            }

            var newAssassin = _repository.AddAssassin(request.CodeName, request.Catchphrase, request.PreferredWeapon);

            return(Created($"api/Assassin/{newAssassin.Id}", newAssassin));
        }
예제 #3
0
        public ActionResult AddAssassin(CreateAssassinRequest assassin)
        {
            if (!_validator.Validate(assassin))
            {
                BadRequest(error: "Assassin needs a catch phrase, code name, and preferred weapon");
            }

            var newAssassin = new Assassin(assassin.CodeName, assassin.CatchPhrase, assassin.PreferredWeapon);

            _assassinRepository.AddAssassin(newAssassin);

            return(Created($"api/assassin/register/{newAssassin.Id}", newAssassin));
        }