Doxy, -Wall -Werror, other cleanup and organization first round

This commit is contained in:
2023-08-19 20:46:31 -04:00
parent 1fedd4d016
commit 49de8aa8d7
43 changed files with 728 additions and 354 deletions

View File

@ -1,28 +1,38 @@
using IO.Swagger.Models.db;
using IO.Swagger.Models.dto;
using IO.Swagger.Models.RequestDto;
using IO.Swagger.Services;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace IO.Swagger.Repositories
{
/// <summary>
/// The EF implementation of this interface
/// </summary>
/// <seealso cref="ICurrencyRepository" />
public class CurrencyRepository : ICurrencyRepository
{
BankDbContext context;
private readonly BankDbContext context;
/// <summary>
/// Initializes a new instance of the <see cref="CurrencyRepository"/> class.
/// </summary>
/// <param name="context">The db context.</param>
/// <exception cref="ArgumentNullException">context</exception>
public CurrencyRepository(BankDbContext context)
{
this.context = context ?? throw new ArgumentNullException(nameof(context));
}
/// <inheritdoc/>
public async Task<List<Currency>> GetAllCurrencies()
{
return await context.Currencies.Include(c => c.User).Include(c=>c.Transactions).ToListAsync();
return await context.Currencies.Include(c => c.User).Include(c => c.Transactions).ToListAsync();
}
/// <inheritdoc/>
public async Task<bool> CreateCurrency(CurrencyCreateBody request, int userId)
{
request.Symbol = request.Symbol.Trim();
@ -36,10 +46,11 @@ namespace IO.Swagger.Repositories
Symbol = request.Symbol,
UserId = userId
});
return await context.SaveChangesAsync() > 0;
}
/// <inheritdoc/>
public async Task<bool> MintCurrency(CurrencyMintBody request, int userId)
{
var existsAndIsOwner = await context.Currencies.AnyAsync(c => c.CurrencyId == request.CurrencyId && c.UserId == userId);
@ -56,6 +67,6 @@ namespace IO.Swagger.Repositories
});
return await context.SaveChangesAsync() > 0;
}
}
}
}