public async Task <IActionResult> GetCallToActionOptionById(int id)
        {
            if (id <= 0)
            {
                ProblemDetails problem = new ProblemDetails
                {
                    Title    = "Invalid Id specified",
                    Detail   = "The specified id is invalid.",
                    Instance = "72702E9D-5D99-40F7-A921-033A79275877"
                };
                return(BadRequest(problem));
            }

            CallToActionOption callToActionOption = await callToActionOptionService.FindAsync(id);

            if (callToActionOption == null)
            {
                ProblemDetails problem = new ProblemDetails
                {
                    Title    = "Failed getting the call to action option.",
                    Detail   = "The database does not contain a call to action option with the specified id.",
                    Instance = "1EAFDED6-74B8-4DA4-A58E-375F58AFDB2E"
                };
                return(NotFound(problem));
            }

            CallToActionOptionResourceResult model =
                mapper.Map <CallToActionOption, CallToActionOptionResourceResult>(callToActionOption);

            return(Ok(model));
        }
        public async Task <IActionResult> CreateCallToActionOption(CallToActionOptionResource callToActionOptionResource)
        {
            if (callToActionOptionResource == null)
            {
                ProblemDetails problem = new ProblemDetails
                {
                    Title    = "Failed creating the call to action option.",
                    Detail   = "The institution resource is null.",
                    Instance = "E2FD8F7B-96B1-4406-9E90-138AA36B570B"
                };
                return(BadRequest(problem));
            }

            CallToActionOption option =
                mapper.Map <CallToActionOptionResource, CallToActionOption>(callToActionOptionResource);

            if ((await callToActionOptionService.GetCallToActionOptionsFromTypeAsync(option.Type)).Any() &&
                (await callToActionOptionService.GetCallToActionOptionFromValueAsync(option.Value)).Any())
            {
                ProblemDetails problem = new ProblemDetails
                {
                    Title    = "Failed creating the call to action option.",
                    Detail   = "Identical call to action option already exists.",
                    Instance = "1DA7B168-FAD1-41B6-A90F-3AAEB26147CE"
                };
                return(BadRequest(problem));
            }

            try
            {
                callToActionOptionService.Add(option);
                callToActionOptionService.Save();
                CallToActionOptionResourceResult model =
                    mapper.Map <CallToActionOption, CallToActionOptionResourceResult>(option);
                return(Created(nameof(CreateCallToActionOption), model));
            } catch (DbUpdateException)
            {
                Log.Logger.Error("Database exception");

                ProblemDetails problem = new ProblemDetails
                {
                    Title    = "Failed Saving the call to action option.",
                    Detail   = "Failed saving the call to action option to the database.",
                    Instance = "5A1D2B14-E320-4FAE-84DF-BC02B996588B"
                };
                return(BadRequest(problem));
            }
        }