using Diligent.WebAPI.Host.DTOs.Notification;
using Diligent.WebAPI.Host.Mediator.Notifications.Commands;
using Diligent.WebAPI.Host.Mediator.Notifications.Queries;
using MediatR;
using Microsoft.AspNetCore.Mvc;

namespace Diligent.WebAPI.Host.Controllers
{
    [ApiVersion("1.0")]
    [ApiController]
    [Route("v{version:apiVersion}/[controller]")]
    public class NotificationController : ControllerBase
    {
        private readonly IMediator _mediator;

        public NotificationController(IMediator mediator)
        {
            _mediator = mediator;
        }

        [HttpGet("{id}")]
        public async Task<IActionResult> GetNotifications([FromRoute] string id) =>
            Ok(await _mediator.Send(new GetNotificationsQuery(id)));

        [HttpPost]
        public async Task<IActionResult> ReadNotifications([FromBody] NotificationDeleteDTO userConnection) =>
            Ok(await _mediator.Send(new DeleteNotificationCommand(userConnection)));
    }
}
