Example #1
0
        public ActionResult CreateSolution([FromBody] SolutionRequest item)
        {
            if (item == null || !ModelState.IsValid)
            {
                return(BadRequest("Model state not valid."));
            }

            if (_solutionService.SolutionExists(item.Title))
            {
                return(BadRequest("Solution already exists."));
            }

            var now = DateTime.UtcNow;

            var solution = new Solution
            {
                Title      = item.Title,
                UpdatedBy  = "Oscar Negrete",
                LastUpdate = now
            };

            try
            {
                _solutionService.AddSolution(solution);
            }
            catch (Exception)
            {
                return(BadRequest("Could not create solution"));
            }

            return(Ok($"Solution created: {item.Title}"));
        }