| 123456789101112131415161718192021222324252627282930313233343536373839 |
- using AutoMapper;
- using Diligent.WebAPI.Business.Services;
- using Diligent.WebAPI.Data.Entities;
- using Microsoft.AspNetCore.Mvc;
-
- namespace Diligent.WebAPI.Host.Controllers
- {
- [ApiVersion("1.0")]
- [ApiController]
- [Route("v{version:apiVersion}/[controller]")]
- public class ChatController : ControllerBase
- {
- private readonly RoomService _roomService;
-
- public ChatController(RoomService roomService)
- {
- _roomService = roomService;
- }
-
- [HttpGet]
- public async Task<IActionResult> GetAll()
- {
- return Ok(await _roomService.GetRoomsAsync());
- }
-
- [HttpPost]
- public async Task<IActionResult> CreateChat(Room room)
- {
- if(room == null)
- {
- throw new BadHttpRequestException("Object cannot be null");
- }
-
- await _roomService.CreateRoomAsync(room);
-
- return Ok(room);
- }
- }
- }
|