Ejemplo n.º 1
0
        public IActionResult Post([FromBody] Deviser.Core.Common.DomainTypes.Page page)
        {
            try
            {
                var result = _navigation.CreatePage(page);
                if (result != null)
                {
                    return(Ok(result));
                }

                return(BadRequest("Invalid page"));
            }
            catch (Exception ex)
            {
                _logger.LogError(string.Format("Error occured while creating a page, PageId: ", page.Id), ex);
                return(new StatusCodeResult(StatusCodes.Status500InternalServerError));
            }
        }
        public async Task <IFormResult <PageViewModel> > CreateItem(PageViewModel item)
        {
            var translateLanguages = GetTranslateLanguages();
            var isMultilingual     = translateLanguages.Count > 0;

            var pageResult = _navigation.CreatePage(ConvertToSingePage(item, isMultilingual, translateLanguages));

            if (pageResult == null)
            {
                return new FormResult <PageViewModel>()
                       {
                           IsSucceeded  = false,
                           ErrorMessage = "Unable to create a page"
                       }
            }
            ;
            var result = new FormResult <PageViewModel>(ConvertToPageViewModel(pageResult, isMultilingual, translateLanguages))
            {
                IsSucceeded    = true,
                SuccessMessage = "Page has been created"
            };

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