Exemplo n.º 1
0
        public IActionResult PostStyle([FromBody] StyleModel styleModel)
        {
            _logger.LogInformation($"{nameof(StyleController)} : {nameof(PostStyle)} was called.");
            try
            {
                if (styleModel == null)
                {
                    return(BadRequest("Style is required"));
                }

                if (_styleService.FindById(styleModel.Id) != null)
                {
                    return(Conflict("Style already exists"));
                }

                _styleService.Create(styleModel);
                _styleService.Save();
                return(Ok("Style Created"));
            }
            catch (DbException exception)
            {
                _logger.LogError(exception.Message);
                return(BadRequest(exception.Message));
            }
            catch (Exception exception)
            {
                _logger.LogError(exception.Message);
                throw;
            }
        }