diff --git a/CommBank-Server/CommBank.csproj b/CommBank-Server/CommBank.csproj index 983cc882..91fbe466 100644 --- a/CommBank-Server/CommBank.csproj +++ b/CommBank-Server/CommBank.csproj @@ -9,27 +9,18 @@ + - + - - - - - - - - - - - - + + \ No newline at end of file diff --git a/CommBank-Server/Models/Goal.cs b/CommBank-Server/Models/Goal.cs index 77ff1ad5..f8fb3801 100644 --- a/CommBank-Server/Models/Goal.cs +++ b/CommBank-Server/Models/Goal.cs @@ -27,4 +27,7 @@ public class Goal [BsonRepresentation(BsonType.ObjectId)] public string? UserId { get; set; } + + // New optional icon field + public string? Icon { get; set; } } \ No newline at end of file diff --git a/CommBank-Server/Program.cs b/CommBank-Server/Program.cs index a88e560d..78110c84 100644 --- a/CommBank-Server/Program.cs +++ b/CommBank-Server/Program.cs @@ -1,53 +1,25 @@ -using CommBank.Models; -using CommBank.Services; -using MongoDB.Driver; +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()) +try { - app.UseSwagger(); - app.UseSwaggerUI(); -} + var connectionString = + "mongodb+srv://shaikshah:Test123456@cluster0.8uzhwc1.mongodb.net/?appName=Cluster0"; -app.UseHttpsRedirection(); + var settings = MongoClientSettings.FromConnectionString(connectionString); + settings.ServerApi = new ServerApi(ServerApiVersion.V1); -app.UseAuthorization(); + var client = new MongoClient(settings); -app.MapControllers(); + var dbs = client.ListDatabaseNames().ToList(); -app.Run(); + Console.WriteLine("SUCCESS!"); + foreach (var db in dbs) + { + Console.WriteLine(db); + } +} +catch (Exception ex) +{ + Console.WriteLine(ex); +} \ No newline at end of file diff --git a/CommBank-Server/Properties/launchSettings.json b/CommBank-Server/Properties/launchSettings.json index 2c9f444c..9c7cef6a 100644 --- a/CommBank-Server/Properties/launchSettings.json +++ b/CommBank-Server/Properties/launchSettings.json @@ -13,7 +13,7 @@ "commandName": "Project", "launchBrowser": true, "launchUrl": "swagger", - "applicationUrl": "http://localhost:11366;http://localhost:5203", + "applicationUrl": "http://localhost:5203", "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development" } @@ -27,4 +27,5 @@ } } } -} \ No newline at end of file +} + diff --git a/CommBank-Server/Secrets.json b/CommBank-Server/Secrets.json index 0e5bf949..f775811c 100644 --- a/CommBank-Server/Secrets.json +++ b/CommBank-Server/Secrets.json @@ -1,5 +1,5 @@ { "ConnectionStrings": { - "CommBank": "{CONNECTION_STRING}" + "CommBank": "mongodb+srv://shaikshah:Test123456@cluster0.8uzhwc1.mongodb.net/?appName=Cluster0" } } \ No newline at end of file