using Backend.DatabaseHandler; using Backend.ServiceHander; using Backend.Interface; using Microsoft.AspNetCore.Mvc; namespace Backend.Controllers { [ApiController] [Route("api/user-interest")] public sealed class UserInterestController : ControllerBase { private readonly IUserInterestStore _store; public UserInterestController(IUserInterestStore store) { _store = store; } [HttpGet("fetch")] public async Task> FetchAll( [FromQuery] string user, [FromQuery] string type) { try { List items = await _store.FetchAllAsync(user, type); return Ok(new UserInterestFetchResponse { Items = items }); } catch (ArgumentException ex) { return BadRequest(ex.Message); } } [HttpPost("add")] public async Task> Add( [FromBody] UserInterestModifyRequest request) { try { bool success = await _store.AddAsync(request.User, request.Type, request.Value); return Ok(new BoolResponse { Success = success }); } catch (ArgumentException ex) { return BadRequest(ex.Message); } } [HttpDelete("remove")] public async Task> Remove( [FromBody] UserInterestModifyRequest request) { try { bool success = await _store.RemoveAsync(request.User, request.Type, request.Value); return Ok(new BoolResponse { Success = success }); } catch (ArgumentException ex) { return BadRequest(ex.Message); } } } }