Beispiel #1
0
        public IActionResult CreateOptionList([FromBody] Deviser.Core.Common.DomainTypes.OptionList optionList)
        {
            try
            {
                if (optionList == null || string.IsNullOrEmpty(optionList.Name))
                {
                    return(BadRequest("Invalid parameter"));
                }

                if (_optionListRepository.GetOptionList(optionList.Name) != null)
                {
                    return(BadRequest("Option list already exist"));
                }

                var result = _optionListRepository.CreateOptionList(optionList);
                if (result != null)
                {
                    return(Ok(result));
                }
                return(NotFound());
            }
            catch (Exception ex)
            {
                _logger.LogError(string.Format("Error occured while creating option list"), ex);
                return(new StatusCodeResult(StatusCodes.Status500InternalServerError));
            }
        }
        public async Task <IFormResult <OptionList> > CreateItem(OptionList item)
        {
            ParseProperty(item);
            var resultOptionList = _optionListRepository.CreateOptionList(item);

            ParseResult(resultOptionList);
            if (resultOptionList == null)
            {
                return new FormResult <OptionList>()
                       {
                           IsSucceeded  = false,
                           ErrorMessage = "Unable to create the OptionList"
                       }
            }
            ;

            var result = new FormResult <OptionList>(resultOptionList)
            {
                IsSucceeded    = true,
                SuccessMessage = "OptionList has been created"
            };

            return(await Task.FromResult(result));
        }