Préparation des projet + Interface Service

projectInit
Kevin MONDEJAR 3 months ago
parent fcbdf8df79
commit 4d2047b03a

@ -0,0 +1,30 @@
**/.classpath
**/.dockerignore
**/.env
**/.git
**/.gitignore
**/.project
**/.settings
**/.toolstarget
**/.vs
**/.vscode
**/*.*proj.user
**/*.dbmdl
**/*.jfm
**/azds.yaml
**/bin
**/charts
**/docker-compose*
**/Dockerfile*
**/node_modules
**/npm-debug.log
**/obj
**/secrets.dev.yaml
**/values.dev.yaml
LICENSE
README.md
!**/.gitignore
!.git/HEAD
!.git/config
!.git/packed-refs
!.git/refs/heads/**

@ -0,0 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
</Project>

@ -0,0 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
</Project>

@ -0,0 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
</Project>

@ -0,0 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
</Project>

@ -0,0 +1,7 @@
namespace Model2entities
{
public class Class1
{
}
}

@ -0,0 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
</Project>

@ -0,0 +1,39 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Shared
{
public interface ICharacterService<TChar>
{
// Retrieves a character by its unique identifier (id).
// 'id' is the unique identifier of the character.
Task<TChar> GetCharById(int id);
// Retrieves a character by its name.
// 'name' is the name of the character to be retrieved.
Task<TChar> GetCharByName(string name);
// Retrieves all characters, with pagination support.
// This returns a list of all characters in the system.
Task<PaginationResult<TChar>> GetAll();
// Adds a new character to the system.
// 'character' is the character object that will be added to the system.
Task AddCharacter(TChar character);
// Updates an existing character identified by its unique identifier ('id').
// 'id' is the unique identifier of the character to be updated
// 'character' contains the updated character data.
Task UpdateCharacter(int id, TChar character);
// Removes a character from the system based on its unique identifier ('id').
// 'id' is the unique identifier of the character to be removed.
Task RemoveCharacter(int id);
// Retrieves the unique identifier of the last added character.
Task<int> GetLastCharId();
}
}

@ -0,0 +1,54 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Shared
{
public interface ICommentService<TComment>
{
// Retrieves a comment by its unique identifier (id).
// 'id' is the unique identifier of the comment.
Task<TComment> GetCommentById(int id);
// Retrieves comments related to a specific quote, with pagination.
// 'quoteId' is the unique identifier of the quote.
// 'index' is the page number (for pagination).
// 'pageSize' is the number of comments per page.
Task<PaginationResult<TComment>> GetCommentByQuote(int quoteId, int index, int pageSize);
// Retrieves all comments, with pagination support.
// This returns a list of all comments.
Task<PaginationResult<TComment>> GetAllComment();
// Retrieves comments made by a specific user, with pagination.
// 'userId' is the unique identifier of the user.
// 'index' is the page number (for pagination).
// 'pageSize' is the number of comments per page.
Task<PaginationResult<TComment>> GetCommentByUser(int userId, int index, int pageSize);
// Adds a new commenT.
// 'comment' is the comment object that will be added.
Task AddComment(TComment comment);
// Updates an existing comment identified by 'id'.
// 'id' is the unique identifier of the comment, and 'comment' contains the updated comment data.
Task UpdateComment(int id, TComment comment);
// Removes a comment based on its unique identifier ('id').
// 'id' is the unique identifier of the comment to be removed.
Task RemoveComment(int id);
// Deletes all comments related to a specific quote.
// 'quoteId' is the unique identifier of the quote for which comments will be deleted.
Task DeleteCommentForQuote(int quoteId);
// Deletes all comments made by a specific user.
// 'userId' is the unique identifier of the user whose comments will be deleted.
Task DeleteCommentForuser(int userId);
// Retrieves the last comment ID.
Task<int> LastCommentId();
}
}

@ -0,0 +1,28 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Shared
{
public interface IFavoriteService
{
// Adds a quote to a user's list of favorites.
// 'quoteid' is the unique identifier of the quote to be added to favorites.
// 'userId' is the unique identifier of the user who is adding the quote to their favorites.
Task AddFavorite(int quoteid, int userId);
// Removes a quote from a user's list of favorites.
// 'quoteid' is the unique identifier of the quote to be removed from favorites.
// 'userId' is the unique identifier of the user who is removing the quote from their favorites.
Task RemoveFavorite(int quoteid, int userId);
// Removes all favorite quotes for a specific user.
// 'userId' is the unique identifier of the user whose favorites will be removed.
Task RemoveAllFavoriteForUser(int userId);
// Removes a specific quote from the favorite lists of all users.
// 'quoteId' is the unique identifier of the quote to be removed from all users' favorites.
Task RemoveAllFavoriteForQuote(int quoteId);
}

@ -0,0 +1,39 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Shared
{
public interface IImagesService<TImage>
{
// Retrieves an image by its unique identifier (id).
// 'id' is the unique identifier of the image.
Task<TImage> GetImageById(string id);
// Retrieves all images, with pagination support.
// This returns a list of all images in the system.
Task<PaginationResult<TImage>> GetAllImage();
// Retrieves a subset of images based on the provided index and page size.
// 'index' is the starting point for pagination (page number).
// 'pageSize' is the number of images per page.
Task<PaginationResult<TImage>> GetSomeImage(int index, int pageSize);
// Adds a new image to the system.
// 'image' is the image object that will be added to the system.
Task AddImage(TImage image);
// Updates an existing image identified by its unique identifier ('id').
// 'id' is the unique identifier of the image to be updated, and 'image' contains the updated image data.
Task UpdateImage(int id, TImage image);
// Removes an image from the system based on its unique identifier ('id').
// 'id' is the unique identifier of the image to be removed from the system.
Task RemoveImage(int id);
// Retrieves the last Image ID.
Task<int> GetLastImageId();
}
}

@ -0,0 +1,59 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Shared
{
public interface IQuestionService<TQuestion>
{
// Retrieves all questions, with pagination support.
// This returns a list of all questions in the system.
Task<PaginationResult<TQuestion>> GetAllQuestion();
// Retrieves a subset of questions based on the provided index and page size.
// 'index' is the starting point for pagination (page number).
// 'pageSize' is the number of questions per page.
Task<PaginationResult<TQuestion>> GetSomeQuestion(int index, int pageSize);
// Retrieves questions that are marked as invalid, with pagination support.
// 'index' is the starting page (page number)
// 'pageSize' is the number of questions per page.
Task<PaginationResult<TQuestion>> GetInvalidQuestion(int index, int pageSize);
// Retrieves a specific question by its unique identifier (id).
// 'id' is the unique identifier of the question.
Task<TQuestion> GetQuestionById(int id);
// Retrieves a random question from the system.
Task<TQuestion> GetRandomQuestion();
// Adds a new question to the system.
// 'question' is the question object that will be added.
Task AddQuestion(TQuestion question);
// Updates an existing question identified by 'id'.
// 'id' is the unique identifier of the question
// 'question' contains the new question data.
Task UpdateQuestion(int id, TQuestion question);
// Removes a question from the system based on its unique identifier ('id').
// 'id' is the unique identifier of the question to be removed.
Task RemoveQuestion(int id);
// Retrieves the total count of questions in the system.
Task<int> CountQuestions();
// Validates or invalidates a question based on its unique identifier ('id').
// 'id' is the unique identifier of the question
// 'isvalid' is a boolean indicating whether the question is valid.
Task ValidateQuestion(int id, bool isvalid);
// Retrieves a random question from a quote to a character.
Task<TQuestion> GetRandomQuestionQuoteToCharacter();
// Retrieves a random question from a quote to a source.
Task<TQuestion> GetRandomQuestionQuoteToSource();
}
}

@ -0,0 +1,41 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Shared
{
public interface IQuizService<TQuiz>
{
// Retrieves a specific quiz by its unique identifier (id).
// 'id' is the unique identifier of the quiz to be retrieved.
Task<TQuiz> GetQuizById(int id);
// Retrieves all quizzes, with pagination support.
// This returns a list of all quizzes in the system.
Task<PaginationResult<TQuiz>> GetAllQuiz();
// Retrieves a subset of quizzes based on the provided index and page size.
// 'index' is the starting point for pagination (page number).
// 'pageSize' is the number of quizzes per page.
Task<PaginationResult<TQuiz>> GetSomeQuiz(int index, int pageSize);
// Adds a new quiz to the system.
// 'quiz' is the quiz object that will be added to the system.
Task AddQuiz(TQuiz quiz);
// Updates an existing quiz identified by its unique identifier ('quizId').
// 'quizId' is the unique identifier of the quiz to be updated
// 'quiz' contains the updated quiz data.
Task UpdateQiz(int quizId, TQuiz quiz);
// Removes a quiz from the system based on its unique identifier ('quizId').
// 'quizId' is the unique identifier of the quiz to be removed from the system.
Task RemoveQuiz(int quizId);
// Retrieves the number of questions in a specific quiz identified by its unique identifier ('quizId').
// 'quizId' is the unique identifier of the quiz for which the number of questions is requested.
Task<int> GetNbQuestionQuiz(int quizId);
}
}

@ -0,0 +1,96 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Shared
{
public interface IQuoteService<TQuote>
{
// Retrieves the daily quote in a specified language.
// 'lang' is a language code.
Task<TQuote> GetDayliQuote(int lang);
// Retrieves a specific quote by its unique identifier (id).
Task<TQuote> GetQuoteById(int id);
// Retrieves all available quotes in the system, without any filters.
Task<PaginationResult<TQuote>> GetAllQuote();
// Retrieves a page of some availble quote based on the index (pagination)
// 'index' is the starting point for pagination
// 'pageSize' determines the number of quotes per page
Task<PaginationResult<TQuote>> GetSomeQuote(int index, int pageSize);
// Retrieves all available quotes but filtered by language.
// 'lang' is a language code used to filter the quotes in the chosen language.
Task<PaginationResult<TQuote>> GetAllQuoteLang(int lang);
// Retrieves a page of quote suggestions based on the index (pagination) and language.
// 'index' is the starting point for pagination
// 'pageSize' determines the number of quotes per page
// 'lang' specifies the language for the suggestions.
Task<PaginationResult<TQuote>> GetSuggestions(int index, int pageSize, int lang);
// Retrieves the favorite quotes of a specific user.
// 'index' is the starting point for pagination
// 'pageSize' determines the number of quotes per page
// 'UserId' is the identifier of the user to fetch their favorite quotes.
Task<PaginationResult<TQuote>> GetFavorites(int index, int pageSize, int UserId);
// Retrieves a page of valid quotes with pagination.
// 'index' is the current page
// 'pageSize' is the number of quotes per page.
Task<PaginationResult<TQuote>> GetValidQuote(int index, int pageSize);
// Retrieves a page of invalid quotes with pagination.
// 'index' is the current page
// 'pageSize' is the number of quotes per page.
Task<PaginationResult<TQuote>> GetInvalidQuote(int index, int pageSize);
// Searches for quotes based on content (text of the quote), with pagination and filtering by language.
// 'content' is the text of the quote
// 'index' is the current page
// 'pageSize' is the number of results per page
// 'lang' is the language code to filter the results.
Task<PaginationResult<TQuote>> SearchByContent(string content, int index, int pageSize, int lang);
// Searches for quotes by their source, with pagination and filtering by language.
// 'source' is the source of the quote
// 'index' is the current page
// 'pageSize' is the number of results per page
// 'lang' is the language code to filter the results.
Task<PaginationResult<TQuote>> SearchBySource(string source, int index, int pageSize, int lang);
// Searches for quotes related to a specific character, with pagination and filtering by language.
// 'character' refers to a name or role in the content
// 'index' is the current page
// 'pageSize' is the number of results per page,
// 'lang' is the language code to filter the results.
Task<PaginationResult<TQuote>> SearchByCharacter(string character, int index, int pageSize, int lang);
// Adds a new quote.
// 'quote' is the quote object that will be added.
Task AddQuote(TQuote quote);
// Updates an existing quote identified by 'quoteId' with new details.
// 'quoteId' is the ID of the quote to be updated
// 'quote' contains the new data.
Task UpdateQuote(int quoteId, TQuote quote);
// Removes a quote based on its unique identifier ('quoteId').
Task RemoveQuote(int quoteId);
// Returns the total number of quotes available.
Task<int> CountQuotes();
// Retrieves the last ID.
Task<int> GetLastQuoteId();
// Validates or invalidates a quote based on the 'quoteId' and a boolean value ('isValidate').
// If 'isValidate' is true, the quote is marked as valid; if false, it is invalid.
Task ValidateQuote(int quoteId, bool isValidate);
}
}

@ -0,0 +1,47 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Shared
{
public interface ISourceService<TSource>
{
// Retrieves a source by its unique identifier (id).
// 'id' is the unique identifier of the source.
Task<TSource> GetSourceById(int id);
// Retrieves a source by its title.
// 'title' is the title of the source to be retrieved.
Task<TSource> GetSourceByTitle(string title);
// Retrieves a source by its date.
// 'date' is the date associated with the source to be retrieved.
Task<TSource> GetSourceByDate(string date);
// Retrieves a source by its type.
// 'type' is the type of the source to be retrieved.
Task<TSource> GetSourceByType(string type);
// Retrieves all sources, with pagination support.
// This returns a list of all sources in the system.
Task<PaginationResult<TSource>> GetAll();
// Adds a new source to the system.
// 'source' is the source object that will be added.
Task AddSource(TSource source);
// Updates an existing source identified by its unique identifier ('id').
// 'id' is the unique identifier of the source to be updated
// 'source' contains the updated source data.
Task UpdateSource(int id, TSource source);
// Removes a source from the system based on its unique identifier ('id').
// 'id' is the unique identifier of the source to be removed.
Task RemoveSource(int id);
// Retrieves the unique identifier of the last added source.
Task<int> GetLastSourceId();
}
}

@ -0,0 +1,67 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Shared
{
public interface IUserService<TUser>
{
// Retrieves a user by their unique identifier (id).
// 'id' is the unique identifier of the user.
Task<TUser> GetUserById(int id);
// Retrieves a user by their username.
// 'username' is the username of the user to be retrieved.
Task<TUser> GetUserByUsername(string username);
// Retrieves a user by their email address.
// 'email' is the email address of the user to be retrieved.
Task<TUser> GetUserByEmail(string email);
// Retrieves all users.
// This returns a list of users with pagination information (e.g., total count, page size).
Task<PaginationResult<TUser>> GetAllUser();
// Retrieves a subset of users based on the provided index and page size.
// 'index' is the starting point for pagination (page number).
// 'pageSize' is the number of users per page.
Task<PaginationResult<TUser>> GetSomeUser(int index, int pageSize);
// Adds a new user to the system.
// 'user' is the user object that will be added to the system.
Task AddUser(TUser user);
// Updates the details of an existing user identified by 'userId'.
// 'userId' is the ID of the user to be updated, and 'user' contains the new user data.
Task UpdateUser(int userId, TUser user);
// Removes a user from the system based on their unique identifier ('userId').
// 'userId' is the unique identifier of the user to be removed.
Task RemoveUser(int userId);
// Retrieves the hashed password for a given username.
// 'username' is the username for which the password hash is to be retrieved.
Task<string> GetHashPassword(string username);
// Checks if a username already exists.
// 'username' is the username to check for existence.
Task<bool> ExistUsername(string username);
// Checks if an email address already exists.
// 'email' is the email address to check for existence.
Task<bool> ExistEmail(string email);
// Sets the admin role for a user.
// 'isAdmin' is a boolean indicating whether the user should have admin privileges.
Task SetAdminRole(bool isAdmin);
// Retrieves the total count of users.
Task<int> CountUser();
// Retrieves the last user ID.
Task<int> GetLastUserId();
}
}

@ -0,0 +1,33 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
// Represents a paginated result set for a collection of items.
public class PaginationResult<T>
{
// Total number in the item List.
public int totalCount { get; set; }
// The current page index (starting from 0).
public int pageIndex { get; set; }
// The number of items displayed per page.
public int countPerPage { get; set; }
// The list of items for the current page.
public List<T> items { get; set; }
// Constructor to initialize a new instance of the PaginationResult class.
// 'totalCount' is the total number of items, 'pageIndex' is the current page,
// 'countPerPage' is the number of items per page, and 'items' is the list of items for the current page.
public PaginationResult(int totalCount, int pageIndex, int countPerPage, List<T> items)
{
this.totalCount = totalCount; // Sets the total number of items available.
this.pageIndex = pageIndex; // Sets the current page index (starting from 1).
this.countPerPage = countPerPage; // Sets the number of items per page.
this.items = items; // Sets the items for the current page.
}
}

@ -0,0 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
</Project>

@ -0,0 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
</Project>

@ -0,0 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
</Project>

@ -0,0 +1,79 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.9.34723.18
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConsoleTest", "ConsoleTest\ConsoleTest.csproj", "{A8B0E4D8-0726-4248-BB6D-DAA2545270B1}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Shared", "Shared\Shared.csproj", "{792EF125-E2D4-457C-B536-BDAEFB49D14E}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Entity", "Entity\Entity.csproj", "{69A4450C-AA43-4622-A866-9A5F7C8A2C14}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Contextlib", "Contextlib\Contextlib.csproj", "{32977454-CE94-4532-AE26-29F6951B78CF}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StubbedContextLib", "StubbedContextLib\StubbedContextLib.csproj", "{5CD69B14-C6AE-4628-A374-996C486E25F2}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestModel2Entities", "TestModel2Entities\TestModel2Entities.csproj", "{2CF20FAC-C2F1-4048-9D46-F39081B0FBEF}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Entities", "Model\Entities.csproj", "{C51815EE-ED06-4F38-955E-7EBB72C0A7EF}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Model2Entities", "Model2entities\Model2Entities.csproj", "{4A1CBA3D-C798-4E19-865F-39F919F1205A}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "XUnitTest", "XUnitTest\XUnitTest.csproj", "{48002CA2-7CFF-4077-90CF-392476320CE3}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WfApi", "WfApi\WfApi.csproj", "{D4EEE1BF-CDCB-4E66-997B-7A5984DA7995}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{A8B0E4D8-0726-4248-BB6D-DAA2545270B1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A8B0E4D8-0726-4248-BB6D-DAA2545270B1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A8B0E4D8-0726-4248-BB6D-DAA2545270B1}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A8B0E4D8-0726-4248-BB6D-DAA2545270B1}.Release|Any CPU.Build.0 = Release|Any CPU
{792EF125-E2D4-457C-B536-BDAEFB49D14E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{792EF125-E2D4-457C-B536-BDAEFB49D14E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{792EF125-E2D4-457C-B536-BDAEFB49D14E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{792EF125-E2D4-457C-B536-BDAEFB49D14E}.Release|Any CPU.Build.0 = Release|Any CPU
{69A4450C-AA43-4622-A866-9A5F7C8A2C14}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{69A4450C-AA43-4622-A866-9A5F7C8A2C14}.Debug|Any CPU.Build.0 = Debug|Any CPU
{69A4450C-AA43-4622-A866-9A5F7C8A2C14}.Release|Any CPU.ActiveCfg = Release|Any CPU
{69A4450C-AA43-4622-A866-9A5F7C8A2C14}.Release|Any CPU.Build.0 = Release|Any CPU
{32977454-CE94-4532-AE26-29F6951B78CF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{32977454-CE94-4532-AE26-29F6951B78CF}.Debug|Any CPU.Build.0 = Debug|Any CPU
{32977454-CE94-4532-AE26-29F6951B78CF}.Release|Any CPU.ActiveCfg = Release|Any CPU
{32977454-CE94-4532-AE26-29F6951B78CF}.Release|Any CPU.Build.0 = Release|Any CPU
{5CD69B14-C6AE-4628-A374-996C486E25F2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5CD69B14-C6AE-4628-A374-996C486E25F2}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5CD69B14-C6AE-4628-A374-996C486E25F2}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5CD69B14-C6AE-4628-A374-996C486E25F2}.Release|Any CPU.Build.0 = Release|Any CPU
{2CF20FAC-C2F1-4048-9D46-F39081B0FBEF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2CF20FAC-C2F1-4048-9D46-F39081B0FBEF}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2CF20FAC-C2F1-4048-9D46-F39081B0FBEF}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2CF20FAC-C2F1-4048-9D46-F39081B0FBEF}.Release|Any CPU.Build.0 = Release|Any CPU
{C51815EE-ED06-4F38-955E-7EBB72C0A7EF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C51815EE-ED06-4F38-955E-7EBB72C0A7EF}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C51815EE-ED06-4F38-955E-7EBB72C0A7EF}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C51815EE-ED06-4F38-955E-7EBB72C0A7EF}.Release|Any CPU.Build.0 = Release|Any CPU
{4A1CBA3D-C798-4E19-865F-39F919F1205A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4A1CBA3D-C798-4E19-865F-39F919F1205A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4A1CBA3D-C798-4E19-865F-39F919F1205A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4A1CBA3D-C798-4E19-865F-39F919F1205A}.Release|Any CPU.Build.0 = Release|Any CPU
{48002CA2-7CFF-4077-90CF-392476320CE3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{48002CA2-7CFF-4077-90CF-392476320CE3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{48002CA2-7CFF-4077-90CF-392476320CE3}.Release|Any CPU.ActiveCfg = Release|Any CPU
{48002CA2-7CFF-4077-90CF-392476320CE3}.Release|Any CPU.Build.0 = Release|Any CPU
{D4EEE1BF-CDCB-4E66-997B-7A5984DA7995}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D4EEE1BF-CDCB-4E66-997B-7A5984DA7995}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D4EEE1BF-CDCB-4E66-997B-7A5984DA7995}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D4EEE1BF-CDCB-4E66-997B-7A5984DA7995}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {EC43AAEE-68F6-4CA2-A195-14A91E7D53C0}
EndGlobalSection
EndGlobal

@ -0,0 +1,33 @@
using Microsoft.AspNetCore.Mvc;
namespace WfApi.Controllers
{
[ApiController]
[Route("[controller]")]
public class WeatherForecastController : ControllerBase
{
private static readonly string[] Summaries = new[]
{
"Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
};
private readonly ILogger<WeatherForecastController> _logger;
public WeatherForecastController(ILogger<WeatherForecastController> logger)
{
_logger = logger;
}
[HttpGet(Name = "GetWeatherForecast")]
public IEnumerable<WeatherForecast> Get()
{
return Enumerable.Range(1, 5).Select(index => new WeatherForecast
{
Date = DateOnly.FromDateTime(DateTime.Now.AddDays(index)),
TemperatureC = Random.Shared.Next(-20, 55),
Summary = Summaries[Random.Shared.Next(Summaries.Length)]
})
.ToArray();
}
}
}

@ -0,0 +1,25 @@
#See https://aka.ms/customizecontainer to learn how to customize your debug container and how Visual Studio uses this Dockerfile to build your images for faster debugging.
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base
USER app
WORKDIR /app
EXPOSE 8080
EXPOSE 8081
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
ARG BUILD_CONFIGURATION=Release
WORKDIR /src
COPY ["WfApi/WfApi.csproj", "WfApi/"]
RUN dotnet restore "./WfApi/WfApi.csproj"
COPY . .
WORKDIR "/src/WfApi"
RUN dotnet build "./WfApi.csproj" -c $BUILD_CONFIGURATION -o /app/build
FROM build AS publish
ARG BUILD_CONFIGURATION=Release
RUN dotnet publish "./WfApi.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "WfApi.dll"]

@ -0,0 +1,25 @@
var builder = WebApplication.CreateBuilder(args);
// Add services to the container.
builder.Services.AddControllers();
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();
var app = builder.Build();
// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
{
app.UseSwagger();
app.UseSwaggerUI();
}
app.UseHttpsRedirection();
app.UseAuthorization();
app.MapControllers();
app.Run();

@ -0,0 +1,52 @@
{
"profiles": {
"http": {
"commandName": "Project",
"launchBrowser": true,
"launchUrl": "swagger",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"dotnetRunMessages": true,
"applicationUrl": "http://localhost:5239"
},
"https": {
"commandName": "Project",
"launchBrowser": true,
"launchUrl": "swagger",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"dotnetRunMessages": true,
"applicationUrl": "https://localhost:7250;http://localhost:5239"
},
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"launchUrl": "swagger",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"Container (Dockerfile)": {
"commandName": "Docker",
"launchBrowser": true,
"launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}/swagger",
"environmentVariables": {
"ASPNETCORE_HTTPS_PORTS": "8081",
"ASPNETCORE_HTTP_PORTS": "8080"
},
"publishAllPorts": true,
"useSSL": true
}
},
"$schema": "http://json.schemastore.org/launchsettings.json",
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:23612",
"sslPort": 44320
}
}
}

@ -0,0 +1,13 @@
namespace WfApi
{
public class WeatherForecast
{
public DateOnly Date { get; set; }
public int TemperatureC { get; set; }
public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);
public string? Summary { get; set; }
}
}

@ -0,0 +1,16 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<UserSecretsId>283a610b-b95e-4b09-af22-b7d3270a917d</UserSecretsId>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.19.6" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.4.0" />
</ItemGroup>
</Project>

@ -0,0 +1,6 @@
@WfApi_HostAddress = http://localhost:5239
GET {{WfApi_HostAddress}}/weatherforecast/
Accept: application/json
###

@ -0,0 +1,8 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
}
}

@ -0,0 +1,9 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*"
}

@ -0,0 +1,11 @@
namespace XUnitTest
{
public class UnitTest1
{
[Fact]
public void Test1()
{
}
}
}

@ -0,0 +1,23 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<IsPackable>false</IsPackable>
<IsTestProject>true</IsTestProject>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="coverlet.collector" Version="6.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
<PackageReference Include="xunit" Version="2.5.3" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.3" />
</ItemGroup>
<ItemGroup>
<Using Include="Xunit" />
</ItemGroup>
</Project>
Loading…
Cancel
Save