Exemplo n.º 1
0
        public async Task <IActionResult> Add([FromBody] Salon salon)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            try
            {
                await salonRepository.Add(salon);

                await salonRepository.SaveChanges();
            }
            catch (Exception ex)
            {
                log.LogError("[POST: api/Salon] {0}", ex.Message);
                return(StatusCode(StatusCodes.Status500InternalServerError, ex.Message));
            }

            return(CreatedAtAction(nameof(GetOne), new { id = salon.Id }, salon));
        }