diff --git a/CommBank-Server/CommBank.csproj b/CommBank-Server/CommBank.csproj
deleted file mode 100644
index 983cc882..00000000
--- a/CommBank-Server/CommBank.csproj
+++ /dev/null
@@ -1,35 +0,0 @@
-
-
-
- net6.0
- enable
- enable
- CommBank_Server
- CommBank-Server
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/CommBank-Server/Controllers/AccountController.cs b/CommBank-Server/Controllers/AccountController.cs
deleted file mode 100644
index b5b22995..00000000
--- a/CommBank-Server/Controllers/AccountController.cs
+++ /dev/null
@@ -1,72 +0,0 @@
-using Microsoft.AspNetCore.Mvc;
-using CommBank.Services;
-using CommBank.Models;
-
-namespace CommBank.Controllers;
-
-[ApiController]
-[Route("api/[controller]")]
-public class AccountController : ControllerBase
-{
- private readonly IAccountsService _accountsService;
-
- public AccountController(IAccountsService accountsService) =>
- _accountsService = accountsService;
-
- [HttpGet]
- public async Task> Get() =>
- await _accountsService.GetAsync();
-
- [HttpGet("{id:length(24)}")]
- public async Task> Get(string id)
- {
- var account = await _accountsService.GetAsync(id);
-
- if (account is null)
- {
- return NotFound();
- }
-
- return account;
- }
-
- [HttpPost]
- public async Task Post(Account newAccount)
- {
- await _accountsService.CreateAsync(newAccount);
-
- return CreatedAtAction(nameof(Get), new { id = newAccount.Id }, newAccount);
- }
-
- [HttpPut("{id:length(24)}")]
- public async Task Update(string id, Account updatedAccount)
- {
- var account = await _accountsService.GetAsync(id);
-
- if (account is null)
- {
- return NotFound();
- }
-
- updatedAccount.Id = account.Id;
-
- await _accountsService.UpdateAsync(id, updatedAccount);
-
- return NoContent();
- }
-
- [HttpDelete("{id:length(24)}")]
- public async Task Delete(string id)
- {
- var account = await _accountsService.GetAsync(id);
-
- if (account is null)
- {
- return NotFound();
- }
-
- await _accountsService.RemoveAsync(id);
-
- return NoContent();
- }
-}
\ No newline at end of file
diff --git a/CommBank-Server/Controllers/AuthController.cs b/CommBank-Server/Controllers/AuthController.cs
deleted file mode 100644
index 52bbe0c9..00000000
--- a/CommBank-Server/Controllers/AuthController.cs
+++ /dev/null
@@ -1,28 +0,0 @@
-using Microsoft.AspNetCore.Mvc;
-using CommBank.Services;
-using CommBank.Models;
-
-namespace CommBank.Controllers;
-
-[ApiController]
-[Route("api/Auth")]
-public class AuthController : ControllerBase
-{
- private readonly AuthService _authService;
-
- public AuthController(AuthService authService) =>
- _authService = authService;
-
- [HttpPost("Login")]
- public async Task Post(LoginInput input)
- {
- var user = await _authService.Login(input.Email, input.Password);
-
- if (user is null)
- {
- return NotFound();
- }
-
- return NoContent();
- }
-}
\ No newline at end of file
diff --git a/CommBank-Server/Controllers/GoalController.cs b/CommBank-Server/Controllers/GoalController.cs
deleted file mode 100644
index 98271a5f..00000000
--- a/CommBank-Server/Controllers/GoalController.cs
+++ /dev/null
@@ -1,102 +0,0 @@
-using Microsoft.AspNetCore.Mvc;
-using CommBank.Services;
-using CommBank.Models;
-
-namespace CommBank.Controllers;
-
-[ApiController]
-[Route("api/[controller]")]
-public class GoalController : ControllerBase
-{
- private readonly IGoalsService _goalsService;
- private readonly IUsersService _usersService;
-
- public GoalController(IGoalsService goalsService, IUsersService usersService)
- {
- _goalsService = goalsService;
- _usersService = usersService;
- }
-
- [HttpGet]
- public async Task> Get() =>
- await _goalsService.GetAsync();
-
- [HttpGet("{id:length(24)}")]
- public async Task> Get(string id)
- {
- var goal = await _goalsService.GetAsync(id);
-
- if (goal is null)
- {
- return NotFound();
- }
-
- return goal;
- }
-
- [HttpGet("User/{id:length(24)}")]
- public async Task?> GetForUser(string id) =>
- await _goalsService.GetForUserAsync(id);
-
- [HttpPost]
- public async Task Post(Goal newGoal)
- {
- await _goalsService.CreateAsync(newGoal);
-
- if (newGoal.Id is not null && newGoal.UserId is not null)
- {
- var user = await _usersService.GetAsync(newGoal.UserId);
-
- if (user is not null && user.Id is not null)
- {
- if (user.GoalIds is not null)
- {
- user.GoalIds.Add(newGoal.Id);
- }
- else
- {
- user.GoalIds = new()
- {
- newGoal.Id
- };
- }
-
- await _usersService.UpdateAsync(user.Id, user);
- }
- }
-
- return CreatedAtAction(nameof(Get), new { id = newGoal.Id }, newGoal);
- }
-
- [HttpPut("{id:length(24)}")]
- public async Task Update(string id, Goal updatedGoal)
- {
- var goal = await _goalsService.GetAsync(id);
-
- if (goal is null)
- {
- return NotFound();
- }
-
- updatedGoal.Id = goal.Id;
-
- await _goalsService.UpdateAsync(id, updatedGoal);
-
- return NoContent();
- }
-
- [HttpDelete("{id:length(24)}")]
- public async Task Delete(string id)
- {
- var goal = await _goalsService.GetAsync(id);
-
- if (goal is null)
- {
- return NotFound();
- }
-
- await _goalsService.RemoveAsync(id);
-
- return NoContent();
- }
-}
\ No newline at end of file
diff --git a/CommBank-Server/Controllers/HomeController.cs b/CommBank-Server/Controllers/HomeController.cs
deleted file mode 100644
index 1bbc6cff..00000000
--- a/CommBank-Server/Controllers/HomeController.cs
+++ /dev/null
@@ -1,32 +0,0 @@
-using System.Diagnostics;
-using Microsoft.AspNetCore.Mvc;
-using CommBank.Models;
-
-namespace CommBank.Controllers;
-
-public class HomeController : Controller
-{
- private readonly ILogger _logger;
-
- public HomeController(ILogger logger)
- {
- _logger = logger;
- }
-
- public IActionResult Index()
- {
- return View();
- }
-
- public IActionResult Privacy()
- {
- return View();
- }
-
- [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
- public IActionResult Error()
- {
- return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
- }
-}
-
diff --git a/CommBank-Server/Controllers/TagController.cs b/CommBank-Server/Controllers/TagController.cs
deleted file mode 100644
index 1311a2f9..00000000
--- a/CommBank-Server/Controllers/TagController.cs
+++ /dev/null
@@ -1,71 +0,0 @@
-using Microsoft.AspNetCore.Mvc;
-using CommBank.Services;
-
-namespace CommBank.Controllers;
-
-[ApiController]
-[Route("api/[controller]")]
-public class TagController : ControllerBase
-{
- private readonly ITagsService _tagsService;
-
- public TagController(ITagsService tagsService) =>
- _tagsService = tagsService;
-
- [HttpGet]
- public async Task> Get() =>
- await _tagsService.GetAsync();
-
- [HttpGet("{id:length(24)}")]
- public async Task> Get(string id)
- {
- var tag = await _tagsService.GetAsync(id);
-
- if (tag is null)
- {
- return NotFound();
- }
-
- return tag;
- }
-
- [HttpPost]
- public async Task Post(CommBank.Models.Tag newTag)
- {
- await _tagsService.CreateAsync(newTag);
-
- return CreatedAtAction(nameof(Get), new { id = newTag.Id }, newTag);
- }
-
- [HttpPut("{id:length(24)}")]
- public async Task Update(string id, CommBank.Models.Tag updatedTag)
- {
- var tag = await _tagsService.GetAsync(id);
-
- if (tag is null)
- {
- return NotFound();
- }
-
- updatedTag.Id = tag.Id;
-
- await _tagsService.UpdateAsync(id, updatedTag);
-
- return NoContent();
- }
-
- [HttpDelete("{id:length(24)}")]
- public async Task Delete(string id)
- {
- var tag = await _tagsService.GetAsync(id);
-
- if (tag is null)
- {
- return NotFound();
- }
-
- await _tagsService.RemoveAsync(id);
-
- return NoContent();
- }
-}
\ No newline at end of file
diff --git a/CommBank-Server/Controllers/TransactionController.cs b/CommBank-Server/Controllers/TransactionController.cs
deleted file mode 100644
index c8e0293a..00000000
--- a/CommBank-Server/Controllers/TransactionController.cs
+++ /dev/null
@@ -1,76 +0,0 @@
-using Microsoft.AspNetCore.Mvc;
-using CommBank.Models;
-using CommBank.Services;
-
-namespace CommBank.Controllers;
-
-[ApiController]
-[Route("api/[controller]")]
-public class TransactionController : ControllerBase
-{
- private readonly ITransactionsService _transactionsService;
-
- public TransactionController(ITransactionsService transactionsService) =>
- _transactionsService = transactionsService;
-
- [HttpGet]
- public async Task> Get() =>
- await _transactionsService.GetAsync();
-
- [HttpGet("User/{id:length(24)}")]
- public async Task?> GetForUser(string id) =>
- await _transactionsService.GetForUserAsync(id);
-
- [HttpGet("{id:length(24)}")]
- public async Task> Get(string id)
- {
- var transaction = await _transactionsService.GetAsync(id);
-
- if (transaction is null)
- {
- return NotFound();
- }
-
- return transaction;
- }
-
- [HttpPost]
- public async Task Post(Transaction newTransaction)
- {
- await _transactionsService.CreateAsync(newTransaction);
-
- return CreatedAtAction(nameof(Get), new { id = newTransaction.Id }, newTransaction);
- }
-
- [HttpPut("{id:length(24)}")]
- public async Task Update(string id, Transaction updatedTransaction)
- {
- var transaction = await _transactionsService.GetAsync(id);
-
- if (transaction is null)
- {
- return NotFound();
- }
-
- updatedTransaction.Id = transaction.Id;
-
- await _transactionsService.UpdateAsync(id, updatedTransaction);
-
- return NoContent();
- }
-
- [HttpDelete("{id:length(24)}")]
- public async Task Delete(string id)
- {
- var transaction = await _transactionsService.GetAsync(id);
-
- if (transaction is null)
- {
- return NotFound();
- }
-
- await _transactionsService.RemoveAsync(id);
-
- return NoContent();
- }
-}
\ No newline at end of file
diff --git a/CommBank-Server/Controllers/UserController.cs b/CommBank-Server/Controllers/UserController.cs
deleted file mode 100644
index b4d1e7ce..00000000
--- a/CommBank-Server/Controllers/UserController.cs
+++ /dev/null
@@ -1,72 +0,0 @@
-using Microsoft.AspNetCore.Mvc;
-using CommBank.Services;
-using CommBank.Models;
-
-namespace CommBank.Controllers;
-
-[ApiController]
-[Route("api/[controller]")]
-public class UserController : ControllerBase
-{
- private readonly IUsersService _usersService;
-
- public UserController(IUsersService usersService) =>
- _usersService = usersService;
-
- [HttpGet]
- public async Task> Get() =>
- await _usersService.GetAsync();
-
- [HttpGet("{id:length(24)}")]
- public async Task> Get(string id)
- {
- var user = await _usersService.GetAsync(id);
-
- if (user is null)
- {
- return NotFound();
- }
-
- return user;
- }
-
- [HttpPost]
- public async Task Post(User newUser)
- {
- await _usersService.CreateAsync(newUser);
-
- return CreatedAtAction(nameof(Get), new { id = newUser.Id }, newUser);
- }
-
- [HttpPut("{id:length(24)}")]
- public async Task Update(string id, User updatedUser)
- {
- var user = await _usersService.GetAsync(id);
-
- if (user is null)
- {
- return NotFound();
- }
-
- updatedUser.Id = user.Id;
-
- await _usersService.UpdateAsync(id, updatedUser);
-
- return NoContent();
- }
-
- [HttpDelete("{id:length(24)}")]
- public async Task Delete(string id)
- {
- var user = await _usersService.GetAsync(id);
-
- if (user is null)
- {
- return NotFound();
- }
-
- await _usersService.RemoveAsync(id);
-
- return NoContent();
- }
-}
\ No newline at end of file
diff --git a/CommBank-Server/Models/Account.cs b/CommBank-Server/Models/Account.cs
deleted file mode 100644
index cc62e354..00000000
--- a/CommBank-Server/Models/Account.cs
+++ /dev/null
@@ -1,25 +0,0 @@
-using MongoDB.Bson;
-using System.Text.Json.Serialization;
-using MongoDB.Bson.Serialization.Attributes;
-
-namespace CommBank.Models;
-
-public class Account
-{
- [BsonId]
- [BsonRepresentation(BsonType.ObjectId)]
- public string? Id { get; set; }
-
- public long? Number { get; set; }
-
- public string? Name { get; set; }
-
- public double Balance { get; set; } = 0;
-
- [JsonConverter(typeof(JsonStringEnumConverter))]
- [BsonRepresentation(BsonType.String)]
- public AccountType AccountType { get; set; }
-
- [BsonRepresentation(BsonType.ObjectId)]
- public List? TransactionIds { get; set; }
-}
\ No newline at end of file
diff --git a/CommBank-Server/Models/AccountType.cs b/CommBank-Server/Models/AccountType.cs
deleted file mode 100644
index 869149a3..00000000
--- a/CommBank-Server/Models/AccountType.cs
+++ /dev/null
@@ -1,7 +0,0 @@
-namespace CommBank.Models;
-
-public enum AccountType
-{
- GoalSaver,
- NetBankSaver
-}
\ No newline at end of file
diff --git a/CommBank-Server/Models/ErrorViewModel.cs b/CommBank-Server/Models/ErrorViewModel.cs
deleted file mode 100644
index 40204926..00000000
--- a/CommBank-Server/Models/ErrorViewModel.cs
+++ /dev/null
@@ -1,9 +0,0 @@
-namespace CommBank.Models;
-
-public class ErrorViewModel
-{
- public string? RequestId { get; set; }
-
- public bool ShowRequestId => !string.IsNullOrEmpty(RequestId);
-}
-
diff --git a/CommBank-Server/Models/Goal.cs b/CommBank-Server/Models/Goal.cs
deleted file mode 100644
index 77ff1ad5..00000000
--- a/CommBank-Server/Models/Goal.cs
+++ /dev/null
@@ -1,30 +0,0 @@
-using MongoDB.Bson;
-using MongoDB.Bson.Serialization.Attributes;
-
-namespace CommBank.Models;
-
-public class Goal
-{
- [BsonId]
- [BsonRepresentation(BsonType.ObjectId)]
- public string? Id { get; set; }
-
- public string? Name { get; set; }
-
- public UInt64 TargetAmount { get; set; } = 0;
-
- public DateTime TargetDate { get; set; }
-
- public double Balance { get; set; } = 0.00;
-
- public DateTime Created { get; set; } = DateTime.Now;
-
- [BsonRepresentation(BsonType.ObjectId)]
- public List? TransactionIds { get; set; }
-
- [BsonRepresentation(BsonType.ObjectId)]
- public List? TagIds { get; set; }
-
- [BsonRepresentation(BsonType.ObjectId)]
- public string? UserId { get; set; }
-}
\ No newline at end of file
diff --git a/CommBank-Server/Models/LoginInput.cs b/CommBank-Server/Models/LoginInput.cs
deleted file mode 100644
index deb7336f..00000000
--- a/CommBank-Server/Models/LoginInput.cs
+++ /dev/null
@@ -1,20 +0,0 @@
-namespace CommBank.Models;
-
-interface ILoginInput
-{
- string Email { get; set; }
- string Password { get; set; }
-}
-
-
-public class LoginInput : ILoginInput
-{
- public LoginInput(string email, string password)
- {
- Email = email;
- Password = password;
- }
-
- public string Email { get; set; }
- public string Password { get; set; }
-}
diff --git a/CommBank-Server/Models/ObjectIdConverter.cs b/CommBank-Server/Models/ObjectIdConverter.cs
deleted file mode 100644
index ef17bbb0..00000000
--- a/CommBank-Server/Models/ObjectIdConverter.cs
+++ /dev/null
@@ -1,26 +0,0 @@
-using MongoDB.Bson;
-using Newtonsoft.Json;
-
-class ObjectIdConverter : JsonConverter
-{
-
- public override void WriteJson(JsonWriter writer, object? value, JsonSerializer serializer)
- {
- if (value is not null)
- {
- serializer.Serialize(writer, value.ToString());
- }
- }
-
- public override object ReadJson(JsonReader reader, Type objectType, object? existingValue, JsonSerializer serializer)
- {
- throw new NotImplementedException();
- }
-
- public override bool CanConvert(Type objectType)
- {
- return typeof(ObjectId).IsAssignableFrom(objectType);
- }
-
-
-}
\ No newline at end of file
diff --git a/CommBank-Server/Models/Tag.cs b/CommBank-Server/Models/Tag.cs
deleted file mode 100644
index 0fda50b8..00000000
--- a/CommBank-Server/Models/Tag.cs
+++ /dev/null
@@ -1,13 +0,0 @@
-using MongoDB.Bson;
-using MongoDB.Bson.Serialization.Attributes;
-
-namespace CommBank.Models;
-
-public class Tag
-{
- [BsonId]
- [BsonRepresentation(BsonType.ObjectId)]
- public string? Id { get; set; }
-
- public string? Name { get; set; }
-}
\ No newline at end of file
diff --git a/CommBank-Server/Models/Transaction.cs b/CommBank-Server/Models/Transaction.cs
deleted file mode 100644
index cd7c521b..00000000
--- a/CommBank-Server/Models/Transaction.cs
+++ /dev/null
@@ -1,31 +0,0 @@
-using MongoDB.Bson;
-using System.Text.Json.Serialization;
-using MongoDB.Bson.Serialization.Attributes;
-
-namespace CommBank.Models;
-
-public class Transaction
-{
- [BsonId]
- [BsonRepresentation(BsonType.ObjectId)]
- public string? Id { get; set; }
-
- [JsonConverter(typeof(JsonStringEnumConverter))]
- [BsonRepresentation(BsonType.String)]
- public TransactionType TransactionType { get; set; }
-
- public double Amount { get; set; } = 0.00;
-
- public DateTime DateTime { get; set; } = DateTime.Now;
-
- [BsonRepresentation(BsonType.ObjectId)]
- public string? GoalId { get; set; }
-
- [BsonRepresentation(BsonType.ObjectId)]
- public string? UserId { get; set; }
-
- [BsonRepresentation(BsonType.ObjectId)]
- public string[]? TagIds { get; set; }
-
- public string? Description { get; set; }
-}
\ No newline at end of file
diff --git a/CommBank-Server/Models/TransactionType.cs b/CommBank-Server/Models/TransactionType.cs
deleted file mode 100644
index 8c5d1158..00000000
--- a/CommBank-Server/Models/TransactionType.cs
+++ /dev/null
@@ -1,9 +0,0 @@
-namespace CommBank.Models;
-
-public enum TransactionType
-{
- Credit,
- Debit,
- Transfer
-}
-
diff --git a/CommBank-Server/Models/UpdatedIcon.cs b/CommBank-Server/Models/UpdatedIcon.cs
deleted file mode 100644
index 9b3602f2..00000000
--- a/CommBank-Server/Models/UpdatedIcon.cs
+++ /dev/null
@@ -1,17 +0,0 @@
-namespace CommBank.Models;
-
-interface IUpdatedIcon
-{
- string Icon { get; set; }
-}
-
-
-public class UpdatedIcon : IUpdatedIcon
-{
- public UpdatedIcon(string icon)
- {
- Icon = icon;
- }
-
- public string Icon { get; set; }
-}
diff --git a/CommBank-Server/Models/User.cs b/CommBank-Server/Models/User.cs
deleted file mode 100644
index 3fad72bf..00000000
--- a/CommBank-Server/Models/User.cs
+++ /dev/null
@@ -1,26 +0,0 @@
-using MongoDB.Bson;
-using MongoDB.Bson.Serialization.Attributes;
-
-namespace CommBank.Models;
-
-public class User
-{
- [BsonId]
- [BsonRepresentation(BsonType.ObjectId)]
- public string? Id { get; set; }
-
- public string? Name { get; set; }
-
- public string? Email { get; set; }
-
- public string? Password { get; set; }
-
- [BsonRepresentation(BsonType.ObjectId)]
- public List? AccountIds { get; set; }
-
- [BsonRepresentation(BsonType.ObjectId)]
- public List? GoalIds { get; set; }
-
- [BsonRepresentation(BsonType.ObjectId)]
- public List? TransactionIds { get; set; }
-}
\ No newline at end of file
diff --git a/CommBank-Server/Program.cs b/CommBank-Server/Program.cs
deleted file mode 100644
index a88e560d..00000000
--- a/CommBank-Server/Program.cs
+++ /dev/null
@@ -1,53 +0,0 @@
-using CommBank.Models;
-using CommBank.Services;
-using MongoDB.Driver;
-
-var builder = WebApplication.CreateBuilder(args);
-
-builder.Services.AddControllers();
-
-builder.Services.AddEndpointsApiExplorer();
-builder.Services.AddSwaggerGen();
-
-builder.Configuration.SetBasePath(Directory.GetCurrentDirectory()).AddJsonFile("Secrets.json");
-
-var mongoClient = new MongoClient(builder.Configuration.GetConnectionString("CommBank"));
-var mongoDatabase = mongoClient.GetDatabase("CommBank");
-
-IAccountsService accountsService = new AccountsService(mongoDatabase);
-IAuthService authService = new AuthService(mongoDatabase);
-IGoalsService goalsService = new GoalsService(mongoDatabase);
-ITagsService tagsService = new TagsService(mongoDatabase);
-ITransactionsService transactionsService = new TransactionsService(mongoDatabase);
-IUsersService usersService = new UsersService(mongoDatabase);
-
-builder.Services.AddSingleton(accountsService);
-builder.Services.AddSingleton(authService);
-builder.Services.AddSingleton(goalsService);
-builder.Services.AddSingleton(tagsService);
-builder.Services.AddSingleton(transactionsService);
-builder.Services.AddSingleton(usersService);
-
-builder.Services.AddCors();
-
-var app = builder.Build();
-
-app.UseCors(builder => builder
- .AllowAnyOrigin()
- .AllowAnyMethod()
- .AllowAnyHeader());
-
-if (app.Environment.IsDevelopment())
-{
- app.UseSwagger();
- app.UseSwaggerUI();
-}
-
-app.UseHttpsRedirection();
-
-app.UseAuthorization();
-
-app.MapControllers();
-
-app.Run();
-
diff --git a/CommBank-Server/Properties/launchSettings.json b/CommBank-Server/Properties/launchSettings.json
deleted file mode 100644
index 2c9f444c..00000000
--- a/CommBank-Server/Properties/launchSettings.json
+++ /dev/null
@@ -1,30 +0,0 @@
-{
- "$schema": "https://json.schemastore.org/launchsettings.json",
- "iisSettings": {
- "windowsAuthentication": false,
- "anonymousAuthentication": true,
- "iisExpress": {
- "applicationUrl": "http://localhost:21087",
- "sslPort": 44320
- }
- },
- "profiles": {
- "CommBank_Server": {
- "commandName": "Project",
- "launchBrowser": true,
- "launchUrl": "swagger",
- "applicationUrl": "http://localhost:11366;http://localhost:5203",
- "environmentVariables": {
- "ASPNETCORE_ENVIRONMENT": "Development"
- }
- },
- "IIS Express": {
- "commandName": "IISExpress",
- "launchBrowser": true,
- "launchUrl": "swagger",
- "environmentVariables": {
- "ASPNETCORE_ENVIRONMENT": "Development"
- }
- }
- }
-}
\ No newline at end of file
diff --git a/CommBank-Server/Secrets.json b/CommBank-Server/Secrets.json
deleted file mode 100644
index 0e5bf949..00000000
--- a/CommBank-Server/Secrets.json
+++ /dev/null
@@ -1,5 +0,0 @@
-{
- "ConnectionStrings": {
- "CommBank": "{CONNECTION_STRING}"
- }
-}
\ No newline at end of file
diff --git a/CommBank-Server/Services/AccountService.cs b/CommBank-Server/Services/AccountService.cs
deleted file mode 100644
index 52d1cb9b..00000000
--- a/CommBank-Server/Services/AccountService.cs
+++ /dev/null
@@ -1,30 +0,0 @@
-using Microsoft.Extensions.Options;
-using CommBank.Models;
-using MongoDB.Driver;
-
-namespace CommBank.Services;
-
-public class AccountsService : IAccountsService
-{
- private readonly IMongoCollection _accountsCollection;
-
- public AccountsService(IMongoDatabase mongoDatabase)
- {
- _accountsCollection = mongoDatabase.GetCollection("Accounts");
- }
-
- public async Task> GetAsync() =>
- await _accountsCollection.Find(_ => true).ToListAsync();
-
- public async Task GetAsync(string id) =>
- await _accountsCollection.Find(x => x.Id == id).FirstOrDefaultAsync();
-
- public async Task CreateAsync(Account newAccount) =>
- await _accountsCollection.InsertOneAsync(newAccount);
-
- public async Task UpdateAsync(string id, Account updatedAccount) =>
- await _accountsCollection.ReplaceOneAsync(x => x.Id == id, updatedAccount);
-
- public async Task RemoveAsync(string id) =>
- await _accountsCollection.DeleteOneAsync(x => x.Id == id);
-}
\ No newline at end of file
diff --git a/CommBank-Server/Services/AuthService.cs b/CommBank-Server/Services/AuthService.cs
deleted file mode 100644
index c37de8ea..00000000
--- a/CommBank-Server/Services/AuthService.cs
+++ /dev/null
@@ -1,34 +0,0 @@
-using Microsoft.Extensions.Options;
-using CommBank.Models;
-using MongoDB.Driver;
-
-namespace CommBank.Services;
-
-public class AuthService : IAuthService
-{
- private readonly IMongoCollection _usersCollection;
-
- public AuthService(IMongoDatabase mongoDatabase)
- {
- _usersCollection = mongoDatabase.GetCollection("Users");
- }
-
- public async Task Login(string email, string password)
- {
- var user = await _usersCollection
- .Find(x => x.Email == email)
- .FirstOrDefaultAsync();
-
- if (user is not null)
- {
- var isCorrectPassword = BCrypt.Net.BCrypt.Verify(password, user.Password);
-
- if (isCorrectPassword)
- {
- return user;
- }
- }
-
- return null;
- }
-}
\ No newline at end of file
diff --git a/CommBank-Server/Services/GoalService.cs b/CommBank-Server/Services/GoalService.cs
deleted file mode 100644
index b0c600a1..00000000
--- a/CommBank-Server/Services/GoalService.cs
+++ /dev/null
@@ -1,32 +0,0 @@
-using CommBank.Models;
-using MongoDB.Driver;
-
-namespace CommBank.Services;
-
-public class GoalsService : IGoalsService
-{
- private readonly IMongoCollection _goalsCollection;
-
- public GoalsService(IMongoDatabase mongoDatabase)
- {
- _goalsCollection = mongoDatabase.GetCollection("Goals");
- }
-
- public async Task> GetAsync() =>
- await _goalsCollection.Find(_ => true).ToListAsync();
-
- public async Task?> GetForUserAsync(string id) =>
- await _goalsCollection.Find(x => x.UserId == id).ToListAsync();
-
- public async Task GetAsync(string id) =>
- await _goalsCollection.Find(x => x.Id == id).FirstOrDefaultAsync();
-
- public async Task CreateAsync(Goal newGoal) =>
- await _goalsCollection.InsertOneAsync(newGoal);
-
- public async Task UpdateAsync(string id, Goal updatedGoal) =>
- await _goalsCollection.ReplaceOneAsync(x => x.Id == id, updatedGoal);
-
- public async Task RemoveAsync(string id) =>
- await _goalsCollection.DeleteOneAsync(x => x.Id == id);
-}
\ No newline at end of file
diff --git a/CommBank-Server/Services/IAccountService.cs b/CommBank-Server/Services/IAccountService.cs
deleted file mode 100644
index 00ee1b7b..00000000
--- a/CommBank-Server/Services/IAccountService.cs
+++ /dev/null
@@ -1,13 +0,0 @@
-using CommBank.Models;
-
-namespace CommBank.Services
-{
- public interface IAccountsService
- {
- Task CreateAsync(Account newAccount);
- Task> GetAsync();
- Task GetAsync(string id);
- Task RemoveAsync(string id);
- Task UpdateAsync(string id, Account updatedAccount);
- }
-}
\ No newline at end of file
diff --git a/CommBank-Server/Services/IAuthService.cs b/CommBank-Server/Services/IAuthService.cs
deleted file mode 100644
index a16ddea6..00000000
--- a/CommBank-Server/Services/IAuthService.cs
+++ /dev/null
@@ -1,9 +0,0 @@
-using CommBank.Models;
-
-namespace CommBank.Services
-{
- public interface IAuthService
- {
- Task Login(string email, string password);
- }
-}
\ No newline at end of file
diff --git a/CommBank-Server/Services/IGoalsService.cs b/CommBank-Server/Services/IGoalsService.cs
deleted file mode 100644
index 50ee8e0b..00000000
--- a/CommBank-Server/Services/IGoalsService.cs
+++ /dev/null
@@ -1,14 +0,0 @@
-using CommBank.Models;
-
-namespace CommBank.Services
-{
- public interface IGoalsService
- {
- Task CreateAsync(Goal newGoal);
- Task> GetAsync();
- Task?> GetForUserAsync(string id);
- Task GetAsync(string id);
- Task RemoveAsync(string id);
- Task UpdateAsync(string id, Goal updatedGoal);
- }
-}
\ No newline at end of file
diff --git a/CommBank-Server/Services/ITagsService.cs b/CommBank-Server/Services/ITagsService.cs
deleted file mode 100644
index b021144f..00000000
--- a/CommBank-Server/Services/ITagsService.cs
+++ /dev/null
@@ -1,13 +0,0 @@
-using CommBank.Models;
-
-namespace CommBank.Services
-{
- public interface ITagsService
- {
- Task CreateAsync(Tag newTag);
- Task> GetAsync();
- Task GetAsync(string id);
- Task RemoveAsync(string id);
- Task UpdateAsync(string id, Tag updatedTag);
- }
-}
\ No newline at end of file
diff --git a/CommBank-Server/Services/ITransactionsService.cs b/CommBank-Server/Services/ITransactionsService.cs
deleted file mode 100644
index b68aa6c0..00000000
--- a/CommBank-Server/Services/ITransactionsService.cs
+++ /dev/null
@@ -1,14 +0,0 @@
-using CommBank.Models;
-
-namespace CommBank.Services
-{
- public interface ITransactionsService
- {
- Task CreateAsync(Transaction newTransaction);
- Task> GetAsync();
- Task?> GetForUserAsync(string id);
- Task GetAsync(string id);
- Task RemoveAsync(string id);
- Task UpdateAsync(string id, Transaction updatedTransaction);
- }
-}
\ No newline at end of file
diff --git a/CommBank-Server/Services/IUsersService.cs b/CommBank-Server/Services/IUsersService.cs
deleted file mode 100644
index d3b4a179..00000000
--- a/CommBank-Server/Services/IUsersService.cs
+++ /dev/null
@@ -1,13 +0,0 @@
-using CommBank.Models;
-
-namespace CommBank.Services
-{
- public interface IUsersService
- {
- Task CreateAsync(User newUser);
- Task> GetAsync();
- Task GetAsync(string id);
- Task RemoveAsync(string id);
- Task UpdateAsync(string id, User updatedUser);
- }
-}
\ No newline at end of file
diff --git a/CommBank-Server/Services/TagsService.cs b/CommBank-Server/Services/TagsService.cs
deleted file mode 100644
index daf8e589..00000000
--- a/CommBank-Server/Services/TagsService.cs
+++ /dev/null
@@ -1,30 +0,0 @@
-using Microsoft.Extensions.Options;
-using CommBank.Models;
-using MongoDB.Driver;
-
-namespace CommBank.Services;
-
-public class TagsService : ITagsService
-{
- private readonly IMongoCollection _tagsCollection;
-
- public TagsService(IMongoDatabase mongoDatabase)
- {
- _tagsCollection = mongoDatabase.GetCollection("Tags");
- }
-
- public async Task> GetAsync() =>
- await _tagsCollection.Find(_ => true).ToListAsync();
-
- public async Task GetAsync(string id) =>
- await _tagsCollection.Find(x => x.Id == id).FirstOrDefaultAsync();
-
- public async Task CreateAsync(Models.Tag newTag) =>
- await _tagsCollection.InsertOneAsync(newTag);
-
- public async Task UpdateAsync(string id, Models.Tag updatedTag) =>
- await _tagsCollection.ReplaceOneAsync(x => x.Id == id, updatedTag);
-
- public async Task RemoveAsync(string id) =>
- await _tagsCollection.DeleteOneAsync(x => x.Id == id);
-}
\ No newline at end of file
diff --git a/CommBank-Server/Services/TransactionsService.cs b/CommBank-Server/Services/TransactionsService.cs
deleted file mode 100644
index 77718468..00000000
--- a/CommBank-Server/Services/TransactionsService.cs
+++ /dev/null
@@ -1,33 +0,0 @@
-using Microsoft.Extensions.Options;
-using CommBank.Models;
-using MongoDB.Driver;
-
-namespace CommBank.Services;
-
-public class TransactionsService : ITransactionsService
-{
- private readonly IMongoCollection _transactionsCollection;
-
- public TransactionsService(IMongoDatabase mongoDatabase)
- {
- _transactionsCollection = mongoDatabase.GetCollection("Transactions");
- }
-
- public async Task> GetAsync() =>
- await _transactionsCollection.Find(_ => true).ToListAsync();
-
- public async Task?> GetForUserAsync(string id) =>
- await _transactionsCollection.Find(x => x.UserId == id).ToListAsync();
-
- public async Task GetAsync(string id) =>
- await _transactionsCollection.Find(x => x.Id == id).FirstOrDefaultAsync();
-
- public async Task CreateAsync(Transaction newTransaction) =>
- await _transactionsCollection.InsertOneAsync(newTransaction);
-
- public async Task UpdateAsync(string id, Transaction updatedTransaction) =>
- await _transactionsCollection.ReplaceOneAsync(x => x.Id == id, updatedTransaction);
-
- public async Task RemoveAsync(string id) =>
- await _transactionsCollection.DeleteOneAsync(x => x.Id == id);
-}
\ No newline at end of file
diff --git a/CommBank-Server/Services/UsersService.cs b/CommBank-Server/Services/UsersService.cs
deleted file mode 100644
index 4c4c32f0..00000000
--- a/CommBank-Server/Services/UsersService.cs
+++ /dev/null
@@ -1,34 +0,0 @@
-using Microsoft.Extensions.Options;
-using CommBank.Models;
-using MongoDB.Driver;
-
-namespace CommBank.Services;
-
-public class UsersService : IUsersService
-{
- private readonly IMongoCollection _usersCollection;
-
- public UsersService(IMongoDatabase mongoDatabase)
- {
- _usersCollection = mongoDatabase.GetCollection("Users");
- }
-
- public async Task> GetAsync() =>
- await _usersCollection.Find(_ => true).ToListAsync();
-
- public async Task GetAsync(string id) =>
- await _usersCollection.Find(x => x.Id == id).FirstOrDefaultAsync();
-
- public async Task CreateAsync(User newUser)
- {
- newUser.Password = BCrypt.Net.BCrypt.HashPassword(newUser.Password);
-
- await _usersCollection.InsertOneAsync(newUser);
- }
-
- public async Task UpdateAsync(string id, User updatedUser) =>
- await _usersCollection.ReplaceOneAsync(x => x.Id == id, updatedUser);
-
- public async Task RemoveAsync(string id) =>
- await _usersCollection.DeleteOneAsync(x => x.Id == id);
-}
\ No newline at end of file
diff --git a/CommBank-Server/appsettings.Development.json b/CommBank-Server/appsettings.Development.json
deleted file mode 100644
index ce16a2e3..00000000
--- a/CommBank-Server/appsettings.Development.json
+++ /dev/null
@@ -1,9 +0,0 @@
-{
- "Logging": {
- "LogLevel": {
- "Default": "Information",
- "Microsoft.AspNetCore": "Warning"
- }
- }
-}
-
diff --git a/CommBank-Server/appsettings.json b/CommBank-Server/appsettings.json
deleted file mode 100644
index af0538f7..00000000
--- a/CommBank-Server/appsettings.json
+++ /dev/null
@@ -1,10 +0,0 @@
-{
- "Logging": {
- "LogLevel": {
- "Default": "Information",
- "Microsoft.AspNetCore": "Warning"
- }
- },
- "AllowedHosts": "*"
-}
-
diff --git a/CommBank.Tests/GoalControllerTests.cs b/CommBank.Tests/GoalControllerTests.cs
index 8380181f..c6a4373c 100644
--- a/CommBank.Tests/GoalControllerTests.cs
+++ b/CommBank.Tests/GoalControllerTests.cs
@@ -66,9 +66,27 @@ public async void Get()
public async void GetForUser()
{
// Arrange
-
+ var goals = collections.GetGoals();
+ var users = collections.GetUsers();
+
+ IGoalsService goalsService = new FakeGoalsService(goals, goals[0]);
+ IUsersService usersService = new FakeUsersService(users, users[0]);
+
+ GoalController controller = new(goalsService, usersService);
+
// Act
-
+ var httpContext = new Microsoft.AspNetCore.Http.DefaultHttpContext();
+ controller.ControllerContext.HttpContext = httpContext;
+
+ var result = await controller.GetForUser(goals[0].UserId!);
+
// Assert
+ Assert.NotNull(result);
+
+ foreach (Goal goal in result!)
+ {
+ Assert.IsAssignableFrom(goal);
+ Assert.Equal(goals[0].UserId, goal.UserId);
+ }
}
}
\ No newline at end of file