Skip to content

Commit

Permalink
feat: added get hobbyist by artist id endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
Miguel445Ar committed Nov 23, 2023
1 parent ecc108b commit 8d4989e
Show file tree
Hide file tree
Showing 7 changed files with 216 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using AutoMapper;
using MediatR;
Expand Down Expand Up @@ -40,6 +42,15 @@ public async Task<IActionResult> RegisterNewProfileHobbyist([FromBody] RegisterH
HobbyistResource hobbyistResource = await _profileCommandService.ExecuteRegisterProfileCommand(registerProfileHobbyistCommand);
return Ok(hobbyistResource);
}
[HttpGet("user/{userId}")]
public async Task<IActionResult> GetHobbyistByArtistId(long userId)
{
List<Hobbyist> hobbyists = await _context.Hobbyists.Where(h => h.UserId == userId).ToListAsync();
if(hobbyists.Count != 1) return NotFound(new { message = "Hobbyist not found" });
HobbyistResource hobbyistResource = _mapper.Map<Hobbyist, HobbyistResource>(hobbyists.First());
return Ok(hobbyistResource);
}

[HttpGet("{hobbyistId}")]
public async Task<IActionResult> GetHobbyist(long hobbyistId)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,173 @@
{
"$schema": "https://schema.management.azure.com/schemas/2018-05-01/subscriptionDeploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"metadata": {
"_dependencyType": "compute.function.linux.appService"
},
"parameters": {
"resourceGroupName": {
"type": "string",
"defaultValue": "peru-stars",
"metadata": {
"description": "Name of the resource group for the resource. It is recommended to put resources under same resource group for better tracking."
}
},
"resourceGroupLocation": {
"type": "string",
"defaultValue": "eastus2",
"metadata": {
"description": "Location of the resource group. Resource groups could have different location than resources, however by default we use API versions from latest hybrid profile which support all locations for resource types we support."
}
},
"resourceName": {
"type": "string",
"defaultValue": "PerustarsDDDAPI",
"metadata": {
"description": "Name of the main resource to be created by this template."
}
},
"resourceLocation": {
"type": "string",
"defaultValue": "[parameters('resourceGroupLocation')]",
"metadata": {
"description": "Location of the resource. By default use resource group's location, unless the resource provider is not supported there."
}
}
},
"resources": [
{
"type": "Microsoft.Resources/resourceGroups",
"name": "[parameters('resourceGroupName')]",
"location": "[parameters('resourceGroupLocation')]",
"apiVersion": "2019-10-01"
},
{
"type": "Microsoft.Resources/deployments",
"name": "[concat(parameters('resourceGroupName'), 'Deployment', uniqueString(concat(parameters('resourceName'), subscription().subscriptionId)))]",
"resourceGroup": "[parameters('resourceGroupName')]",
"apiVersion": "2019-10-01",
"dependsOn": [
"[parameters('resourceGroupName')]"
],
"properties": {
"mode": "Incremental",
"expressionEvaluationOptions": {
"scope": "inner"
},
"parameters": {
"resourceGroupName": {
"value": "[parameters('resourceGroupName')]"
},
"resourceGroupLocation": {
"value": "[parameters('resourceGroupLocation')]"
},
"resourceName": {
"value": "[parameters('resourceName')]"
},
"resourceLocation": {
"value": "[parameters('resourceLocation')]"
}
},
"template": {
"$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"resourceGroupName": {
"type": "string"
},
"resourceGroupLocation": {
"type": "string"
},
"resourceName": {
"type": "string"
},
"resourceLocation": {
"type": "string"
}
},
"variables": {
"storage_name": "[toLower(concat('storage', uniqueString(concat(parameters('resourceName'), subscription().subscriptionId))))]",
"appServicePlan_name": "[concat('Plan', uniqueString(concat(parameters('resourceName'), subscription().subscriptionId)))]",
"storage_ResourceId": "[concat('/subscriptions/', subscription().subscriptionId, '/resourceGroups/', parameters('resourceGroupName'), '/providers/Microsoft.Storage/storageAccounts/', variables('storage_name'))]",
"appServicePlan_ResourceId": "[concat('/subscriptions/', subscription().subscriptionId, '/resourceGroups/', parameters('resourceGroupName'), '/providers/Microsoft.Web/serverFarms/', variables('appServicePlan_name'))]",
"function_ResourceId": "[concat('/subscriptions/', subscription().subscriptionId, '/resourceGroups/', parameters('resourceGroupName'), '/providers/Microsoft.Web/sites/', parameters('resourceName'))]"
},
"resources": [
{
"location": "[parameters('resourceLocation')]",
"name": "[parameters('resourceName')]",
"type": "Microsoft.Web/sites",
"apiVersion": "2015-08-01",
"tags": {
"[concat('hidden-related:', variables('appServicePlan_ResourceId'))]": "empty"
},
"dependsOn": [
"[variables('appServicePlan_ResourceId')]",
"[variables('storage_ResourceId')]"
],
"kind": "functionapp",
"properties": {
"name": "[parameters('resourceName')]",
"kind": "functionapp",
"httpsOnly": true,
"reserved": false,
"serverFarmId": "[variables('appServicePlan_ResourceId')]",
"siteConfig": {
"alwaysOn": true,
"linuxFxVersion": "dotnet|3.1"
}
},
"identity": {
"type": "SystemAssigned"
},
"resources": [
{
"name": "appsettings",
"type": "config",
"apiVersion": "2015-08-01",
"dependsOn": [
"[variables('function_ResourceId')]"
],
"properties": {
"AzureWebJobsStorage": "[concat('DefaultEndpointsProtocol=https;AccountName=', variables('storage_name'), ';AccountKey=', listKeys(variables('storage_ResourceId'), '2017-10-01').keys[0].value, ';EndpointSuffix=', 'core.windows.net')]",
"FUNCTIONS_EXTENSION_VERSION": "~3",
"FUNCTIONS_WORKER_RUNTIME": "dotnet"
}
}
]
},
{
"location": "[parameters('resourceGroupLocation')]",
"name": "[variables('storage_name')]",
"type": "Microsoft.Storage/storageAccounts",
"apiVersion": "2017-10-01",
"tags": {
"[concat('hidden-related:', concat('/providers/Microsoft.Web/sites/', parameters('resourceName')))]": "empty"
},
"properties": {
"supportsHttpsTrafficOnly": true
},
"sku": {
"name": "Standard_LRS"
},
"kind": "Storage"
},
{
"location": "[parameters('resourceGroupLocation')]",
"name": "[variables('appServicePlan_name')]",
"type": "Microsoft.Web/serverFarms",
"apiVersion": "2015-02-01",
"kind": "linux",
"properties": {
"name": "[variables('appServicePlan_name')]",
"sku": "Standard",
"workerSizeId": "0",
"reserved": true
}
}
]
}
}
}
]
}
5 changes: 4 additions & 1 deletion PERUSTARS/PERUSTARS/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,16 @@
},
"ConnectionStrings": {


//"DefaultConnection1ssssss": "server=localhost;port=3306;database=perustars;uid=root;password=admin",
"DefaultConnection": "server=perustars-main-db.mysql.database.azure.com;port=3306;database=perustars;uid=perustarsAdmin;password=Admin123"
//"DefaultConnection3": "Server=MYSQL5047.site4now.net;Database=db_a758df_perusta;Uid=a758df_perusta;Pwd=password1",
//"DefaultConnection": "Server=bufyroukqdunhwcivvpo-mysql.services.clever-cloud.com;Database=bufyroukqdunhwcivvpo;Uid=ubcldvvxbrtlhp2d;Pwd=FltJthiJHLXaKDmKT11O"
//"PostgresSQLConnection": "host=localhost;port=5432;username=postgres;password=12345;database=perustars"
//"DefaultConnection": "host=localhost;port=3306;username=root;password=password;database=perustars"
//"DefaultConnection1": "server=localhost;port=3306;database=perustars;uid=root;password=admin",
//"DefaultConnection": "server=perustars-db.mysql.database.azure.com;port=3306;database=perustars;uid=perustarsAdmin;password=Miguel445"
//"DefaultConnection3": "Server=MYSQL5047.site4now.net;Database=db_a758df_perusta;Uid=a758df_perusta;Pwd=password1",
//"PostgreSQLConnection": "host=localhost;port=5432;username=postgres;password=12345;database=perustars"
// "DefaultConnection": "server=localhost;port=3306;database=perustars;uid=root;password=root"
},
"AllowedHosts": "*"
Expand Down
Binary file modified PERUSTARS/PERUSTARS/bin/Debug/net5.0/PERUSTARS.dll
Binary file not shown.
Binary file modified PERUSTARS/PERUSTARS/bin/Debug/net5.0/PERUSTARS.pdb
Binary file not shown.
5 changes: 4 additions & 1 deletion PERUSTARS/PERUSTARS/bin/Debug/net5.0/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,16 @@
},
"ConnectionStrings": {


//"DefaultConnection1ssssss": "server=localhost;port=3306;database=perustars;uid=root;password=admin",
"DefaultConnection": "server=perustars-main-db.mysql.database.azure.com;port=3306;database=perustars;uid=perustarsAdmin;password=Admin123"
//"DefaultConnection3": "Server=MYSQL5047.site4now.net;Database=db_a758df_perusta;Uid=a758df_perusta;Pwd=password1",
//"DefaultConnection": "Server=bufyroukqdunhwcivvpo-mysql.services.clever-cloud.com;Database=bufyroukqdunhwcivvpo;Uid=ubcldvvxbrtlhp2d;Pwd=FltJthiJHLXaKDmKT11O"
//"PostgresSQLConnection": "host=localhost;port=5432;username=postgres;password=12345;database=perustars"
//"DefaultConnection": "host=localhost;port=3306;username=root;password=password;database=perustars"
//"DefaultConnection1": "server=localhost;port=3306;database=perustars;uid=root;password=admin",
//"DefaultConnection": "server=perustars-db.mysql.database.azure.com;port=3306;database=perustars;uid=perustarsAdmin;password=Miguel445"
//"DefaultConnection3": "Server=MYSQL5047.site4now.net;Database=db_a758df_perusta;Uid=a758df_perusta;Pwd=password1",
//"PostgreSQLConnection": "host=localhost;port=5432;username=postgres;password=12345;database=perustars"
// "DefaultConnection": "server=localhost;port=3306;database=perustars;uid=root;password=root"
},
"AllowedHosts": "*"
Expand Down
24 changes: 24 additions & 0 deletions PERUSTARS/PERUSTARS/bin/Release/net5.0/appsettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"AppSettings": {
"Secret": "BackendService Secret for PeruStars :D"
},
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
},
"ConnectionStrings": {


//"DefaultConnection1ssssss": "server=localhost;port=3306;database=perustars;uid=root;password=admin",
"DefaultConnection": "server=perustars-main-db.mysql.database.azure.com;port=3306;database=perustars;uid=perustarsAdmin;password=Admin123"
//"DefaultConnection3": "Server=MYSQL5047.site4now.net;Database=db_a758df_perusta;Uid=a758df_perusta;Pwd=password1",
//"DefaultConnection": "Server=bufyroukqdunhwcivvpo-mysql.services.clever-cloud.com;Database=bufyroukqdunhwcivvpo;Uid=ubcldvvxbrtlhp2d;Pwd=FltJthiJHLXaKDmKT11O"
//"PostgresSQLConnection": "host=localhost;port=5432;username=postgres;password=12345;database=perustars"
//"DefaultConnection": "host=localhost;port=3306;username=root;password=password;database=perustars"
// "DefaultConnection": "server=localhost;port=3306;database=perustars;uid=root;password=root"
},
"AllowedHosts": "*"
}

0 comments on commit 8d4989e

Please sign in to comment.