mirror of
https://github.com/D4M13N-D3V/comissions-app-core-api.git
synced 2025-03-14 10:04:55 +00:00
fix: added endpoint for admin to get and send messages on a artist request.
This commit is contained in:
parent
d8a32fffc6
commit
850288258a
@ -1,7 +1,9 @@
|
|||||||
|
using comissions.app.api.Extensions;
|
||||||
using comissions.app.api.Models.ArtistRequest;
|
using comissions.app.api.Models.ArtistRequest;
|
||||||
using comissions.app.api.Services.Payment;
|
using comissions.app.api.Services.Payment;
|
||||||
using comissions.app.database;
|
using comissions.app.database;
|
||||||
using comissions.app.database.Entities;
|
using comissions.app.database.Entities;
|
||||||
|
using comissions.app.database.Models;
|
||||||
using Microsoft.AspNetCore.Authorization;
|
using Microsoft.AspNetCore.Authorization;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
@ -168,4 +170,28 @@ public class AdminArtistRequestsController : Controller
|
|||||||
await _client.Event.Trigger(newTriggerModel);
|
await _client.Event.Trigger(newTriggerModel);
|
||||||
return Ok();
|
return Ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[HttpGet]
|
||||||
|
[Route("Messages")]
|
||||||
|
public async Task<IActionResult> GetMessages()
|
||||||
|
{
|
||||||
|
var messages = await _dbContext.ArtistRequestMessages.ToListAsync();
|
||||||
|
var result = messages.Select(x=>x.ToModel()).ToList();
|
||||||
|
return Ok(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPost]
|
||||||
|
[Route("Messages")]
|
||||||
|
public async Task<IActionResult> AddMessage([FromBody] string message)
|
||||||
|
{
|
||||||
|
var newMessage = new ArtistRequestMessage()
|
||||||
|
{
|
||||||
|
UserId = User.GetUserId(),
|
||||||
|
Message = message,
|
||||||
|
SentDate = DateTime.UtcNow
|
||||||
|
};
|
||||||
|
_dbContext.ArtistRequestMessages.Add(newMessage);
|
||||||
|
await _dbContext.SaveChangesAsync();
|
||||||
|
return Ok(newMessage.ToModel());
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user