示例#1
0
        public ActionResult <int> Post(
            [FromBody] CreateClientRequest clientRequest)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }

            var nextId = mockClients.Data.Max(c => c.Id) + 1;
            var client = new Client(
                id: nextId,
                name: clientRequest.Name,
                email: clientRequest.Email,
                gender: clientRequest.Gender,
                phone: clientRequest.Phone);

            mockClients.Add(client);

            return(CreatedAtAction(nameof(Post), new { client.Id }));
        }