public ActionResult <int> AddLeaper(CreateLeaperRequest createRequest)
        {
            if (!_validator.Validate(createRequest))
            {
                return(BadRequest(new { error = "users must have a username" }));
            }

            var newLeaper = _leaperRepository.AddLeaper(createRequest.Name, createRequest.Age, createRequest.Budget);

            return(Created($"api/leaper/{newLeaper.Id}", newLeaper));
        }
Exemplo n.º 2
0
        public ActionResult AddLeaper(CreateLeaperRequest createRequest)
        {
            if (_validator.Validate(createRequest))
            {
                return(BadRequest(new { error = "leaper must have a name" }));
            }

            var newLeaper = _leaperRepository.AddLeaper(createRequest.LeaperName, createRequest.Age, createRequest.BudgetAmount);

            return(Created($"api/leapers/{newLeaper.Id}", newLeaper));
        }