示例#1
0
        public async Task<ActionResult> Post([FromBody] ProjetoEntity projeto)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            try
            {

                var result = await _servicoprojetos.Post(projeto);
                if (result != null)
                {
                    return Created(new Uri(Url.Link("GetProjetoWithId", new { id = result.id })), result);
                }
                else
                {
                    return BadRequest();
                }

            }
            catch (ArgumentException ex)
            {
                return StatusCode((int)HttpStatusCode.InternalServerError, ex.Message);
            }
        }