Another step towards getting rid of HttpResponseException
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.IO;
|
||||
@@ -10,10 +10,9 @@ using Umbraco.Core.Mapping;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Core.Services;
|
||||
using Umbraco.Core.Strings;
|
||||
using Umbraco.Web.BackOffice.Filters;
|
||||
using Umbraco.Web.Common.ActionsResults;
|
||||
using Umbraco.Web.Common.Attributes;
|
||||
using Umbraco.Web.Common.Authorization;
|
||||
using Umbraco.Web.Common.Exceptions;
|
||||
using Umbraco.Web.Models.ContentEditing;
|
||||
using Constants = Umbraco.Core.Constants;
|
||||
|
||||
@@ -63,11 +62,11 @@ namespace Umbraco.Web.BackOffice.Controllers
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
[DetermineAmbiguousActionByPassingParameters]
|
||||
public TemplateDisplay GetById(int id)
|
||||
public ActionResult<TemplateDisplay> GetById(int id)
|
||||
{
|
||||
var template = _fileService.GetTemplate(id);
|
||||
if (template == null)
|
||||
throw new HttpResponseException(HttpStatusCode.NotFound);
|
||||
return new ValidationErrorResult(template, StatusCodes.Status404NotFound);
|
||||
|
||||
return _umbracoMapper.Map<ITemplate, TemplateDisplay>(template);
|
||||
}
|
||||
@@ -79,11 +78,11 @@ namespace Umbraco.Web.BackOffice.Controllers
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
[DetermineAmbiguousActionByPassingParameters]
|
||||
public TemplateDisplay GetById(Guid id)
|
||||
public ActionResult<TemplateDisplay> GetById(Guid id)
|
||||
{
|
||||
var template = _fileService.GetTemplate(id);
|
||||
if (template == null)
|
||||
throw new HttpResponseException(HttpStatusCode.NotFound);
|
||||
return new ValidationErrorResult(template, StatusCodes.Status404NotFound);
|
||||
|
||||
return _umbracoMapper.Map<ITemplate, TemplateDisplay>(template);
|
||||
}
|
||||
@@ -94,16 +93,16 @@ namespace Umbraco.Web.BackOffice.Controllers
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
[DetermineAmbiguousActionByPassingParameters]
|
||||
public TemplateDisplay GetById(Udi id)
|
||||
public ActionResult<TemplateDisplay> GetById(Udi id)
|
||||
{
|
||||
var guidUdi = id as GuidUdi;
|
||||
if (guidUdi == null)
|
||||
throw new HttpResponseException(HttpStatusCode.NotFound);
|
||||
return new ValidationErrorResult(guidUdi, StatusCodes.Status404NotFound);
|
||||
|
||||
var template = _fileService.GetTemplate(guidUdi.Guid);
|
||||
if (template == null)
|
||||
{
|
||||
throw new HttpResponseException(HttpStatusCode.NotFound);
|
||||
return new ValidationErrorResult(template, StatusCodes.Status404NotFound);
|
||||
}
|
||||
|
||||
return _umbracoMapper.Map<ITemplate, TemplateDisplay>(template);
|
||||
@@ -120,7 +119,7 @@ namespace Umbraco.Web.BackOffice.Controllers
|
||||
{
|
||||
var template = _fileService.GetTemplate(id);
|
||||
if (template == null)
|
||||
throw new HttpResponseException(HttpStatusCode.NotFound);
|
||||
return new ValidationErrorResult(template, StatusCodes.Status404NotFound);
|
||||
|
||||
_fileService.DeleteTemplate(template.Alias);
|
||||
return Ok();
|
||||
@@ -167,7 +166,7 @@ namespace Umbraco.Web.BackOffice.Controllers
|
||||
// update
|
||||
var template = _fileService.GetTemplate(display.Id);
|
||||
if (template == null)
|
||||
throw new HttpResponseException(HttpStatusCode.NotFound);
|
||||
return new ValidationErrorResult(template, StatusCodes.Status404NotFound);
|
||||
|
||||
var changeMaster = template.MasterTemplateAlias != display.MasterTemplateAlias;
|
||||
var changeAlias = template.Alias != display.Alias;
|
||||
@@ -239,7 +238,7 @@ namespace Umbraco.Web.BackOffice.Controllers
|
||||
{
|
||||
master = _fileService.GetTemplate(display.MasterTemplateAlias);
|
||||
if (master == null)
|
||||
throw new HttpResponseException(HttpStatusCode.NotFound);
|
||||
return new ValidationErrorResult(master, StatusCodes.Status404NotFound);
|
||||
}
|
||||
|
||||
// we need to pass the template name as alias to keep the template file casing consistent with templates created with content
|
||||
|
||||
Reference in New Issue
Block a user