diff --git a/WF_EF_Api/.dockerignore b/WF_EF_Api/.dockerignore new file mode 100644 index 0000000..4d72b4f --- /dev/null +++ b/WF_EF_Api/.dockerignore @@ -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/** \ No newline at end of file diff --git a/WF_EF_Api/ConsoleTest/ConsoleTest.csproj b/WF_EF_Api/ConsoleTest/ConsoleTest.csproj new file mode 100644 index 0000000..206b89a --- /dev/null +++ b/WF_EF_Api/ConsoleTest/ConsoleTest.csproj @@ -0,0 +1,10 @@ + + + + Exe + net8.0 + enable + enable + + + diff --git a/WF_EF_Api/ConsoleTest/Program.cs b/WF_EF_Api/ConsoleTest/Program.cs new file mode 100644 index 0000000..af0744a --- /dev/null +++ b/WF_EF_Api/ConsoleTest/Program.cs @@ -0,0 +1 @@ + diff --git a/WF_EF_Api/Contextlib/Contextlib.csproj b/WF_EF_Api/Contextlib/Contextlib.csproj new file mode 100644 index 0000000..bb23fb7 --- /dev/null +++ b/WF_EF_Api/Contextlib/Contextlib.csproj @@ -0,0 +1,9 @@ + + + + net8.0 + enable + enable + + + diff --git a/WF_EF_Api/Entity/Entity.csproj b/WF_EF_Api/Entity/Entity.csproj new file mode 100644 index 0000000..bb23fb7 --- /dev/null +++ b/WF_EF_Api/Entity/Entity.csproj @@ -0,0 +1,9 @@ + + + + net8.0 + enable + enable + + + diff --git a/WF_EF_Api/Model/Entities.csproj b/WF_EF_Api/Model/Entities.csproj new file mode 100644 index 0000000..bb23fb7 --- /dev/null +++ b/WF_EF_Api/Model/Entities.csproj @@ -0,0 +1,9 @@ + + + + net8.0 + enable + enable + + + diff --git a/WF_EF_Api/Model2entities/Class1.cs b/WF_EF_Api/Model2entities/Class1.cs new file mode 100644 index 0000000..7214afa --- /dev/null +++ b/WF_EF_Api/Model2entities/Class1.cs @@ -0,0 +1,7 @@ +namespace Model2entities +{ + public class Class1 + { + + } +} diff --git a/WF_EF_Api/Model2entities/Model2Entities.csproj b/WF_EF_Api/Model2entities/Model2Entities.csproj new file mode 100644 index 0000000..bb23fb7 --- /dev/null +++ b/WF_EF_Api/Model2entities/Model2Entities.csproj @@ -0,0 +1,9 @@ + + + + net8.0 + enable + enable + + + diff --git a/WF_EF_Api/Shared/ICharacterService.cs b/WF_EF_Api/Shared/ICharacterService.cs new file mode 100644 index 0000000..a1c1a57 --- /dev/null +++ b/WF_EF_Api/Shared/ICharacterService.cs @@ -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 + { + // Retrieves a character by its unique identifier (id). + // 'id' is the unique identifier of the character. + Task GetCharById(int id); + + // Retrieves a character by its name. + // 'name' is the name of the character to be retrieved. + Task GetCharByName(string name); + + // Retrieves all characters, with pagination support. + // This returns a list of all characters in the system. + Task> 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 GetLastCharId(); + } +} diff --git a/WF_EF_Api/Shared/IComentaryService.cs b/WF_EF_Api/Shared/IComentaryService.cs new file mode 100644 index 0000000..2cf4fe1 --- /dev/null +++ b/WF_EF_Api/Shared/IComentaryService.cs @@ -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 + { + // Retrieves a comment by its unique identifier (id). + // 'id' is the unique identifier of the comment. + Task 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> GetCommentByQuote(int quoteId, int index, int pageSize); + + // Retrieves all comments, with pagination support. + // This returns a list of all comments. + Task> 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> 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 LastCommentId(); + } +} diff --git a/WF_EF_Api/Shared/IFavoriteService.cs b/WF_EF_Api/Shared/IFavoriteService.cs new file mode 100644 index 0000000..53ca0a7 --- /dev/null +++ b/WF_EF_Api/Shared/IFavoriteService.cs @@ -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); + } diff --git a/WF_EF_Api/Shared/IImagesService.cs b/WF_EF_Api/Shared/IImagesService.cs new file mode 100644 index 0000000..e2d0465 --- /dev/null +++ b/WF_EF_Api/Shared/IImagesService.cs @@ -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 + { + // Retrieves an image by its unique identifier (id). + // 'id' is the unique identifier of the image. + Task GetImageById(string id); + + // Retrieves all images, with pagination support. + // This returns a list of all images in the system. + Task> 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> 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 GetLastImageId(); + } +} diff --git a/WF_EF_Api/Shared/IQuestionService.cs b/WF_EF_Api/Shared/IQuestionService.cs new file mode 100644 index 0000000..73b8f0d --- /dev/null +++ b/WF_EF_Api/Shared/IQuestionService.cs @@ -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 + { + // Retrieves all questions, with pagination support. + // This returns a list of all questions in the system. + Task> 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> 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> GetInvalidQuestion(int index, int pageSize); + + // Retrieves a specific question by its unique identifier (id). + // 'id' is the unique identifier of the question. + Task GetQuestionById(int id); + + // Retrieves a random question from the system. + Task 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 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 GetRandomQuestionQuoteToCharacter(); + + // Retrieves a random question from a quote to a source. + Task GetRandomQuestionQuoteToSource(); + } +} diff --git a/WF_EF_Api/Shared/IQuizService.cs b/WF_EF_Api/Shared/IQuizService.cs new file mode 100644 index 0000000..e0735b2 --- /dev/null +++ b/WF_EF_Api/Shared/IQuizService.cs @@ -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 + { + // Retrieves a specific quiz by its unique identifier (id). + // 'id' is the unique identifier of the quiz to be retrieved. + Task GetQuizById(int id); + + // Retrieves all quizzes, with pagination support. + // This returns a list of all quizzes in the system. + Task> 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> 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 GetNbQuestionQuiz(int quizId); + } +} diff --git a/WF_EF_Api/Shared/IQuoteService.cs b/WF_EF_Api/Shared/IQuoteService.cs new file mode 100644 index 0000000..5a4e5e9 --- /dev/null +++ b/WF_EF_Api/Shared/IQuoteService.cs @@ -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 + { + // Retrieves the daily quote in a specified language. + // 'lang' is a language code. + Task GetDayliQuote(int lang); + + // Retrieves a specific quote by its unique identifier (id). + Task GetQuoteById(int id); + + // Retrieves all available quotes in the system, without any filters. + Task> 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> 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> 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> 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> 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> 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> 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> 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> 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> 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 CountQuotes(); + + // Retrieves the last ID. + Task 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); + } +} diff --git a/WF_EF_Api/Shared/ISourceService.cs b/WF_EF_Api/Shared/ISourceService.cs new file mode 100644 index 0000000..228078e --- /dev/null +++ b/WF_EF_Api/Shared/ISourceService.cs @@ -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 + { + // Retrieves a source by its unique identifier (id). + // 'id' is the unique identifier of the source. + Task GetSourceById(int id); + + // Retrieves a source by its title. + // 'title' is the title of the source to be retrieved. + Task GetSourceByTitle(string title); + + // Retrieves a source by its date. + // 'date' is the date associated with the source to be retrieved. + Task GetSourceByDate(string date); + + // Retrieves a source by its type. + // 'type' is the type of the source to be retrieved. + Task GetSourceByType(string type); + + // Retrieves all sources, with pagination support. + // This returns a list of all sources in the system. + Task> 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 GetLastSourceId(); + } +} diff --git a/WF_EF_Api/Shared/IUserService.cs b/WF_EF_Api/Shared/IUserService.cs new file mode 100644 index 0000000..d8028ee --- /dev/null +++ b/WF_EF_Api/Shared/IUserService.cs @@ -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 + { + // Retrieves a user by their unique identifier (id). + // 'id' is the unique identifier of the user. + Task GetUserById(int id); + + // Retrieves a user by their username. + // 'username' is the username of the user to be retrieved. + Task GetUserByUsername(string username); + + // Retrieves a user by their email address. + // 'email' is the email address of the user to be retrieved. + Task GetUserByEmail(string email); + + // Retrieves all users. + // This returns a list of users with pagination information (e.g., total count, page size). + Task> 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> 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 GetHashPassword(string username); + + + // Checks if a username already exists. + // 'username' is the username to check for existence. + Task ExistUsername(string username); + + // Checks if an email address already exists. + // 'email' is the email address to check for existence. + Task 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 CountUser(); + + // Retrieves the last user ID. + Task GetLastUserId(); + } +} diff --git a/WF_EF_Api/Shared/PaginationResult.cs b/WF_EF_Api/Shared/PaginationResult.cs new file mode 100644 index 0000000..5347d3e --- /dev/null +++ b/WF_EF_Api/Shared/PaginationResult.cs @@ -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 +{ + // 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 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 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. + } +} + diff --git a/WF_EF_Api/Shared/Shared.csproj b/WF_EF_Api/Shared/Shared.csproj new file mode 100644 index 0000000..bb23fb7 --- /dev/null +++ b/WF_EF_Api/Shared/Shared.csproj @@ -0,0 +1,9 @@ + + + + net8.0 + enable + enable + + + diff --git a/WF_EF_Api/StubbedContextLib/StubbedContextLib.csproj b/WF_EF_Api/StubbedContextLib/StubbedContextLib.csproj new file mode 100644 index 0000000..bb23fb7 --- /dev/null +++ b/WF_EF_Api/StubbedContextLib/StubbedContextLib.csproj @@ -0,0 +1,9 @@ + + + + net8.0 + enable + enable + + + diff --git a/WF_EF_Api/TestModel2Entities/TestModel2Entities.csproj b/WF_EF_Api/TestModel2Entities/TestModel2Entities.csproj new file mode 100644 index 0000000..bb23fb7 --- /dev/null +++ b/WF_EF_Api/TestModel2Entities/TestModel2Entities.csproj @@ -0,0 +1,9 @@ + + + + net8.0 + enable + enable + + + diff --git a/WF_EF_Api/WF_EF_Api.sln b/WF_EF_Api/WF_EF_Api.sln new file mode 100644 index 0000000..bff150d --- /dev/null +++ b/WF_EF_Api/WF_EF_Api.sln @@ -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 diff --git a/WF_EF_Api/WfApi/Controllers/WeatherForecastController.cs b/WF_EF_Api/WfApi/Controllers/WeatherForecastController.cs new file mode 100644 index 0000000..c618314 --- /dev/null +++ b/WF_EF_Api/WfApi/Controllers/WeatherForecastController.cs @@ -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 _logger; + + public WeatherForecastController(ILogger logger) + { + _logger = logger; + } + + [HttpGet(Name = "GetWeatherForecast")] + public IEnumerable 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(); + } + } +} diff --git a/WF_EF_Api/WfApi/Dockerfile b/WF_EF_Api/WfApi/Dockerfile new file mode 100644 index 0000000..a318a5b --- /dev/null +++ b/WF_EF_Api/WfApi/Dockerfile @@ -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"] \ No newline at end of file diff --git a/WF_EF_Api/WfApi/Program.cs b/WF_EF_Api/WfApi/Program.cs new file mode 100644 index 0000000..15eacee --- /dev/null +++ b/WF_EF_Api/WfApi/Program.cs @@ -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(); diff --git a/WF_EF_Api/WfApi/Properties/launchSettings.json b/WF_EF_Api/WfApi/Properties/launchSettings.json new file mode 100644 index 0000000..6e4ee26 --- /dev/null +++ b/WF_EF_Api/WfApi/Properties/launchSettings.json @@ -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 + } + } +} \ No newline at end of file diff --git a/WF_EF_Api/WfApi/WeatherForecast.cs b/WF_EF_Api/WfApi/WeatherForecast.cs new file mode 100644 index 0000000..cb85aa4 --- /dev/null +++ b/WF_EF_Api/WfApi/WeatherForecast.cs @@ -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; } + } +} diff --git a/WF_EF_Api/WfApi/WfApi.csproj b/WF_EF_Api/WfApi/WfApi.csproj new file mode 100644 index 0000000..ff8c292 --- /dev/null +++ b/WF_EF_Api/WfApi/WfApi.csproj @@ -0,0 +1,16 @@ + + + + net8.0 + enable + enable + 283a610b-b95e-4b09-af22-b7d3270a917d + Linux + + + + + + + + diff --git a/WF_EF_Api/WfApi/WfApi.http b/WF_EF_Api/WfApi/WfApi.http new file mode 100644 index 0000000..4fd1d65 --- /dev/null +++ b/WF_EF_Api/WfApi/WfApi.http @@ -0,0 +1,6 @@ +@WfApi_HostAddress = http://localhost:5239 + +GET {{WfApi_HostAddress}}/weatherforecast/ +Accept: application/json + +### diff --git a/WF_EF_Api/WfApi/appsettings.Development.json b/WF_EF_Api/WfApi/appsettings.Development.json new file mode 100644 index 0000000..ff66ba6 --- /dev/null +++ b/WF_EF_Api/WfApi/appsettings.Development.json @@ -0,0 +1,8 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + } +} diff --git a/WF_EF_Api/WfApi/appsettings.json b/WF_EF_Api/WfApi/appsettings.json new file mode 100644 index 0000000..4d56694 --- /dev/null +++ b/WF_EF_Api/WfApi/appsettings.json @@ -0,0 +1,9 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + }, + "AllowedHosts": "*" +} diff --git a/WF_EF_Api/XUnitTest/UnitTest1.cs b/WF_EF_Api/XUnitTest/UnitTest1.cs new file mode 100644 index 0000000..f8a0369 --- /dev/null +++ b/WF_EF_Api/XUnitTest/UnitTest1.cs @@ -0,0 +1,11 @@ +namespace XUnitTest +{ + public class UnitTest1 + { + [Fact] + public void Test1() + { + + } + } +} \ No newline at end of file diff --git a/WF_EF_Api/XUnitTest/XUnitTest.csproj b/WF_EF_Api/XUnitTest/XUnitTest.csproj new file mode 100644 index 0000000..3aa9860 --- /dev/null +++ b/WF_EF_Api/XUnitTest/XUnitTest.csproj @@ -0,0 +1,23 @@ + + + + net8.0 + enable + enable + + false + true + + + + + + + + + + + + + +