2022-08-18 22:59:13 +03:00
|
|
|
using System;
|
|
|
|
using BlueWest.Data;
|
2022-08-22 00:14:50 +03:00
|
|
|
using BlueWest.WebApi.EF;
|
2022-09-10 07:12:03 +03:00
|
|
|
using Microsoft.AspNetCore.Authentication.Cookies;
|
|
|
|
using Microsoft.AspNetCore.Authentication.JwtBearer;
|
|
|
|
using Microsoft.AspNetCore.Authorization;
|
2022-09-17 22:13:35 +03:00
|
|
|
using Microsoft.AspNetCore.Cors;
|
2022-08-18 22:59:13 +03:00
|
|
|
using Microsoft.AspNetCore.Http;
|
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
|
|
|
|
namespace BlueWest.WebApi.Controllers;
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// The controller responsible to fetch currency data
|
|
|
|
/// </summary>
|
|
|
|
[ApiController]
|
|
|
|
[Route("[controller]")]
|
2022-09-10 07:12:03 +03:00
|
|
|
[Authorize(AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme)]
|
|
|
|
[Authorize(AuthenticationSchemes = CookieAuthenticationDefaults.AuthenticationScheme)]
|
2022-09-17 22:13:35 +03:00
|
|
|
//[Authorize(Roles = "Administrator")]
|
|
|
|
[EnableCors(Constants.CorsPolicyName)]
|
|
|
|
|
2022-08-22 02:51:45 +03:00
|
|
|
public class FinanceController : ControllerBase
|
2022-08-18 22:59:13 +03:00
|
|
|
{
|
|
|
|
private readonly FinanceDbContext _dbContext;
|
|
|
|
|
2022-08-22 02:51:45 +03:00
|
|
|
/// <summary>
|
|
|
|
/// Finance Controller Api Controller
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="dbContext">The finance database context</param>
|
2022-08-18 22:59:13 +03:00
|
|
|
public FinanceController(FinanceDbContext dbContext)
|
|
|
|
{
|
|
|
|
_dbContext = dbContext;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Returns a transaction by the provided id
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="userId"></param>
|
|
|
|
/// <param name="transactionId"></param>
|
|
|
|
/// <returns></returns>
|
|
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
|
|
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
|
|
|
[HttpGet("{userId}/transactions/{transactionId}")]
|
|
|
|
public ActionResult GetTransactionsById(int userId, TimeSpan transactionId)
|
|
|
|
{
|
|
|
|
return new NotFoundResult();
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Posts a finance transaction
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="userId"></param>
|
|
|
|
/// <param name="financeTransaction"></param>
|
|
|
|
/// <returns></returns>
|
|
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
|
|
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
|
|
|
[HttpPost("{userId}/transactions")]
|
|
|
|
public ActionResult PostTransaction(int userId, FinanceOpCreate financeTransaction)
|
|
|
|
{
|
|
|
|
return new BadRequestResult();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Get Transactions
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="userId"></param>
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
|
|
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
|
|
|
[HttpGet("{userId}/transactions")]
|
|
|
|
public ActionResult GetTransactions(int userId)
|
|
|
|
{
|
|
|
|
return Ok();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|