mirror of
https://github.com/sphildreth/roadie
synced 2024-11-30 08:00:21 +00:00
57 lines
No EOL
1.8 KiB
C#
57 lines
No EOL
1.8 KiB
C#
using Microsoft.AspNetCore.Authorization;
|
|
using Microsoft.AspNetCore.Identity;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using Microsoft.Extensions.Configuration;
|
|
using Microsoft.Extensions.Logging;
|
|
using Roadie.Api.Services;
|
|
using Roadie.Library.Caching;
|
|
using Roadie.Library.Identity;
|
|
using Roadie.Library.Models;
|
|
using System;
|
|
using System.Net;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace Roadie.Api.Controllers
|
|
{
|
|
[Produces("application/json")]
|
|
[Route("artist")]
|
|
[ApiController]
|
|
[Authorize]
|
|
public class ArtistController : EntityControllerBase
|
|
{
|
|
private IArtistService ArtistService { get; }
|
|
|
|
private UserManager<ApplicationUser> UserManager { get; }
|
|
|
|
public ArtistController(IArtistService artistService, ILoggerFactory logger, ICacheManager cacheManager, IConfiguration configuration, UserManager<ApplicationUser> userManager)
|
|
: base(cacheManager, configuration)
|
|
{
|
|
this._logger = logger.CreateLogger("RoadieApi.Controllers.ArtistController");
|
|
this.ArtistService = artistService;
|
|
this.UserManager = userManager;
|
|
}
|
|
|
|
//[EnableQuery]
|
|
//public IActionResult Get()
|
|
//{
|
|
// return Ok(this._RoadieDbContext.Artists.ProjectToType<models.Artist>());
|
|
//}
|
|
|
|
[HttpGet("{id}")]
|
|
[ProducesResponseType(200)]
|
|
[ProducesResponseType(404)]
|
|
public async Task<ActionResult<Artist>> Get(Guid id, string inc = null)
|
|
{
|
|
var result = await this.ArtistService.ArtistById(null, id, (inc ?? Artist.DefaultIncludes).ToLower().Split(","));
|
|
if (result == null)
|
|
{
|
|
return NotFound();
|
|
}
|
|
if (!result.IsSuccess)
|
|
{
|
|
return StatusCode((int)HttpStatusCode.InternalServerError);
|
|
}
|
|
return Ok(result);
|
|
}
|
|
}
|
|
} |