75 lines
2.0 KiB
C#
75 lines
2.0 KiB
C#
using Microsoft.AspNetCore.Mvc;
|
|
using Demo.Data.RemoteData.RemoteDataBase.DAO;
|
|
using Demo.Domain.UseCase;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
|
|
namespace Demo.API.Controllers
|
|
{
|
|
[ApiController]
|
|
[Route("api/[controller]")]
|
|
public class AdminController : ControllerBase
|
|
{
|
|
private readonly UserUseCase _userUseCase;
|
|
private readonly GroupUseCase _groupUseCase;
|
|
private readonly UseCasePresence _presenceUseCase;
|
|
|
|
public AdminController(UserUseCase userUseCase, GroupUseCase groupUseCase, UseCasePresence presenceUseCase)
|
|
{
|
|
_userUseCase = userUseCase;
|
|
_groupUseCase = groupUseCase;
|
|
_presenceUseCase = presenceUseCase;
|
|
}
|
|
|
|
[HttpPost("addUser")]
|
|
public IActionResult AddUser([FromBody] User user)
|
|
{
|
|
_userUseCase.UpdateUser(user);
|
|
return Ok();
|
|
}
|
|
|
|
[HttpPut("updateUser")]
|
|
public IActionResult UpdateUser([FromBody] User user)
|
|
{
|
|
_userUseCase.UpdateUser(user);
|
|
return Ok();
|
|
}
|
|
|
|
[HttpDelete("deleteUser/{id}")]
|
|
public IActionResult DeleteUser(Guid id)
|
|
{
|
|
_userUseCase.DeleteUser(id);
|
|
return Ok();
|
|
}
|
|
|
|
[HttpGet("getUser/{id}")]
|
|
public IActionResult GetUser(Guid id)
|
|
{
|
|
var user = _userUseCase.GetUserById(id);
|
|
if (user == null)
|
|
{
|
|
return NotFound();
|
|
}
|
|
return Ok(user);
|
|
}
|
|
|
|
[HttpGet("getAllUsers")]
|
|
public IActionResult GetAllUsers()
|
|
{
|
|
var users = _userUseCase.GetAllUsers();
|
|
return Ok(users);
|
|
}
|
|
|
|
[HttpGet("getPresenceByUser/{userId}")]
|
|
public IActionResult GetPresenceByUser(Guid userId)
|
|
{
|
|
var presence = _presenceUseCase.GetPresenceByGroup(userId);
|
|
if (presence == null)
|
|
{
|
|
return NotFound();
|
|
}
|
|
return Ok(presence);
|
|
}
|
|
}
|
|
} |