├── BlazorWasmGraphQL ├── Client │ ├── Pages │ │ ├── MovieRating.razor │ │ ├── MovieDetails.razor.css │ │ ├── Home.razor.css │ │ ├── AddToWatchlist.razor │ │ ├── MovieRating.razor.cs │ │ ├── MovieGenre.razor.css │ │ ├── Watchlist.razor.css │ │ ├── MovieRating.razor.css │ │ ├── MovieCard.razor.cs │ │ ├── MovieCard.razor.css │ │ ├── MovieGenre.razor │ │ ├── MovieCard.razor │ │ ├── MovieGenre.razor.cs │ │ ├── Home.razor │ │ ├── Watchlist.razor.cs │ │ ├── Login.razor │ │ ├── MovieDetails.razor.cs │ │ ├── Watchlist.razor │ │ ├── MovieDetails.razor │ │ ├── Registration.razor.cs │ │ ├── ManageMovies.razor.cs │ │ ├── Home.razor.cs │ │ ├── Login.razor.cs │ │ ├── ManageMovies.razor │ │ ├── Registration.razor │ │ ├── AddEditMovie.razor │ │ ├── AddToWatchlist.razor.cs │ │ └── AddEditMovie.razor.cs │ ├── GraphQLAPIClient │ │ ├── DeleteMovieData.graphql │ │ ├── FetchGenreList.graphql │ │ ├── AddMovieData.graphql │ │ ├── EditMovieData.graphql │ │ ├── AuthenticateUser.graphql │ │ ├── FetchMovieList.graphql │ │ ├── RegisterUser.graphql │ │ ├── FetchWatchList.graphql │ │ ├── SortMovieData.graphql │ │ ├── FilterMovieData.graphql │ │ ├── ToggleWatchList.graphql │ │ ├── schema.extensions.graphql │ │ ├── .graphqlrc.json │ │ └── schema.graphql │ ├── wwwroot │ │ ├── favicon.ico │ │ ├── icon-192.png │ │ ├── css │ │ │ ├── open-iconic │ │ │ │ ├── font │ │ │ │ │ ├── fonts │ │ │ │ │ │ ├── open-iconic.eot │ │ │ │ │ │ ├── open-iconic.otf │ │ │ │ │ │ ├── open-iconic.ttf │ │ │ │ │ │ ├── open-iconic.woff │ │ │ │ │ │ └── open-iconic.svg │ │ │ │ │ └── css │ │ │ │ │ │ └── open-iconic-bootstrap.min.css │ │ │ │ ├── ICON-LICENSE │ │ │ │ ├── README.md │ │ │ │ └── FONT-LICENSE │ │ │ └── app.css │ │ └── index.html │ ├── Shared │ │ ├── MainLayout.razor.css │ │ ├── RedirectToLogin.razor │ │ ├── NavMenu.razor.css │ │ ├── MainLayout.razor │ │ ├── NavMenu.razor.cs │ │ ├── NavMenu.razor │ │ ├── CustomValidator.cs │ │ └── AppStateContainer.cs │ ├── .config │ │ └── dotnet-tools.json │ ├── AuthToken.cs │ ├── _Imports.razor │ ├── App.razor │ ├── Properties │ │ └── launchSettings.json │ ├── BlazorWasmGraphQL.Client.csproj │ ├── Program.cs │ └── CustomAuthStateProvider.cs ├── Server │ ├── Poster │ │ ├── DefaultPoster.jpg │ │ ├── 0de54a0b-6fa5-4a50-b10c-3e8ca36581d9.jpg │ │ ├── 130361e0-669f-4f25-b608-6613c51e33b6.jpg │ │ ├── 469a72b1-02bf-496d-8e0c-86166f1b2584.jpg │ │ ├── 5af918b5-0aeb-40c8-a4a7-444c964fb437.jpg │ │ ├── 72d23bc9-4e58-42cf-9b93-8acd4eebe5b9.jpg │ │ ├── 75457f0f-8bdc-414b-81e9-7fa5d37d13a4.jpg │ │ ├── 8b1c11fe-da6b-4b4f-a2d1-eee115585e89.jpg │ │ ├── 8c93580c-1e5c-45c0-a1b7-84cb706bc367.jpg │ │ ├── 9ef9d5a6-3ebb-4bf5-8be6-5c225644e39a.jpg │ │ ├── a87ac02e-9d9c-46c7-8097-b37d4418e8ce.jpg │ │ ├── ac780ac1-081d-4d78-8bfa-c358a0a97a26.jpg │ │ ├── d1d3885d-8970-49e9-9048-5c6b0e178b6c.jpg │ │ └── ef36ce15-f73f-4485-8e6e-8c010d5a7c58.jpg │ ├── appsettings.Development.json │ ├── Models │ │ ├── UserType.cs │ │ ├── AuthenticatedUser.cs │ │ ├── UserMaster.cs │ │ └── MovieDBContext.cs │ ├── Interfaces │ │ ├── IWatchlist.cs │ │ ├── IUser.cs │ │ └── IMovie.cs │ ├── appsettings.json │ ├── Pages │ │ ├── Error.cshtml.cs │ │ └── Error.cshtml │ ├── GraphQL │ │ ├── MovieQueryResolver.cs │ │ ├── WatchlistMutationResolver.cs │ │ ├── AuthMutationResolver.cs │ │ └── MovieMutationResolver.cs │ ├── Properties │ │ └── launchSettings.json │ ├── BlazorWasmGraphQL.Server.csproj │ ├── DataAccess │ │ ├── WatchlistDataAccessLayer.cs │ │ ├── UserDataAccessLayer.cs │ │ └── MovieDataAccessLayer.cs │ └── Program.cs └── Shared │ ├── Models │ ├── UserRoles.cs │ ├── Genre.cs │ ├── WatchlistItem.cs │ ├── Watchlist.cs │ ├── Policies.cs │ └── Movie.cs │ ├── Dto │ ├── AuthResponse.cs │ ├── RegistrationResponse.cs │ ├── UserLogin.cs │ └── UserRegistration.cs │ └── BlazorWasmGraphQL.Shared.csproj ├── DBScript └── MovieDBscript.sql ├── README.md ├── BlazorWasmGraphQL.sln └── .gitignore /BlazorWasmGraphQL/Client/Pages/MovieRating.razor: -------------------------------------------------------------------------------- 1 | @inherits MovieRatingBase 2 | 3 | @Rating -------------------------------------------------------------------------------- /DBScript/MovieDBscript.sql: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/suresh-mohan/Blazor-WebAssembly-GraphQL/HEAD/DBScript/MovieDBscript.sql -------------------------------------------------------------------------------- /BlazorWasmGraphQL/Client/GraphQLAPIClient/DeleteMovieData.graphql: -------------------------------------------------------------------------------- 1 | mutation DeleteMovieData($movieId:Int!){ 2 | deleteMovie(movieId:$movieId) 3 | } -------------------------------------------------------------------------------- /BlazorWasmGraphQL/Client/GraphQLAPIClient/FetchGenreList.graphql: -------------------------------------------------------------------------------- 1 | query FetchGenreList{ 2 | genreList{ 3 | genreId, 4 | genreName 5 | } 6 | } -------------------------------------------------------------------------------- /BlazorWasmGraphQL/Client/wwwroot/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/suresh-mohan/Blazor-WebAssembly-GraphQL/HEAD/BlazorWasmGraphQL/Client/wwwroot/favicon.ico -------------------------------------------------------------------------------- /BlazorWasmGraphQL/Client/wwwroot/icon-192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/suresh-mohan/Blazor-WebAssembly-GraphQL/HEAD/BlazorWasmGraphQL/Client/wwwroot/icon-192.png -------------------------------------------------------------------------------- /BlazorWasmGraphQL/Server/Poster/DefaultPoster.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/suresh-mohan/Blazor-WebAssembly-GraphQL/HEAD/BlazorWasmGraphQL/Server/Poster/DefaultPoster.jpg -------------------------------------------------------------------------------- /BlazorWasmGraphQL/Client/GraphQLAPIClient/AddMovieData.graphql: -------------------------------------------------------------------------------- 1 | mutation AddMovieData($movieData:MovieInput!){ 2 | addMovie(movie:$movieData){ 3 | movie{ 4 | title 5 | } 6 | } 7 | } -------------------------------------------------------------------------------- /BlazorWasmGraphQL/Client/GraphQLAPIClient/EditMovieData.graphql: -------------------------------------------------------------------------------- 1 | mutation EditMovieData($movieData:MovieInput!){ 2 | editMovie(movie:$movieData){ 3 | movie{ 4 | title 5 | } 6 | } 7 | } -------------------------------------------------------------------------------- /BlazorWasmGraphQL/Client/Pages/MovieDetails.razor.css: -------------------------------------------------------------------------------- 1 | img { 2 | overflow: hidden; 3 | transition: transform .5s; 4 | } 5 | 6 | img:hover { 7 | transform: scale(1.5); 8 | } 9 | -------------------------------------------------------------------------------- /BlazorWasmGraphQL/Client/GraphQLAPIClient/AuthenticateUser.graphql: -------------------------------------------------------------------------------- 1 | mutation login($userData:UserLoginInput!){ 2 | userLogin(userDetails:$userData){ 3 | errorMessage, 4 | token 5 | } 6 | } -------------------------------------------------------------------------------- /BlazorWasmGraphQL/Server/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft.AspNetCore": "Warning" 6 | } 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /BlazorWasmGraphQL/Server/Poster/0de54a0b-6fa5-4a50-b10c-3e8ca36581d9.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/suresh-mohan/Blazor-WebAssembly-GraphQL/HEAD/BlazorWasmGraphQL/Server/Poster/0de54a0b-6fa5-4a50-b10c-3e8ca36581d9.jpg -------------------------------------------------------------------------------- /BlazorWasmGraphQL/Server/Poster/130361e0-669f-4f25-b608-6613c51e33b6.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/suresh-mohan/Blazor-WebAssembly-GraphQL/HEAD/BlazorWasmGraphQL/Server/Poster/130361e0-669f-4f25-b608-6613c51e33b6.jpg -------------------------------------------------------------------------------- /BlazorWasmGraphQL/Server/Poster/469a72b1-02bf-496d-8e0c-86166f1b2584.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/suresh-mohan/Blazor-WebAssembly-GraphQL/HEAD/BlazorWasmGraphQL/Server/Poster/469a72b1-02bf-496d-8e0c-86166f1b2584.jpg -------------------------------------------------------------------------------- /BlazorWasmGraphQL/Server/Poster/5af918b5-0aeb-40c8-a4a7-444c964fb437.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/suresh-mohan/Blazor-WebAssembly-GraphQL/HEAD/BlazorWasmGraphQL/Server/Poster/5af918b5-0aeb-40c8-a4a7-444c964fb437.jpg -------------------------------------------------------------------------------- /BlazorWasmGraphQL/Server/Poster/72d23bc9-4e58-42cf-9b93-8acd4eebe5b9.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/suresh-mohan/Blazor-WebAssembly-GraphQL/HEAD/BlazorWasmGraphQL/Server/Poster/72d23bc9-4e58-42cf-9b93-8acd4eebe5b9.jpg -------------------------------------------------------------------------------- /BlazorWasmGraphQL/Server/Poster/75457f0f-8bdc-414b-81e9-7fa5d37d13a4.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/suresh-mohan/Blazor-WebAssembly-GraphQL/HEAD/BlazorWasmGraphQL/Server/Poster/75457f0f-8bdc-414b-81e9-7fa5d37d13a4.jpg -------------------------------------------------------------------------------- /BlazorWasmGraphQL/Server/Poster/8b1c11fe-da6b-4b4f-a2d1-eee115585e89.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/suresh-mohan/Blazor-WebAssembly-GraphQL/HEAD/BlazorWasmGraphQL/Server/Poster/8b1c11fe-da6b-4b4f-a2d1-eee115585e89.jpg -------------------------------------------------------------------------------- /BlazorWasmGraphQL/Server/Poster/8c93580c-1e5c-45c0-a1b7-84cb706bc367.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/suresh-mohan/Blazor-WebAssembly-GraphQL/HEAD/BlazorWasmGraphQL/Server/Poster/8c93580c-1e5c-45c0-a1b7-84cb706bc367.jpg -------------------------------------------------------------------------------- /BlazorWasmGraphQL/Server/Poster/9ef9d5a6-3ebb-4bf5-8be6-5c225644e39a.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/suresh-mohan/Blazor-WebAssembly-GraphQL/HEAD/BlazorWasmGraphQL/Server/Poster/9ef9d5a6-3ebb-4bf5-8be6-5c225644e39a.jpg -------------------------------------------------------------------------------- /BlazorWasmGraphQL/Server/Poster/a87ac02e-9d9c-46c7-8097-b37d4418e8ce.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/suresh-mohan/Blazor-WebAssembly-GraphQL/HEAD/BlazorWasmGraphQL/Server/Poster/a87ac02e-9d9c-46c7-8097-b37d4418e8ce.jpg -------------------------------------------------------------------------------- /BlazorWasmGraphQL/Server/Poster/ac780ac1-081d-4d78-8bfa-c358a0a97a26.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/suresh-mohan/Blazor-WebAssembly-GraphQL/HEAD/BlazorWasmGraphQL/Server/Poster/ac780ac1-081d-4d78-8bfa-c358a0a97a26.jpg -------------------------------------------------------------------------------- /BlazorWasmGraphQL/Server/Poster/d1d3885d-8970-49e9-9048-5c6b0e178b6c.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/suresh-mohan/Blazor-WebAssembly-GraphQL/HEAD/BlazorWasmGraphQL/Server/Poster/d1d3885d-8970-49e9-9048-5c6b0e178b6c.jpg -------------------------------------------------------------------------------- /BlazorWasmGraphQL/Server/Poster/ef36ce15-f73f-4485-8e6e-8c010d5a7c58.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/suresh-mohan/Blazor-WebAssembly-GraphQL/HEAD/BlazorWasmGraphQL/Server/Poster/ef36ce15-f73f-4485-8e6e-8c010d5a7c58.jpg -------------------------------------------------------------------------------- /BlazorWasmGraphQL/Client/wwwroot/css/open-iconic/font/fonts/open-iconic.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/suresh-mohan/Blazor-WebAssembly-GraphQL/HEAD/BlazorWasmGraphQL/Client/wwwroot/css/open-iconic/font/fonts/open-iconic.eot -------------------------------------------------------------------------------- /BlazorWasmGraphQL/Client/wwwroot/css/open-iconic/font/fonts/open-iconic.otf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/suresh-mohan/Blazor-WebAssembly-GraphQL/HEAD/BlazorWasmGraphQL/Client/wwwroot/css/open-iconic/font/fonts/open-iconic.otf -------------------------------------------------------------------------------- /BlazorWasmGraphQL/Client/wwwroot/css/open-iconic/font/fonts/open-iconic.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/suresh-mohan/Blazor-WebAssembly-GraphQL/HEAD/BlazorWasmGraphQL/Client/wwwroot/css/open-iconic/font/fonts/open-iconic.ttf -------------------------------------------------------------------------------- /BlazorWasmGraphQL/Client/wwwroot/css/open-iconic/font/fonts/open-iconic.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/suresh-mohan/Blazor-WebAssembly-GraphQL/HEAD/BlazorWasmGraphQL/Client/wwwroot/css/open-iconic/font/fonts/open-iconic.woff -------------------------------------------------------------------------------- /BlazorWasmGraphQL/Client/Pages/Home.razor.css: -------------------------------------------------------------------------------- 1 | .filter-container { 2 | position: fixed; 3 | } 4 | 5 | @media screen and (max-width: 768px) { 6 | .filter-container { 7 | position: relative; 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /BlazorWasmGraphQL/Client/GraphQLAPIClient/FetchMovieList.graphql: -------------------------------------------------------------------------------- 1 | query FetchMovieList{ 2 | movieList{ 3 | movieId, 4 | title, 5 | posterPath, 6 | genre, 7 | rating, 8 | language, 9 | duration 10 | } 11 | } -------------------------------------------------------------------------------- /BlazorWasmGraphQL/Client/GraphQLAPIClient/RegisterUser.graphql: -------------------------------------------------------------------------------- 1 | mutation RegisterUser($userData:UserRegistrationInput!){ 2 | userRegistration(registrationData:$userData){ 3 | isRegistrationSuccess, 4 | errorMessage 5 | } 6 | } -------------------------------------------------------------------------------- /BlazorWasmGraphQL/Shared/Models/UserRoles.cs: -------------------------------------------------------------------------------- 1 | namespace BlazorWasmGraphQL.Shared.Models 2 | { 3 | public static class UserRoles 4 | { 5 | public const string Admin = "Admin"; 6 | public const string User = "User"; 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /BlazorWasmGraphQL/Client/Shared/MainLayout.razor.css: -------------------------------------------------------------------------------- 1 | .container { 2 | margin-top: 70px; 3 | } 4 | 5 | .page { 6 | position: relative; 7 | display: flex; 8 | flex-direction: column; 9 | } 10 | 11 | .main { 12 | flex: 1; 13 | } 14 | -------------------------------------------------------------------------------- /BlazorWasmGraphQL/Server/Models/UserType.cs: -------------------------------------------------------------------------------- 1 | namespace BlazorWasmGraphQL.Server.Models 2 | { 3 | public partial class UserType 4 | { 5 | public int UserTypeId { get; set; } 6 | public string UserTypeName { get; set; } = null!; 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /BlazorWasmGraphQL/Shared/Dto/AuthResponse.cs: -------------------------------------------------------------------------------- 1 | namespace BlazorWasmGraphQL.Shared.Dto 2 | { 3 | public class AuthResponse 4 | { 5 | public string? ErrorMessage { get; set; } 6 | 7 | public string? Token { get; set; } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /BlazorWasmGraphQL/Client/.config/dotnet-tools.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": 1, 3 | "isRoot": true, 4 | "tools": { 5 | "strawberryshake.tools": { 6 | "version": "12.4.1", 7 | "commands": [ 8 | "dotnet-graphql" 9 | ] 10 | } 11 | } 12 | } -------------------------------------------------------------------------------- /BlazorWasmGraphQL/Client/Shared/RedirectToLogin.razor: -------------------------------------------------------------------------------- 1 | @inject NavigationManager Navigation 2 | 3 | @code { 4 | protected override void OnInitialized() 5 | { 6 | Navigation.NavigateTo($"login?returnUrl={Uri.EscapeDataString(Navigation.Uri)}"); 7 | } 8 | } -------------------------------------------------------------------------------- /BlazorWasmGraphQL/Client/GraphQLAPIClient/FetchWatchList.graphql: -------------------------------------------------------------------------------- 1 | mutation FetchWatchList($userId:Int!){ 2 | watchlist(userId:$userId){ 3 | movieId, 4 | title, 5 | posterPath, 6 | genre, 7 | rating, 8 | language, 9 | duration 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /BlazorWasmGraphQL/Shared/Dto/RegistrationResponse.cs: -------------------------------------------------------------------------------- 1 | namespace BlazorWasmGraphQL.Shared.Dto 2 | { 3 | public class RegistrationResponse 4 | { 5 | public bool IsRegistrationSuccess { get; set; } 6 | public string? ErrorMessage { get; set; } 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /BlazorWasmGraphQL/Client/GraphQLAPIClient/SortMovieData.graphql: -------------------------------------------------------------------------------- 1 | query SortMovieList($sortInput:MovieSortInput!){ 2 | movieList(order:[$sortInput]){ 3 | movieId, 4 | title, 5 | posterPath, 6 | genre, 7 | rating, 8 | language, 9 | duration 10 | } 11 | } -------------------------------------------------------------------------------- /BlazorWasmGraphQL/Client/Pages/AddToWatchlist.razor: -------------------------------------------------------------------------------- 1 | @inherits AddToWatchlistBase 2 | 3 | -------------------------------------------------------------------------------- /BlazorWasmGraphQL/Server/Interfaces/IWatchlist.cs: -------------------------------------------------------------------------------- 1 | namespace BlazorWasmGraphQL.Server.Interfaces 2 | { 3 | public interface IWatchlist 4 | { 5 | Task ToggleWatchlistItem(int userId, int movieId); 6 | 7 | Task GetWatchlistId(int userId); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /BlazorWasmGraphQL/Client/AuthToken.cs: -------------------------------------------------------------------------------- 1 | namespace BlazorWasmGraphQL.Client 2 | { 3 | public static class AuthToken 4 | { 5 | public static string TokenValue { get; set; } = string.Empty; 6 | 7 | public static string TokenIdentifier { get; set; } = "authToken"; 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /BlazorWasmGraphQL/Client/Pages/MovieRating.razor.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Components; 2 | 3 | namespace BlazorWasmGraphQL.Client.Pages 4 | { 5 | public class MovieRatingBase : ComponentBase 6 | { 7 | [Parameter] 8 | public decimal? Rating { get; set; } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /BlazorWasmGraphQL/Client/GraphQLAPIClient/FilterMovieData.graphql: -------------------------------------------------------------------------------- 1 | query FilterMovieByID($filterInput:MovieFilterInput){ 2 | movieList(where:$filterInput){ 3 | movieId, 4 | title, 5 | posterPath, 6 | genre, 7 | rating, 8 | language, 9 | duration, 10 | overview 11 | } 12 | } -------------------------------------------------------------------------------- /BlazorWasmGraphQL/Client/Pages/MovieGenre.razor.css: -------------------------------------------------------------------------------- 1 | .active-genre { 2 | background-color: #fb641b; 3 | } 4 | 5 | a { 6 | cursor: pointer; 7 | } 8 | 9 | @media only screen and (max-width: 768px) { 10 | .list-group { 11 | position: relative; 12 | width: 100%; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /BlazorWasmGraphQL/Client/Pages/Watchlist.razor.css: -------------------------------------------------------------------------------- 1 | img { 2 | width: 40%; 3 | overflow: hidden; 4 | position: relative; 5 | } 6 | 7 | .watchlist-row { 8 | background: #fcfcfc; 9 | box-shadow: 0 3px 1px -2px rgba(0,0,0,.2), 0 2px 2px 0 rgba(0,0,0,.14), 0 1px 5px 0 rgba(0,0,0,.12); 10 | } 11 | -------------------------------------------------------------------------------- /BlazorWasmGraphQL/Client/GraphQLAPIClient/ToggleWatchList.graphql: -------------------------------------------------------------------------------- 1 | mutation ToggleWatchList($userId:Int!, $movieId: Int!){ 2 | toggleWatchlist(userId:$userId, movieId:$movieId){ 3 | movieId, 4 | title, 5 | posterPath, 6 | genre, 7 | rating, 8 | language, 9 | duration 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /BlazorWasmGraphQL/Shared/Models/Genre.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | namespace BlazorWasmGraphQL.Server.Models 5 | { 6 | public partial class Genre 7 | { 8 | public int GenreId { get; set; } 9 | public string GenreName { get; set; } = null!; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /BlazorWasmGraphQL/Shared/Models/WatchlistItem.cs: -------------------------------------------------------------------------------- 1 | namespace BlazorWasmGraphQL.Server.Models 2 | { 3 | public partial class WatchlistItem 4 | { 5 | public int WatchlistItemId { get; set; } 6 | public string WatchlistId { get; set; } = null!; 7 | public int MovieId { get; set; } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /BlazorWasmGraphQL/Client/Pages/MovieRating.razor.css: -------------------------------------------------------------------------------- 1 | .movie-rating { 2 | background: #e0b600; 3 | border: 3px solid #e0b600; 4 | padding: 5px; 5 | color: #fff; 6 | text-align: center; 7 | display: block; 8 | z-index: 100; 9 | min-width: 35px; 10 | font-size: 14px; 11 | border-radius: 50%; 12 | } 13 | -------------------------------------------------------------------------------- /BlazorWasmGraphQL/Client/Shared/NavMenu.razor.css: -------------------------------------------------------------------------------- 1 | nav { 2 | background-color: #3f51b5; 3 | box-shadow: 0 3px 5px -1px rgba(0,0,0,.2), 0 6px 10px 0 rgba(0,0,0,.14), 0 1px 18px 0 rgba(0,0,0,.12); 4 | } 5 | 6 | .spacer { 7 | flex: 1 1 auto; 8 | } 9 | 10 | .nav-link { 11 | color: #ffffff; 12 | } 13 | 14 | .dropdown { 15 | cursor: pointer; 16 | } 17 | -------------------------------------------------------------------------------- /BlazorWasmGraphQL/Shared/Models/Watchlist.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | namespace BlazorWasmGraphQL.Server.Models 5 | { 6 | public partial class Watchlist 7 | { 8 | public string WatchlistId { get; set; } = null!; 9 | public int UserId { get; set; } 10 | public DateTime DateCreated { get; set; } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /BlazorWasmGraphQL/Server/Interfaces/IUser.cs: -------------------------------------------------------------------------------- 1 | using BlazorWasmGraphQL.Server.Models; 2 | using BlazorWasmGraphQL.Shared.Dto; 3 | 4 | namespace BlazorWasmGraphQL.Server.Interfaces 5 | { 6 | public interface IUser 7 | { 8 | AuthenticatedUser AuthenticateUser(UserLogin loginCredentials); 9 | 10 | Task RegisterUser(UserMaster user); 11 | 12 | Task IsUserExists(int userId); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /BlazorWasmGraphQL/Client/Shared/MainLayout.razor: -------------------------------------------------------------------------------- 1 | @inherits LayoutComponentBase 2 | @using BlazorWasmGraphQL.Client.Pages 3 | 4 | 5 | 6 | 7 | 8 |
9 |
10 | 11 |
12 | @Body 13 |
14 |
15 |
16 | -------------------------------------------------------------------------------- /BlazorWasmGraphQL/Client/GraphQLAPIClient/schema.extensions.graphql: -------------------------------------------------------------------------------- 1 | scalar _KeyFieldSet 2 | 3 | directive @key(fields: _KeyFieldSet!) on SCHEMA | OBJECT 4 | 5 | directive @serializationType(name: String!) on SCALAR 6 | 7 | directive @runtimeType(name: String!) on SCALAR 8 | 9 | directive @enumValue(value: String!) on ENUM_VALUE 10 | 11 | directive @rename(name: String!) on INPUT_FIELD_DEFINITION | INPUT_OBJECT | ENUM | ENUM_VALUE 12 | 13 | extend schema @key(fields: "id") -------------------------------------------------------------------------------- /BlazorWasmGraphQL/Server/Models/AuthenticatedUser.cs: -------------------------------------------------------------------------------- 1 | namespace BlazorWasmGraphQL.Server.Models 2 | { 3 | public class AuthenticatedUser 4 | { 5 | public int UserId { get; set; } 6 | 7 | public string Username { get; set; } 8 | 9 | public string UserTypeName { get; set; } 10 | 11 | public AuthenticatedUser() 12 | { 13 | Username = string.Empty; 14 | UserTypeName = string.Empty; 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /BlazorWasmGraphQL/Shared/Dto/UserLogin.cs: -------------------------------------------------------------------------------- 1 | using System.ComponentModel.DataAnnotations; 2 | 3 | namespace BlazorWasmGraphQL.Shared.Dto 4 | { 5 | public class UserLogin 6 | { 7 | [Required] 8 | public string Username { get; set; } 9 | 10 | [Required] 11 | public string Password { get; set; } 12 | 13 | public UserLogin() 14 | { 15 | Username = string.Empty; 16 | Password = string.Empty; 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /BlazorWasmGraphQL/Shared/BlazorWasmGraphQL.Shared.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net6.0 5 | enable 6 | enable 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /BlazorWasmGraphQL/Server/Interfaces/IMovie.cs: -------------------------------------------------------------------------------- 1 | using BlazorWasmGraphQL.Server.Models; 2 | 3 | namespace BlazorWasmGraphQL.Server.Interfaces 4 | { 5 | public interface IMovie 6 | { 7 | Task AddMovie(Movie movie); 8 | 9 | Task> GetGenre(); 10 | 11 | Task> GetAllMovies(); 12 | 13 | Task UpdateMovie(Movie movie); 14 | 15 | Task DeleteMovie(int movieId); 16 | 17 | Task> GetMoviesAvailableInWatchlist(string watchlistID); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /BlazorWasmGraphQL/Server/Models/UserMaster.cs: -------------------------------------------------------------------------------- 1 | namespace BlazorWasmGraphQL.Server.Models 2 | { 3 | public partial class UserMaster 4 | { 5 | public int UserId { get; set; } 6 | public string FirstName { get; set; } = null!; 7 | public string LastName { get; set; } = null!; 8 | public string Username { get; set; } = null!; 9 | public string Password { get; set; } = null!; 10 | public string Gender { get; set; } = null!; 11 | public string UserTypeName { get; set; } = null!; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /BlazorWasmGraphQL/Client/Pages/MovieCard.razor.cs: -------------------------------------------------------------------------------- 1 | using BlazorWasmGraphQL.Server.Models; 2 | using Microsoft.AspNetCore.Components; 3 | 4 | namespace BlazorWasmGraphQL.Client.Pages 5 | { 6 | public class MovieCardBase : ComponentBase 7 | { 8 | [Parameter] 9 | public Movie Movie { get; set; } = new(); 10 | 11 | protected string imagePreview = string.Empty; 12 | 13 | protected override void OnParametersSet() 14 | { 15 | imagePreview = "/Poster/" + Movie.PosterPath; 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /BlazorWasmGraphQL/Client/Pages/MovieCard.razor.css: -------------------------------------------------------------------------------- 1 | .movie-card { 2 | min-width: 200px; 3 | max-width: 200px; 4 | max-height: 400px; 5 | margin: 3px; 6 | } 7 | 8 | a { 9 | text-decoration: none; 10 | } 11 | 12 | .card-rating { 13 | position: absolute; 14 | right: 7px; 15 | top: 7px; 16 | } 17 | 18 | .card-title { 19 | text-overflow: ellipsis; 20 | white-space: nowrap; 21 | overflow: hidden; 22 | } 23 | 24 | .card { 25 | transition: .3s; 26 | } 27 | 28 | .card:hover { 29 | box-shadow: 0 5px 5px -3px #777, 0 8px 10px 1px #777, 0 3px 14px 2px #777; 30 | } 31 | -------------------------------------------------------------------------------- /BlazorWasmGraphQL/Client/_Imports.razor: -------------------------------------------------------------------------------- 1 | @using System.Net.Http 2 | @using System.Net.Http.Json 3 | @using Microsoft.AspNetCore.Components.Forms 4 | @using Microsoft.AspNetCore.Components.Routing 5 | @using Microsoft.AspNetCore.Components.Web 6 | @using Microsoft.AspNetCore.Components.Web.Virtualization 7 | @using Microsoft.AspNetCore.Components.WebAssembly.Http 8 | @using Microsoft.JSInterop 9 | @using BlazorWasmGraphQL.Client 10 | @using BlazorWasmGraphQL.Client.Shared 11 | @using BlazorWasmGraphQL.Client.GraphQLAPIClient 12 | @using Microsoft.AspNetCore.Components.Authorization 13 | @using Syncfusion.Blazor 14 | @using Syncfusion.Blazor.Notifications -------------------------------------------------------------------------------- /BlazorWasmGraphQL/Server/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft.AspNetCore": "Warning" 6 | } 7 | }, 8 | "ConnectionStrings": { 9 | "DefaultConnection": "Data Source=LAPTOP-N6QJKU32;Initial Catalog=MovieDB;User Id=test;Password=sa;" 10 | }, 11 | "Jwt": { 12 | // The HmacSha256 encryption algorithm requires a key size minimum 32 bits. 13 | "SecretKey": "EnSJ3YxydKxrKwg7", 14 | "Issuer": "https://localhost:7104", 15 | "Audience": "https://localhost:7104" 16 | }, 17 | "DefaultPoster": "DefaultPoster.jpg", 18 | "AllowedHosts": "*" 19 | } 20 | -------------------------------------------------------------------------------- /BlazorWasmGraphQL/Client/Pages/MovieGenre.razor: -------------------------------------------------------------------------------- 1 | @inherits MovieGenreBase 2 | 3 |
4 | 7 | All Genre 8 | 9 | @foreach (var genre in lstGenre) 10 | { 11 | 14 | @genre.GenreName 15 | 16 | } 17 |
-------------------------------------------------------------------------------- /BlazorWasmGraphQL/Client/Pages/MovieCard.razor: -------------------------------------------------------------------------------- 1 | @inherits MovieCardBase 2 | 3 |
4 | 5 | @Movie.Title 6 | 7 |
8 | 9 | 10 | 11 | 12 |
@Movie.Title
13 |
14 |

15 | @Movie.Genre 16 |

17 |
18 |
-------------------------------------------------------------------------------- /BlazorWasmGraphQL/Client/Shared/NavMenu.razor.cs: -------------------------------------------------------------------------------- 1 | using Blazored.LocalStorage; 2 | using Microsoft.AspNetCore.Components; 3 | 4 | namespace BlazorWasmGraphQL.Client.Shared 5 | { 6 | public class NavMenuBase : ComponentBase 7 | { 8 | [Inject] 9 | NavigationManager NavigationManager { get; set; } = default!; 10 | 11 | [Inject] 12 | CustomAuthStateProvider CustomAuthStateProvider { get; set; } = default!; 13 | 14 | [Inject] 15 | ILocalStorageService LocalStorageService { get; set; } = default!; 16 | 17 | protected async Task LogoutUser() 18 | { 19 | await LocalStorageService.RemoveItemAsync(AuthToken.TokenIdentifier); 20 | CustomAuthStateProvider.NotifyAuthState(); 21 | NavigationManager.NavigateTo("/"); 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /BlazorWasmGraphQL/Shared/Models/Policies.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Authorization; 2 | 3 | namespace BlazorWasmGraphQL.Shared.Models 4 | { 5 | public static class Policies 6 | { 7 | public static AuthorizationPolicy AdminPolicy() 8 | { 9 | return new AuthorizationPolicyBuilder().RequireAuthenticatedUser() 10 | .RequireRole(UserRoles.Admin) 11 | .Build(); 12 | } 13 | 14 | public static AuthorizationPolicy UserPolicy() 15 | { 16 | return new AuthorizationPolicyBuilder().RequireAuthenticatedUser() 17 | .RequireRole(UserRoles.User) 18 | .Build(); 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /BlazorWasmGraphQL/Server/Pages/Error.cshtml.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Mvc; 2 | using Microsoft.AspNetCore.Mvc.RazorPages; 3 | using System.Diagnostics; 4 | 5 | namespace BlazorWasmGraphQL.Server.Pages 6 | { 7 | [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)] 8 | [IgnoreAntiforgeryToken] 9 | public class ErrorModel : PageModel 10 | { 11 | public string? RequestId { get; set; } 12 | 13 | public bool ShowRequestId => !string.IsNullOrEmpty(RequestId); 14 | 15 | private readonly ILogger _logger; 16 | 17 | public ErrorModel(ILogger logger) 18 | { 19 | _logger = logger; 20 | } 21 | 22 | public void OnGet() 23 | { 24 | RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier; 25 | } 26 | } 27 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Blazor-WebAssembly-GraphQL 2 | 3 | Check the live demo at https://blazorwasmgraphql.azurewebsites.net/ 4 | 5 | ## Blog reference 6 | [A Full-Stack Web App Using Blazor WebAssembly and GraphQL-Part 1](https://www.syncfusion.com/blogs/post/a-full-stack-web-app-using-blazor-webassembly-and-graphql-part-1.aspx) 7 | 8 | ## Prerequisites 9 | - Visual Studio 2022 10 | - SQL Server 11 | - SQL Server Management Studio (SSMS) 12 | - .NET Core 6.0 SDK or above 13 | 14 | 15 | ## Steps to run the app 16 | 17 | - Clone the Repo 18 | - Scaffold and seed the initial data using the [DBScript](https://github.com/suresh-mohan/Blazor-WebAssembly-GraphQL/tree/main/DBScript) 19 | - Put your own connection string in the [appsettings.json](https://github.com/suresh-mohan/Blazor-WebAssembly-GraphQL/blob/main/BlazorWasmGraphQL/Server/appsettings.json) file. 20 | - Build and launch the application from Visual Studio. 21 | -------------------------------------------------------------------------------- /BlazorWasmGraphQL/Client/GraphQLAPIClient/.graphqlrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "schema": "schema.graphql", 3 | "documents": "**/*.graphql", 4 | "extensions": { 5 | "strawberryShake": { 6 | "name": "MovieClient", 7 | "namespace": "BlazorWasmGraphQL.Client.GraphQLAPIClient", 8 | "url": "https://localhost:7104/graphql/", 9 | "dependencyInjection": true, 10 | "strictSchemaValidation": true, 11 | "hashAlgorithm": "md5", 12 | "useSingleFile": true, 13 | "requestStrategy": "Default", 14 | "outputDirectoryName": "Generated", 15 | "noStore": false, 16 | "emitGeneratedCode": true, 17 | "razorComponents": false, 18 | "records": { 19 | "inputs": false, 20 | "entities": false 21 | }, 22 | "transportProfiles": [ 23 | { 24 | "default": "Http", 25 | "subscription": "WebSocket" 26 | } 27 | ] 28 | } 29 | } 30 | } -------------------------------------------------------------------------------- /BlazorWasmGraphQL/Server/GraphQL/MovieQueryResolver.cs: -------------------------------------------------------------------------------- 1 | using BlazorWasmGraphQL.Server.Interfaces; 2 | using BlazorWasmGraphQL.Server.Models; 3 | 4 | namespace BlazorWasmGraphQL.Server.GraphQL 5 | { 6 | public class MovieQueryResolver 7 | { 8 | readonly IMovie _movieService; 9 | 10 | public MovieQueryResolver(IMovie movieService) 11 | { 12 | _movieService = movieService; 13 | } 14 | 15 | [GraphQLDescription("Gets the list of genres.")] 16 | public async Task> GetGenreList() 17 | { 18 | return await _movieService.GetGenre(); 19 | } 20 | 21 | [GraphQLDescription("Gets the list of movies.")] 22 | [UseSorting] 23 | [UseFiltering] 24 | public async Task> GetMovieList() 25 | { 26 | List availableMovies = await _movieService.GetAllMovies(); 27 | return availableMovies.AsQueryable(); 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /BlazorWasmGraphQL/Client/App.razor: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | @if (!context.User.Identity.IsAuthenticated) 7 | { 8 | 9 | } 10 | else 11 | { 12 |

You are not authorized to access this resource.

13 | } 14 |
15 |
16 |
17 | 18 | Not found 19 | 20 |

Sorry, there's nothing at this address.

21 |
22 |
23 |
24 |
-------------------------------------------------------------------------------- /BlazorWasmGraphQL/Client/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "iisSettings": { 3 | "windowsAuthentication": false, 4 | "anonymousAuthentication": true, 5 | "iisExpress": { 6 | "applicationUrl": "http://localhost:23588", 7 | "sslPort": 44334 8 | } 9 | }, 10 | "profiles": { 11 | "BlazorWasmGraphQL": { 12 | "commandName": "Project", 13 | "dotnetRunMessages": true, 14 | "launchBrowser": true, 15 | "inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}", 16 | "applicationUrl": "https://localhost:7104;http://localhost:5104", 17 | "environmentVariables": { 18 | "ASPNETCORE_ENVIRONMENT": "Development" 19 | } 20 | }, 21 | "IIS Express": { 22 | "commandName": "IISExpress", 23 | "launchBrowser": true, 24 | "inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}", 25 | "environmentVariables": { 26 | "ASPNETCORE_ENVIRONMENT": "Development" 27 | } 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /BlazorWasmGraphQL/Server/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "iisSettings": { 3 | "windowsAuthentication": false, 4 | "anonymousAuthentication": true, 5 | "iisExpress": { 6 | "applicationUrl": "http://localhost:23588", 7 | "sslPort": 44334 8 | } 9 | }, 10 | "profiles": { 11 | "BlazorWasmGraphQL.Server": { 12 | "commandName": "Project", 13 | "dotnetRunMessages": true, 14 | "launchBrowser": true, 15 | "inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}", 16 | "applicationUrl": "https://localhost:7104;http://localhost:5104", 17 | "environmentVariables": { 18 | "ASPNETCORE_ENVIRONMENT": "Development" 19 | } 20 | }, 21 | "IIS Express": { 22 | "commandName": "IISExpress", 23 | "launchBrowser": true, 24 | "inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}", 25 | "environmentVariables": { 26 | "ASPNETCORE_ENVIRONMENT": "Development" 27 | } 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /BlazorWasmGraphQL/Shared/Models/Movie.cs: -------------------------------------------------------------------------------- 1 | using System.ComponentModel.DataAnnotations; 2 | 3 | namespace BlazorWasmGraphQL.Server.Models 4 | { 5 | public partial class Movie 6 | { 7 | public int MovieId { get; set; } 8 | 9 | [Required] 10 | public string Title { get; set; } 11 | 12 | [Required] 13 | public string Overview { get; set; } 14 | 15 | [Required] 16 | public string Genre { get; set; } 17 | 18 | [Required] 19 | public string Language { get; set; } 20 | 21 | [Required] 22 | [Range(1, int.MaxValue, ErrorMessage = " This field accepts only positive numbers.")] 23 | public int Duration { get; set; } 24 | 25 | [Required] 26 | [Range(0, 10.0, ErrorMessage = "The value should be less than or equal to 10.")] 27 | public decimal Rating { get; set; } 28 | 29 | public string? PosterPath { get; set; } 30 | 31 | public Movie() 32 | { 33 | Title = string.Empty; 34 | Overview = string.Empty; 35 | Genre = string.Empty; 36 | Language = string.Empty; 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /BlazorWasmGraphQL/Client/Pages/MovieGenre.razor.cs: -------------------------------------------------------------------------------- 1 | using BlazorWasmGraphQL.Client.Shared; 2 | using BlazorWasmGraphQL.Server.Models; 3 | using Microsoft.AspNetCore.Components; 4 | 5 | namespace BlazorWasmGraphQL.Client.Pages 6 | { 7 | public class MovieGenreBase : ComponentBase 8 | { 9 | [Inject] 10 | NavigationManager NavigationManager { get; set; } = default!; 11 | 12 | [Inject] 13 | AppStateContainer AppStateContainer { get; set; } = default!; 14 | 15 | [Parameter] 16 | public string SelectedGenre { get; set; } = string.Empty; 17 | 18 | protected List lstGenre = new(); 19 | 20 | protected override void OnInitialized() 21 | { 22 | lstGenre = AppStateContainer.AvailableGenre; 23 | } 24 | 25 | protected void SelectGenre(string genreName) 26 | { 27 | if (string.IsNullOrEmpty(genreName)) 28 | { 29 | NavigationManager.NavigateTo("/"); 30 | } 31 | else 32 | { 33 | NavigationManager.NavigateTo("/category/" + genreName); 34 | } 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /BlazorWasmGraphQL/Client/wwwroot/css/open-iconic/ICON-LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 Waybury 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. -------------------------------------------------------------------------------- /BlazorWasmGraphQL/Client/Pages/Home.razor: -------------------------------------------------------------------------------- 1 | @page "/" 2 | @page "/category/{GenreName}" 3 | @inherits HomeBase 4 | 5 |
6 |
7 |
8 |
9 | 10 |
11 |

Sort Movies

12 | 17 |
18 |
19 |
20 |
21 |
22 | @if (lstMovie.Count == 0) 23 | { 24 |

No data to display

25 | } 26 | else 27 | { 28 |
29 | @foreach (var movie in lstMovie) 30 | { 31 | 32 | } 33 |
34 | } 35 |
36 |
-------------------------------------------------------------------------------- /BlazorWasmGraphQL/Client/Shared/NavMenu.razor: -------------------------------------------------------------------------------- 1 | @using BlazorWasmGraphQL.Shared.Models 2 | @inherits NavMenuBase 3 | 4 | -------------------------------------------------------------------------------- /BlazorWasmGraphQL/Shared/Dto/UserRegistration.cs: -------------------------------------------------------------------------------- 1 | using System.ComponentModel.DataAnnotations; 2 | 3 | namespace BlazorWasmGraphQL.Shared.Dto 4 | { 5 | public class UserRegistration 6 | { 7 | [Required] 8 | [Display(Name = "First Name")] 9 | public string FirstName { get; set; } 10 | 11 | [Required] 12 | [Display(Name = "Last Name")] 13 | public string LastName { get; set; } 14 | 15 | [Required] 16 | public string Username { get; set; } 17 | 18 | [Required] 19 | [RegularExpression(@"^(?=.*?[A-Z])(?=.*?[a-z])(?=.*?[0-9]).{8,}$", 20 | ErrorMessage = "Password should have minimum 8 characters, at least 1 uppercase letter, 1 lowercase letter and 1 number.")] 21 | public string Password { get; set; } 22 | 23 | [Required] 24 | [Display(Name = "Confirm Password")] 25 | [Compare("Password", ErrorMessage = "The password and confirmation password do not match.")] 26 | public string ConfirmPassword { get; set; } 27 | 28 | [Required] 29 | public string Gender { get; set; } 30 | 31 | public UserRegistration() 32 | { 33 | FirstName = string.Empty; 34 | LastName = string.Empty; 35 | Gender = string.Empty; 36 | Username = string.Empty; 37 | Password = string.Empty; 38 | ConfirmPassword = string.Empty; 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /BlazorWasmGraphQL/Client/BlazorWasmGraphQL.Client.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net6.0 5 | enable 6 | enable 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /BlazorWasmGraphQL/Server/BlazorWasmGraphQL.Server.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net6.0 5 | enable 6 | enable 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | all 18 | runtime; build; native; contentfiles; analyzers; buildtransitive 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /BlazorWasmGraphQL/Client/Shared/CustomValidator.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Components; 2 | using Microsoft.AspNetCore.Components.Forms; 3 | 4 | namespace BlazorWasmGraphQL.Client.Shared 5 | { 6 | public class CustomValidator : ComponentBase 7 | { 8 | private ValidationMessageStore messageStore = default!; 9 | 10 | [CascadingParameter] 11 | private EditContext CurrentEditContext { get; set; } = default!; 12 | 13 | protected override void OnInitialized() 14 | { 15 | if (CurrentEditContext == null) 16 | { 17 | throw new InvalidOperationException( 18 | $"{nameof(CustomValidator)} requires a cascading parameter of type {nameof(EditContext)}"); 19 | } 20 | 21 | messageStore = new ValidationMessageStore(CurrentEditContext); 22 | 23 | CurrentEditContext.OnValidationRequested += (s, e) => 24 | messageStore.Clear(); 25 | CurrentEditContext.OnFieldChanged += (s, e) => 26 | messageStore.Clear(e.FieldIdentifier); 27 | } 28 | 29 | public void DisplayErrors(string formField, string error) 30 | { 31 | messageStore.Add(CurrentEditContext.Field(formField), error); 32 | 33 | CurrentEditContext.NotifyValidationStateChanged(); 34 | } 35 | 36 | public void ClearErrors() 37 | { 38 | messageStore.Clear(); 39 | CurrentEditContext.NotifyValidationStateChanged(); 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /BlazorWasmGraphQL/Client/wwwroot/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Movie App 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 |
Loading...
19 | 20 |
21 | An unhandled error has occurred. 22 | Reload 23 | 🗙 24 |
25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /BlazorWasmGraphQL/Client/Pages/Watchlist.razor.cs: -------------------------------------------------------------------------------- 1 | using BlazorWasmGraphQL.Client.Shared; 2 | using BlazorWasmGraphQL.Server.Models; 3 | using Microsoft.AspNetCore.Components; 4 | using Microsoft.AspNetCore.Components.Authorization; 5 | 6 | namespace BlazorWasmGraphQL.Client.Pages 7 | { 8 | public class WatchlistBase : ComponentBase 9 | { 10 | [Inject] 11 | AppStateContainer AppStateContainer { get; set; } = default!; 12 | 13 | [Inject] 14 | NavigationManager NavigationManager { get; set; } = default!; 15 | 16 | [CascadingParameter] 17 | Task AuthenticationState { get; set; } = default!; 18 | 19 | protected List watchlist = new(); 20 | 21 | protected override async Task OnInitializedAsync() 22 | { 23 | AppStateContainer.OnAppStateChange += StateHasChanged; 24 | 25 | var authState = await AuthenticationState; 26 | 27 | if (authState.User.Identity is not null && 28 | authState.User.Identity.IsAuthenticated) 29 | { 30 | GetUserWatchlist(); 31 | } 32 | else 33 | { 34 | NavigationManager.NavigateTo($"login?returnUrl={Uri.EscapeDataString(NavigationManager.Uri)}"); 35 | } 36 | } 37 | protected void WatchlistClickHandler() 38 | { 39 | GetUserWatchlist(); 40 | } 41 | 42 | void GetUserWatchlist() 43 | { 44 | watchlist = AppStateContainer.userWatchlist; 45 | } 46 | 47 | public void Dispose() 48 | { 49 | AppStateContainer.OnAppStateChange -= StateHasChanged; 50 | } 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /BlazorWasmGraphQL/Server/Pages/Error.cshtml: -------------------------------------------------------------------------------- 1 | @page 2 | @model BlazorWasmGraphQL.Server.Pages.ErrorModel 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | Error 11 | 12 | 13 | 14 | 15 | 16 |
17 |
18 |

Error.

19 |

An error occurred while processing your request.

20 | 21 | @if (Model.ShowRequestId) 22 | { 23 |

24 | Request ID: @Model.RequestId 25 |

26 | } 27 | 28 |

Development Mode

29 |

30 | Swapping to the Development environment displays detailed information about the error that occurred. 31 |

32 |

33 | The Development environment shouldn't be enabled for deployed applications. 34 | It can result in displaying sensitive information from exceptions to end users. 35 | For local debugging, enable the Development environment by setting the ASPNETCORE_ENVIRONMENT environment variable to Development 36 | and restarting the app. 37 |

38 |
39 |
40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /BlazorWasmGraphQL/Server/GraphQL/WatchlistMutationResolver.cs: -------------------------------------------------------------------------------- 1 | using BlazorWasmGraphQL.Server.Interfaces; 2 | using BlazorWasmGraphQL.Server.Models; 3 | using HotChocolate.AspNetCore.Authorization; 4 | 5 | namespace BlazorWasmGraphQL.Server.GraphQL 6 | { 7 | [ExtendObjectType(typeof(MovieMutationResolver))] 8 | public class WatchlistMutationResolver 9 | { 10 | readonly IWatchlist _watchlistService; 11 | readonly IMovie _movieService; 12 | readonly IUser _userService; 13 | 14 | public WatchlistMutationResolver(IWatchlist watchlistService, IMovie movieService, IUser userService) 15 | { 16 | _watchlistService = watchlistService; 17 | _movieService = movieService; 18 | _userService = userService; 19 | } 20 | 21 | [Authorize] 22 | [GraphQLDescription("Get the user Watchlist.")] 23 | public async Task> GetWatchlist(int userId) 24 | { 25 | return await GetUserWatchlist(userId); 26 | } 27 | 28 | [Authorize] 29 | [GraphQLDescription("Toggle Watchlist item.")] 30 | public async Task> ToggleWatchlist(int userId, int movieId) 31 | { 32 | await _watchlistService.ToggleWatchlistItem(userId, movieId); 33 | return await GetUserWatchlist(userId); 34 | } 35 | 36 | async Task> GetUserWatchlist(int userId) 37 | { 38 | bool user = await _userService.IsUserExists(userId); 39 | 40 | if (user) 41 | { 42 | string watchlistid = await _watchlistService.GetWatchlistId(userId); 43 | return await _movieService.GetMoviesAvailableInWatchlist(watchlistid); 44 | } 45 | else 46 | { 47 | return new List(); 48 | } 49 | } 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /BlazorWasmGraphQL/Client/Pages/Login.razor: -------------------------------------------------------------------------------- 1 | @page "/login" 2 | @inherits LoginBase 3 | 4 |
5 |
6 |
7 |
8 |
9 |

Login

10 |
11 | New User? 12 | Register 13 |
14 |
15 |
16 |
17 | 18 | 19 | 20 | 21 |
22 | 23 |
24 | 25 | 26 |
27 |
28 | 29 |
30 | 31 |
32 | 33 | 34 |
35 |
36 | 37 |
38 | 39 |
40 |
41 |
42 |
43 |
44 |
-------------------------------------------------------------------------------- /BlazorWasmGraphQL/Client/Pages/MovieDetails.razor.cs: -------------------------------------------------------------------------------- 1 | using BlazorWasmGraphQL.Client.GraphQLAPIClient; 2 | using BlazorWasmGraphQL.Server.Models; 3 | using Microsoft.AspNetCore.Components; 4 | 5 | namespace BlazorWasmGraphQL.Client.Pages 6 | { 7 | public class MovieDetailsBase : ComponentBase 8 | { 9 | [Inject] 10 | MovieClient MovieClient { get; set; } = default!; 11 | 12 | [Parameter] 13 | public int MovieID { get; set; } 14 | 15 | public Movie movie = new(); 16 | protected string imagePreview = string.Empty; 17 | protected string movieDuration = string.Empty; 18 | 19 | protected override async Task OnParametersSetAsync() 20 | { 21 | MovieFilterInput movieFilterInput = new() 22 | { 23 | MovieId = new() 24 | { 25 | Eq = MovieID 26 | } 27 | }; 28 | 29 | var response = await MovieClient.FilterMovieByID.ExecuteAsync(movieFilterInput); 30 | 31 | if (response.Data is not null) 32 | { 33 | var movieData = response.Data.MovieList[0]; 34 | 35 | movie.MovieId = movieData.MovieId; 36 | movie.Title = movieData.Title; 37 | movie.Genre = movieData.Genre; 38 | movie.Duration = movieData.Duration; 39 | movie.PosterPath = movieData.PosterPath; 40 | movie.Rating = movieData.Rating; 41 | movie.Overview = movieData.Overview; 42 | movie.Language = movieData.Language; 43 | 44 | imagePreview = "/Poster/" + movie.PosterPath; 45 | ConvertMinToHour(); 46 | } 47 | } 48 | 49 | void ConvertMinToHour() 50 | { 51 | TimeSpan movieLength = TimeSpan.FromMinutes(movie.Duration); 52 | movieDuration = string.Format("{0:0}h {1:00}min", (int)movieLength.TotalHours, movieLength.Minutes); 53 | } 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /BlazorWasmGraphQL/Client/Pages/Watchlist.razor: -------------------------------------------------------------------------------- 1 | @page "/watchlist" 2 | @inherits WatchlistBase 3 | 4 |

My Watchlist

5 |
6 | 7 | @if (watchlist.Count == 0) 8 | { 9 |

No Data to show...

10 | } 11 | else 12 | 13 | { 14 |
15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 |
ImageTitleGenreLanguageAction
27 | 28 | 29 | 30 | @foreach (var movie in watchlist) 31 | { 32 | 33 | 36 | 39 | 40 | 41 | 44 | 45 | } 46 | 47 |
34 | @movie.Title 35 | 37 | @movie.Title 38 | @movie.Genre@movie.Language 42 | 43 |
48 |
49 |
50 | } -------------------------------------------------------------------------------- /BlazorWasmGraphQL/Client/Program.cs: -------------------------------------------------------------------------------- 1 | using Blazored.LocalStorage; 2 | using BlazorWasmGraphQL.Client; 3 | using BlazorWasmGraphQL.Client.Shared; 4 | using BlazorWasmGraphQL.Shared.Models; 5 | using Microsoft.AspNetCore.Components.Authorization; 6 | using Microsoft.AspNetCore.Components.Web; 7 | using Microsoft.AspNetCore.Components.WebAssembly.Hosting; 8 | using System.Net.Http.Headers; 9 | using Syncfusion.Blazor; 10 | 11 | var builder = WebAssemblyHostBuilder.CreateDefault(args); 12 | builder.RootComponents.Add("#app"); 13 | builder.RootComponents.Add("head::after"); 14 | 15 | builder.Services.AddOptions(); 16 | builder.Services.AddAuthorizationCore(config => 17 | { 18 | config.AddPolicy(UserRoles.Admin, Policies.AdminPolicy()); 19 | config.AddPolicy(UserRoles.User, Policies.UserPolicy()); 20 | }); 21 | 22 | builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) }); 23 | 24 | builder.Services.AddSyncfusionBlazor(options => { options.IgnoreScriptIsolation = true; }); 25 | 26 | string graphQLServerPath = builder.HostEnvironment.BaseAddress + "graphql"; 27 | 28 | builder.Services.AddMovieClient() 29 | .ConfigureHttpClient(client => 30 | { 31 | client.BaseAddress = new Uri(graphQLServerPath); 32 | 33 | client.DefaultRequestHeaders.Authorization = 34 | new AuthenticationHeaderValue("Bearer", AuthToken.TokenValue); 35 | } 36 | ); 37 | 38 | // If you use the following line, the AuthenticationStateProvider will not send the updated state to components. 39 | //And hence the nav bar will not be updated, without reloading. 40 | //builder.Services.AddScoped(); 41 | builder.Services.AddScoped(); 42 | builder.Services.AddScoped(provider => provider.GetRequiredService()); 43 | 44 | builder.Services.AddScoped(); 45 | builder.Services.AddBlazoredLocalStorage(); 46 | 47 | await builder.Build().RunAsync(); 48 | -------------------------------------------------------------------------------- /BlazorWasmGraphQL/Client/Pages/MovieDetails.razor: -------------------------------------------------------------------------------- 1 | @page "/movies/details/{movieID:int}" 2 | @inherits MovieDetailsBase 3 | 4 | @if (movie.MovieId > 0) 5 | { 6 |
7 |
8 |

Movie Details

9 |
10 |
11 |
12 |
13 | @movie.Title 14 |
15 |
16 |
17 |
18 |
19 |

@movie.Title

20 | 21 | 22 | 23 |
24 | 25 |

@movie.Overview

26 |
27 |
28 | 29 | 30 | 31 | 32 | 33 |
34 |
35 | Language : @movie.Language 36 | Genre : @movie.Genre 37 | Duration : @movieDuration 38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 | } 46 | else 47 | { 48 |

Loading...

49 | } -------------------------------------------------------------------------------- /BlazorWasmGraphQL.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 17 4 | VisualStudioVersion = 17.0.31919.166 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BlazorWasmGraphQL.Server", "BlazorWasmGraphQL\Server\BlazorWasmGraphQL.Server.csproj", "{B5E7711A-5960-4A82-A9BC-0EC5FA03B688}" 7 | EndProject 8 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BlazorWasmGraphQL.Client", "BlazorWasmGraphQL\Client\BlazorWasmGraphQL.Client.csproj", "{87DB03B5-ED25-46DE-9541-75F17A618005}" 9 | EndProject 10 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BlazorWasmGraphQL.Shared", "BlazorWasmGraphQL\Shared\BlazorWasmGraphQL.Shared.csproj", "{D276249E-1E3F-4B27-ADB2-53C1D70C161D}" 11 | EndProject 12 | Global 13 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 14 | Debug|Any CPU = Debug|Any CPU 15 | Release|Any CPU = Release|Any CPU 16 | EndGlobalSection 17 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 18 | {B5E7711A-5960-4A82-A9BC-0EC5FA03B688}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 19 | {B5E7711A-5960-4A82-A9BC-0EC5FA03B688}.Debug|Any CPU.Build.0 = Debug|Any CPU 20 | {B5E7711A-5960-4A82-A9BC-0EC5FA03B688}.Release|Any CPU.ActiveCfg = Release|Any CPU 21 | {B5E7711A-5960-4A82-A9BC-0EC5FA03B688}.Release|Any CPU.Build.0 = Release|Any CPU 22 | {87DB03B5-ED25-46DE-9541-75F17A618005}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 23 | {87DB03B5-ED25-46DE-9541-75F17A618005}.Debug|Any CPU.Build.0 = Debug|Any CPU 24 | {87DB03B5-ED25-46DE-9541-75F17A618005}.Release|Any CPU.ActiveCfg = Release|Any CPU 25 | {87DB03B5-ED25-46DE-9541-75F17A618005}.Release|Any CPU.Build.0 = Release|Any CPU 26 | {D276249E-1E3F-4B27-ADB2-53C1D70C161D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 27 | {D276249E-1E3F-4B27-ADB2-53C1D70C161D}.Debug|Any CPU.Build.0 = Debug|Any CPU 28 | {D276249E-1E3F-4B27-ADB2-53C1D70C161D}.Release|Any CPU.ActiveCfg = Release|Any CPU 29 | {D276249E-1E3F-4B27-ADB2-53C1D70C161D}.Release|Any CPU.Build.0 = Release|Any CPU 30 | EndGlobalSection 31 | GlobalSection(SolutionProperties) = preSolution 32 | HideSolutionNode = FALSE 33 | EndGlobalSection 34 | GlobalSection(ExtensibilityGlobals) = postSolution 35 | SolutionGuid = {A1E52D45-E40F-4333-B9E7-26450C8A2C7C} 36 | EndGlobalSection 37 | EndGlobal 38 | -------------------------------------------------------------------------------- /BlazorWasmGraphQL/Client/Shared/AppStateContainer.cs: -------------------------------------------------------------------------------- 1 | using BlazorWasmGraphQL.Client.GraphQLAPIClient; 2 | using BlazorWasmGraphQL.Server.Models; 3 | 4 | namespace BlazorWasmGraphQL.Client.Shared 5 | { 6 | public class AppStateContainer 7 | { 8 | private readonly MovieClient _movieClient; 9 | 10 | public AppStateContainer(MovieClient movieClient) 11 | { 12 | _movieClient = movieClient; 13 | } 14 | 15 | public List userWatchlist = new(); 16 | 17 | public List AvailableGenre = new(); 18 | 19 | public event Action OnAppStateChange = default!; 20 | 21 | public async Task GetAvailableGenre() 22 | { 23 | var results = await _movieClient.FetchGenreList.ExecuteAsync(); 24 | 25 | if (results.Data is not null) 26 | { 27 | AvailableGenre = results.Data.GenreList.Select(x => new Genre 28 | { 29 | GenreId = x.GenreId, 30 | GenreName = x.GenreName, 31 | }).ToList(); 32 | } 33 | } 34 | 35 | public async Task GetUserWatchlist(int userId) 36 | { 37 | List currentUserWatchlist = new(); 38 | 39 | if (userId > 0) 40 | { 41 | var response = await _movieClient.FetchWatchList.ExecuteAsync(userId); 42 | 43 | if (response.Data is not null) 44 | { 45 | currentUserWatchlist = response.Data.Watchlist.Select(x => new Movie 46 | { 47 | MovieId = x.MovieId, 48 | Title = x.Title, 49 | Duration = x.Duration, 50 | Genre = x.Genre, 51 | Language = x.Language, 52 | PosterPath = x.PosterPath, 53 | Rating = x.Rating, 54 | }).ToList(); 55 | } 56 | } 57 | 58 | SetUserWatchlist(currentUserWatchlist); 59 | } 60 | 61 | public void SetUserWatchlist(List lstMovie) 62 | { 63 | userWatchlist = lstMovie; 64 | NotifyAppStateChanged(); 65 | } 66 | 67 | private void NotifyAppStateChanged() => OnAppStateChange?.Invoke(); 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /BlazorWasmGraphQL/Client/Pages/Registration.razor.cs: -------------------------------------------------------------------------------- 1 | using BlazorWasmGraphQL.Client.GraphQLAPIClient; 2 | using BlazorWasmGraphQL.Client.Shared; 3 | using BlazorWasmGraphQL.Shared.Dto; 4 | using Microsoft.AspNetCore.Components; 5 | 6 | namespace BlazorWasmGraphQL.Client.Pages 7 | { 8 | public class RegistrationBase : ComponentBase 9 | { 10 | [Inject] 11 | public NavigationManager NavigationManager { get; set; } = default!; 12 | 13 | [Inject] 14 | MovieClient MovieClient { get; set; } = default!; 15 | 16 | [Inject] 17 | ILogger Logger { get; set; } = default!; 18 | 19 | protected UserRegistration registration = new(); 20 | 21 | protected CustomValidator registerValidator; 22 | 23 | protected async Task RegisterUser() 24 | { 25 | registerValidator.ClearErrors(); 26 | 27 | try 28 | { 29 | UserRegistrationInput registrationData = new() 30 | { 31 | FirstName = registration.FirstName, 32 | LastName = registration.LastName, 33 | Username = registration.Username, 34 | Password = registration.Password, 35 | ConfirmPassword = registration.ConfirmPassword, 36 | Gender = registration.Gender, 37 | }; 38 | 39 | var response = await MovieClient.RegisterUser.ExecuteAsync(registrationData); 40 | 41 | if (response.Data is not null) 42 | { 43 | RegistrationResponse RegistrationStatus = new() 44 | { 45 | IsRegistrationSuccess = response.Data.UserRegistration.IsRegistrationSuccess, 46 | ErrorMessage = response.Data.UserRegistration.ErrorMessage 47 | }; 48 | 49 | if (!RegistrationStatus.IsRegistrationSuccess) 50 | { 51 | registerValidator.DisplayErrors(nameof(registration.Username), RegistrationStatus.ErrorMessage); 52 | throw new HttpRequestException($"User registration failed. Status Code: 403 Forbidden"); 53 | } 54 | else 55 | { 56 | NavigationManager.NavigateTo("/login"); 57 | } 58 | } 59 | } 60 | catch (Exception ex) 61 | { 62 | Logger.LogError(ex.Message); 63 | } 64 | } 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /BlazorWasmGraphQL/Client/Pages/ManageMovies.razor.cs: -------------------------------------------------------------------------------- 1 | using BlazorWasmGraphQL.Client.GraphQLAPIClient; 2 | using BlazorWasmGraphQL.Server.Models; 3 | using BlazorWasmGraphQL.Shared.Models; 4 | using Microsoft.AspNetCore.Authorization; 5 | using Microsoft.AspNetCore.Components; 6 | using Microsoft.AspNetCore.Components.Authorization; 7 | 8 | namespace BlazorWasmGraphQL.Client.Pages 9 | { 10 | public class ManageMoviesBase : ComponentBase 11 | { 12 | [Inject] 13 | MovieClient MovieClient { get; set; } = default!; 14 | 15 | [Inject] 16 | IAuthorizationService AuthService { get; set; } = default!; 17 | 18 | [Inject] 19 | public NavigationManager NavigationManager { get; set; } = default!; 20 | 21 | [CascadingParameter] 22 | public Task AuthenticationState { get; set; } = default!; 23 | 24 | protected List? lstMovie = new(); 25 | protected Movie? movie = new(); 26 | 27 | protected override async Task OnInitializedAsync() 28 | { 29 | var authState = await AuthenticationState; 30 | var CheckAdminPolicy = await AuthService.AuthorizeAsync(authState.User, Policies.AdminPolicy()); 31 | 32 | if (CheckAdminPolicy.Succeeded) 33 | { 34 | await GetMovieList(); 35 | } 36 | else 37 | { 38 | NavigationManager.NavigateTo($"login?returnUrl={Uri.EscapeDataString(NavigationManager.Uri)}"); 39 | } 40 | } 41 | 42 | protected async Task GetMovieList() 43 | { 44 | var results = await MovieClient.FetchMovieList.ExecuteAsync(); 45 | 46 | lstMovie = results?.Data?.MovieList.Select(x => new Movie 47 | { 48 | MovieId = x.MovieId, 49 | Title = x.Title, 50 | Duration = x.Duration, 51 | Genre = x.Genre, 52 | Language = x.Language, 53 | PosterPath = x.PosterPath, 54 | Rating = x.Rating, 55 | }).ToList(); 56 | } 57 | 58 | protected void DeleteConfirm(int movieID) 59 | { 60 | movie = lstMovie?.FirstOrDefault(x => x.MovieId == movieID); 61 | } 62 | 63 | protected async Task DeleteMovie(int movieID) 64 | { 65 | var response = await MovieClient.DeleteMovieData.ExecuteAsync(movieID); 66 | 67 | if (response.Data is not null) 68 | { 69 | await GetMovieList(); 70 | AddToWatchlistBase.ToastObj.Show(AddToWatchlistBase.Toast[2]); 71 | } 72 | } 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /BlazorWasmGraphQL/Server/DataAccess/WatchlistDataAccessLayer.cs: -------------------------------------------------------------------------------- 1 | using BlazorWasmGraphQL.Server.Interfaces; 2 | using BlazorWasmGraphQL.Server.Models; 3 | using Microsoft.EntityFrameworkCore; 4 | 5 | namespace BlazorWasmGraphQL.Server.DataAccess 6 | { 7 | public class WatchlistDataAccessLayer : IWatchlist 8 | { 9 | readonly MovieDBContext _dbContext; 10 | 11 | public WatchlistDataAccessLayer(IDbContextFactory dbContext) 12 | { 13 | _dbContext = dbContext.CreateDbContext(); 14 | } 15 | 16 | string CreateWatchlist(int userId) 17 | { 18 | try 19 | { 20 | Watchlist watchlist = new() 21 | { 22 | WatchlistId = Guid.NewGuid().ToString(), 23 | UserId = userId, 24 | DateCreated = DateTime.Now.Date 25 | }; 26 | 27 | _dbContext.Watchlists.Add(watchlist); 28 | _dbContext.SaveChanges(); 29 | 30 | return watchlist.WatchlistId; 31 | } 32 | catch 33 | { 34 | throw; 35 | } 36 | } 37 | 38 | public async Task GetWatchlistId(int userId) 39 | { 40 | try 41 | { 42 | Watchlist? watchlist = await _dbContext.Watchlists.FirstOrDefaultAsync(x => x.UserId == userId); 43 | 44 | if (watchlist is not null) 45 | { 46 | return watchlist.WatchlistId; 47 | } 48 | else 49 | { 50 | return CreateWatchlist(userId); 51 | } 52 | 53 | } 54 | catch 55 | { 56 | throw; 57 | } 58 | } 59 | 60 | public async Task ToggleWatchlistItem(int userId, int movieId) 61 | { 62 | string watchlistId = await GetWatchlistId(userId); 63 | 64 | WatchlistItem? existingWatchlistItem = await _dbContext.WatchlistItems 65 | .FirstOrDefaultAsync(x => x.MovieId == movieId && x.WatchlistId == watchlistId); 66 | 67 | if (existingWatchlistItem is not null) 68 | { 69 | _dbContext.WatchlistItems.Remove(existingWatchlistItem); 70 | } 71 | else 72 | { 73 | WatchlistItem watchlistItem = new() 74 | { 75 | WatchlistId = watchlistId, 76 | MovieId = movieId, 77 | }; 78 | 79 | _dbContext.WatchlistItems.Add(watchlistItem); 80 | } 81 | await _dbContext.SaveChangesAsync(); 82 | } 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /BlazorWasmGraphQL/Client/Pages/Home.razor.cs: -------------------------------------------------------------------------------- 1 | using BlazorWasmGraphQL.Client.GraphQLAPIClient; 2 | using BlazorWasmGraphQL.Server.Models; 3 | using Microsoft.AspNetCore.Components; 4 | 5 | namespace BlazorWasmGraphQL.Client.Pages 6 | { 7 | public class HomeBase : ComponentBase 8 | { 9 | [Parameter] 10 | public string GenreName { get; set; } = default!; 11 | 12 | [Inject] 13 | MovieClient MovieClient { get; set; } = default!; 14 | 15 | protected List lstMovie = new(); 16 | protected List filteredMovie = new(); 17 | 18 | protected override async Task OnInitializedAsync() 19 | { 20 | MovieSortInput initialSort = new() { Title = SortEnumType.Asc }; 21 | 22 | await GetMovieList(initialSort); 23 | } 24 | 25 | protected override void OnParametersSet() 26 | { 27 | FilterMovie(); 28 | } 29 | 30 | async Task GetMovieList(MovieSortInput sortInput) 31 | { 32 | var results = await MovieClient.SortMovieList.ExecuteAsync(sortInput); 33 | 34 | if (results.Data is not null) 35 | { 36 | lstMovie = results.Data.MovieList.Select(x => new Movie 37 | { 38 | MovieId = x.MovieId, 39 | Title = x.Title, 40 | Duration = x.Duration, 41 | Genre = x.Genre, 42 | Language = x.Language, 43 | PosterPath = x.PosterPath, 44 | Rating = x.Rating, 45 | }).ToList(); 46 | } 47 | 48 | filteredMovie = lstMovie; 49 | } 50 | 51 | void FilterMovie() 52 | { 53 | if (!string.IsNullOrEmpty(GenreName)) 54 | { 55 | lstMovie = filteredMovie.Where(m => m.Genre == GenreName).ToList(); 56 | } 57 | else 58 | { 59 | lstMovie = filteredMovie; 60 | } 61 | } 62 | 63 | protected async Task SortMovieData(ChangeEventArgs e) 64 | { 65 | switch (e.Value?.ToString()) 66 | { 67 | case "title": 68 | MovieSortInput titleSort = new() { Title = SortEnumType.Asc }; 69 | await GetMovieList(titleSort); 70 | break; 71 | 72 | case "rating": 73 | MovieSortInput ratingSort = new() { Rating = SortEnumType.Desc }; 74 | await GetMovieList(ratingSort); 75 | break; 76 | 77 | case "duration": 78 | MovieSortInput durationSort = new() { Duration = SortEnumType.Desc }; 79 | await GetMovieList(durationSort); 80 | break; 81 | } 82 | } 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /BlazorWasmGraphQL/Server/DataAccess/UserDataAccessLayer.cs: -------------------------------------------------------------------------------- 1 | using BlazorWasmGraphQL.Server.Interfaces; 2 | using BlazorWasmGraphQL.Server.Models; 3 | using BlazorWasmGraphQL.Shared.Dto; 4 | using Microsoft.EntityFrameworkCore; 5 | 6 | namespace BlazorWasmGraphQL.Server.DataAccess 7 | { 8 | public class UserDataAccessLayer : IUser 9 | { 10 | readonly MovieDBContext _dbContext; 11 | 12 | public UserDataAccessLayer(IDbContextFactory dbContext) 13 | { 14 | _dbContext = dbContext.CreateDbContext(); 15 | } 16 | 17 | public AuthenticatedUser AuthenticateUser(UserLogin loginCredentials) 18 | { 19 | AuthenticatedUser authenticatedUser = new(); 20 | 21 | var userDetails = _dbContext.UserMasters 22 | .FirstOrDefault(u => 23 | u.Username == loginCredentials.Username && 24 | u.Password == loginCredentials.Password); 25 | 26 | if (userDetails != null) 27 | { 28 | authenticatedUser = new AuthenticatedUser 29 | { 30 | Username = userDetails.Username, 31 | UserId = userDetails.UserId, 32 | UserTypeName = userDetails.UserTypeName 33 | }; 34 | } 35 | return authenticatedUser; 36 | } 37 | 38 | public async Task IsUserExists(int userId) 39 | { 40 | UserMaster? user = await _dbContext.UserMasters.FirstOrDefaultAsync(x => x.UserId == userId); 41 | 42 | if (user is not null) 43 | { 44 | return true; 45 | } 46 | else 47 | { 48 | return false; 49 | } 50 | } 51 | 52 | public async Task RegisterUser(UserMaster userData) 53 | { 54 | bool isUserNameAvailable = CheckUserNameAvailability(userData.Username); 55 | 56 | try 57 | { 58 | if (isUserNameAvailable) 59 | { 60 | await _dbContext.UserMasters.AddAsync(userData); 61 | await _dbContext.SaveChangesAsync(); 62 | return true; 63 | } 64 | else 65 | { 66 | return false; 67 | } 68 | } 69 | catch 70 | { 71 | throw; 72 | } 73 | } 74 | 75 | bool CheckUserNameAvailability(string userName) 76 | { 77 | string? user = _dbContext.UserMasters.FirstOrDefault(x => x.Username == userName)?.ToString(); 78 | 79 | if (user is not null) 80 | { 81 | return false; 82 | } 83 | else 84 | { 85 | return true; 86 | } 87 | } 88 | } 89 | } 90 | -------------------------------------------------------------------------------- /BlazorWasmGraphQL/Client/CustomAuthStateProvider.cs: -------------------------------------------------------------------------------- 1 | using Blazored.LocalStorage; 2 | using BlazorWasmGraphQL.Client.Shared; 3 | using Microsoft.AspNetCore.Components.Authorization; 4 | using System.Security.Claims; 5 | using System.Text.Json; 6 | 7 | namespace BlazorWasmGraphQL.Client 8 | { 9 | public class CustomAuthStateProvider : AuthenticationStateProvider 10 | { 11 | private readonly ILocalStorageService _localStorage; 12 | private readonly AuthenticationState _anonymousUser; 13 | private readonly AppStateContainer _appStateContainer; 14 | 15 | public CustomAuthStateProvider(ILocalStorageService localStorage, AppStateContainer appStateContainer) 16 | { 17 | _localStorage = localStorage; 18 | _anonymousUser = new AuthenticationState(new ClaimsPrincipal(new ClaimsIdentity())); 19 | _appStateContainer = appStateContainer; 20 | } 21 | 22 | public override async Task GetAuthenticationStateAsync() 23 | { 24 | await _appStateContainer.GetAvailableGenre(); 25 | AuthToken.TokenValue = await _localStorage.GetItemAsync(AuthToken.TokenIdentifier); 26 | 27 | if (string.IsNullOrWhiteSpace(AuthToken.TokenValue)) 28 | { 29 | return _anonymousUser; 30 | } 31 | 32 | List? userClaims = ParseClaimsFromJwt(AuthToken.TokenValue).ToList(); 33 | int UserId = Convert.ToInt32(userClaims.Find(claim => claim.Type == "userId")!.Value); 34 | 35 | if (UserId > 0) 36 | { 37 | await _appStateContainer.GetUserWatchlist(UserId); 38 | } 39 | return new AuthenticationState(new ClaimsPrincipal(new ClaimsIdentity(userClaims, "BlazorClientAuth"))); 40 | } 41 | 42 | public void NotifyAuthState() 43 | { 44 | NotifyAuthenticationStateChanged(GetAuthenticationStateAsync()); 45 | } 46 | 47 | static IEnumerable ParseClaimsFromJwt(string jwt) 48 | { 49 | var claims = new List(); 50 | var payload = jwt.Split('.')[1]; 51 | 52 | var jsonBytes = ParseBase64WithoutPadding(payload); 53 | 54 | var keyValuePairs = JsonSerializer.Deserialize>(jsonBytes); 55 | 56 | if (keyValuePairs is not null) 57 | { 58 | claims.AddRange(keyValuePairs.Select(kvp => new Claim(kvp.Key, kvp.Value.ToString()))); 59 | } 60 | 61 | return claims; 62 | } 63 | 64 | static byte[] ParseBase64WithoutPadding(string base64) 65 | { 66 | switch (base64.Length % 4) 67 | { 68 | case 2: base64 += "=="; break; 69 | case 3: base64 += "="; break; 70 | } 71 | return Convert.FromBase64String(base64); 72 | } 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /BlazorWasmGraphQL/Client/Pages/Login.razor.cs: -------------------------------------------------------------------------------- 1 | using Blazored.LocalStorage; 2 | using BlazorWasmGraphQL.Client.GraphQLAPIClient; 3 | using BlazorWasmGraphQL.Client.Shared; 4 | using BlazorWasmGraphQL.Shared.Dto; 5 | using Microsoft.AspNetCore.Components; 6 | 7 | namespace BlazorWasmGraphQL.Client.Pages 8 | { 9 | public class LoginBase : ComponentBase 10 | { 11 | [Parameter] 12 | [SupplyParameterFromQuery] 13 | public string returnUrl { get; set; } = default!; 14 | 15 | [Inject] 16 | NavigationManager NavigationManager { get; set; } = default!; 17 | 18 | [Inject] 19 | CustomAuthStateProvider CustomAuthStateProvider { get; set; } = default!; 20 | 21 | [Inject] 22 | MovieClient MovieClient { get; set; } = default!; 23 | 24 | [Inject] 25 | ILocalStorageService LocalStorageService { get; set; } = default!; 26 | 27 | [Inject] 28 | ILogger Logger { get; set; } = default!; 29 | 30 | string _returnUrl = "/"; 31 | protected UserLogin login = new(); 32 | protected CustomValidator customValidator; 33 | 34 | protected override void OnInitialized() 35 | { 36 | if (returnUrl is not null) 37 | { 38 | _returnUrl = returnUrl; 39 | } 40 | } 41 | 42 | protected async Task AuthenticateUser() 43 | { 44 | customValidator.ClearErrors(); 45 | 46 | try 47 | { 48 | UserLoginInput loginData = new() 49 | { 50 | Password = login.Password, 51 | Username = login.Username, 52 | }; 53 | 54 | var response = await MovieClient.Login.ExecuteAsync(loginData); 55 | 56 | if (response.Data is not null) 57 | { 58 | AuthResponse authResponse = new() 59 | { 60 | ErrorMessage = response.Data.UserLogin.ErrorMessage, 61 | Token = response.Data.UserLogin.Token 62 | }; 63 | 64 | if (authResponse.ErrorMessage is not null) 65 | { 66 | customValidator.DisplayErrors(nameof(login.Username), authResponse.ErrorMessage); 67 | throw new HttpRequestException($"User validation failed. Status Code: 401 Unauthorized"); 68 | } 69 | else 70 | { 71 | await LocalStorageService.SetItemAsync(AuthToken.TokenIdentifier, authResponse.Token); 72 | CustomAuthStateProvider.NotifyAuthState(); 73 | NavigationManager.NavigateTo(_returnUrl); 74 | } 75 | } 76 | } 77 | catch (Exception ex) 78 | { 79 | Logger.LogError(ex.Message); 80 | } 81 | } 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /BlazorWasmGraphQL/Client/wwwroot/css/app.css: -------------------------------------------------------------------------------- 1 | @import url('open-iconic/font/css/open-iconic-bootstrap.min.css'); 2 | 3 | html, body { 4 | font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; 5 | } 6 | 7 | h1:focus { 8 | outline: none; 9 | } 10 | 11 | a, .btn-link { 12 | color: #0071c1; 13 | } 14 | 15 | .btn-primary { 16 | color: #fff; 17 | background-color: #1b6ec2; 18 | border-color: #1861ac; 19 | } 20 | 21 | .content { 22 | padding-top: 1.1rem; 23 | } 24 | 25 | .valid.modified:not([type=checkbox]) { 26 | outline: 1px solid #26b050; 27 | } 28 | 29 | .invalid { 30 | outline: 1px solid red; 31 | } 32 | 33 | .validation-message { 34 | color: red; 35 | } 36 | 37 | #blazor-error-ui { 38 | background: lightyellow; 39 | bottom: 0; 40 | box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2); 41 | display: none; 42 | left: 0; 43 | padding: 0.6rem 1.25rem 0.7rem 1.25rem; 44 | position: fixed; 45 | width: 100%; 46 | z-index: 1000; 47 | } 48 | 49 | #blazor-error-ui .dismiss { 50 | cursor: pointer; 51 | position: absolute; 52 | right: 0.75rem; 53 | top: 0.5rem; 54 | } 55 | 56 | .blazor-error-boundary { 57 | background: url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTYiIGhlaWdodD0iNDkiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIG92ZXJmbG93PSJoaWRkZW4iPjxkZWZzPjxjbGlwUGF0aCBpZD0iY2xpcDAiPjxyZWN0IHg9IjIzNSIgeT0iNTEiIHdpZHRoPSI1NiIgaGVpZ2h0PSI0OSIvPjwvY2xpcFBhdGg+PC9kZWZzPjxnIGNsaXAtcGF0aD0idXJsKCNjbGlwMCkiIHRyYW5zZm9ybT0idHJhbnNsYXRlKC0yMzUgLTUxKSI+PHBhdGggZD0iTTI2My41MDYgNTFDMjY0LjcxNyA1MSAyNjUuODEzIDUxLjQ4MzcgMjY2LjYwNiA1Mi4yNjU4TDI2Ny4wNTIgNTIuNzk4NyAyNjcuNTM5IDUzLjYyODMgMjkwLjE4NSA5Mi4xODMxIDI5MC41NDUgOTIuNzk1IDI5MC42NTYgOTIuOTk2QzI5MC44NzcgOTMuNTEzIDI5MSA5NC4wODE1IDI5MSA5NC42NzgyIDI5MSA5Ny4wNjUxIDI4OS4wMzggOTkgMjg2LjYxNyA5OUwyNDAuMzgzIDk5QzIzNy45NjMgOTkgMjM2IDk3LjA2NTEgMjM2IDk0LjY3ODIgMjM2IDk0LjM3OTkgMjM2LjAzMSA5NC4wODg2IDIzNi4wODkgOTMuODA3MkwyMzYuMzM4IDkzLjAxNjIgMjM2Ljg1OCA5Mi4xMzE0IDI1OS40NzMgNTMuNjI5NCAyNTkuOTYxIDUyLjc5ODUgMjYwLjQwNyA1Mi4yNjU4QzI2MS4yIDUxLjQ4MzcgMjYyLjI5NiA1MSAyNjMuNTA2IDUxWk0yNjMuNTg2IDY2LjAxODNDMjYwLjczNyA2Ni4wMTgzIDI1OS4zMTMgNjcuMTI0NSAyNTkuMzEzIDY5LjMzNyAyNTkuMzEzIDY5LjYxMDIgMjU5LjMzMiA2OS44NjA4IDI1OS4zNzEgNzAuMDg4N0wyNjEuNzk1IDg0LjAxNjEgMjY1LjM4IDg0LjAxNjEgMjY3LjgyMSA2OS43NDc1QzI2Ny44NiA2OS43MzA5IDI2Ny44NzkgNjkuNTg3NyAyNjcuODc5IDY5LjMxNzkgMjY3Ljg3OSA2Ny4xMTgyIDI2Ni40NDggNjYuMDE4MyAyNjMuNTg2IDY2LjAxODNaTTI2My41NzYgODYuMDU0N0MyNjEuMDQ5IDg2LjA1NDcgMjU5Ljc4NiA4Ny4zMDA1IDI1OS43ODYgODkuNzkyMSAyNTkuNzg2IDkyLjI4MzcgMjYxLjA0OSA5My41Mjk1IDI2My41NzYgOTMuNTI5NSAyNjYuMTE2IDkzLjUyOTUgMjY3LjM4NyA5Mi4yODM3IDI2Ny4zODcgODkuNzkyMSAyNjcuMzg3IDg3LjMwMDUgMjY2LjExNiA4Ni4wNTQ3IDI2My41NzYgODYuMDU0N1oiIGZpbGw9IiNGRkU1MDAiIGZpbGwtcnVsZT0iZXZlbm9kZCIvPjwvZz48L3N2Zz4=) no-repeat 1rem/1.8rem, #b32121; 58 | padding: 1rem 1rem 1rem 3.7rem; 59 | color: white; 60 | } 61 | 62 | .blazor-error-boundary::after { 63 | content: "An error has occurred." 64 | } 65 | -------------------------------------------------------------------------------- /BlazorWasmGraphQL/Server/GraphQL/AuthMutationResolver.cs: -------------------------------------------------------------------------------- 1 | using BlazorWasmGraphQL.Server.Interfaces; 2 | using BlazorWasmGraphQL.Server.Models; 3 | using BlazorWasmGraphQL.Shared.Dto; 4 | using BlazorWasmGraphQL.Shared.Models; 5 | using Microsoft.IdentityModel.Tokens; 6 | using System.IdentityModel.Tokens.Jwt; 7 | using System.Security.Claims; 8 | using System.Text; 9 | 10 | namespace BlazorWasmGraphQL.Server.GraphQL 11 | { 12 | [ExtendObjectType(typeof(MovieMutationResolver))] 13 | public class AuthMutationResolver 14 | { 15 | readonly IUser _userService; 16 | readonly IConfiguration _config; 17 | 18 | public AuthMutationResolver(IConfiguration config, IUser userService) 19 | { 20 | _config = config; 21 | _userService = userService; 22 | } 23 | 24 | 25 | [GraphQLDescription("Authenticate the user.")] 26 | public AuthResponse UserLogin(UserLogin userDetails) 27 | { 28 | AuthenticatedUser authenticatedUser = _userService.AuthenticateUser(userDetails); 29 | 30 | if (!string.IsNullOrEmpty(authenticatedUser.Username)) 31 | { 32 | string tokenString = GenerateJWT(authenticatedUser); 33 | 34 | return new AuthResponse { Token = tokenString }; 35 | } 36 | 37 | else 38 | { 39 | return new AuthResponse { ErrorMessage = "Username or Password is incorrect." }; 40 | } 41 | } 42 | 43 | [GraphQLDescription("Register a new user.")] 44 | public async Task UserRegistration(UserRegistration registrationData) 45 | { 46 | UserMaster user = new() 47 | { 48 | FirstName = registrationData.FirstName, 49 | LastName = registrationData.LastName, 50 | Username = registrationData.Username, 51 | Password = registrationData.Password, 52 | Gender = registrationData.Gender, 53 | UserTypeName = UserRoles.User 54 | }; 55 | 56 | bool userRegistrationStatus = await _userService.RegisterUser(user); 57 | 58 | if (userRegistrationStatus) 59 | { 60 | return new RegistrationResponse { IsRegistrationSuccess = true }; 61 | } 62 | else 63 | { 64 | return new RegistrationResponse { IsRegistrationSuccess = false, ErrorMessage = "This User Name is not available." }; 65 | } 66 | } 67 | 68 | string GenerateJWT(AuthenticatedUser userInfo) 69 | { 70 | var securityKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(_config["Jwt:SecretKey"])); 71 | var credentials = new SigningCredentials(securityKey, SecurityAlgorithms.HmacSha256); 72 | 73 | List userClaims = new() 74 | { 75 | new Claim(ClaimTypes.Name, userInfo.Username), 76 | new Claim("userId", userInfo.UserId.ToString()), 77 | new Claim(ClaimTypes.Role, userInfo.UserTypeName), 78 | }; 79 | 80 | var token = new JwtSecurityToken( 81 | issuer: _config["Jwt:Issuer"], 82 | audience: _config["Jwt:Audience"], 83 | claims: userClaims, 84 | expires: DateTime.Now.AddHours(24), 85 | signingCredentials: credentials 86 | ); 87 | 88 | return new JwtSecurityTokenHandler().WriteToken(token); 89 | } 90 | } 91 | } 92 | -------------------------------------------------------------------------------- /BlazorWasmGraphQL/Server/Program.cs: -------------------------------------------------------------------------------- 1 | using BlazorWasmGraphQL.Server.DataAccess; 2 | using BlazorWasmGraphQL.Server.GraphQL; 3 | using BlazorWasmGraphQL.Server.Interfaces; 4 | using BlazorWasmGraphQL.Server.Models; 5 | using BlazorWasmGraphQL.Shared.Models; 6 | using Microsoft.AspNetCore.Authentication.JwtBearer; 7 | using Microsoft.EntityFrameworkCore; 8 | using Microsoft.Extensions.FileProviders; 9 | using Microsoft.IdentityModel.Tokens; 10 | using System.Text; 11 | 12 | var builder = WebApplication.CreateBuilder(args); 13 | 14 | // Add services to the container. 15 | 16 | builder.Services.AddControllersWithViews(); 17 | builder.Services.AddRazorPages(); 18 | 19 | builder.Services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme) 20 | .AddJwtBearer(options => 21 | { 22 | options.RequireHttpsMetadata = false; 23 | options.SaveToken = true; 24 | options.TokenValidationParameters = new TokenValidationParameters 25 | { 26 | ValidateIssuer = true, 27 | ValidateAudience = true, 28 | ValidateLifetime = true, 29 | ValidateIssuerSigningKey = true, 30 | ValidIssuer = builder.Configuration["Jwt:Issuer"], 31 | ValidAudience = builder.Configuration["Jwt:Audience"], 32 | IssuerSigningKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(builder.Configuration["Jwt:SecretKey"])), 33 | }; 34 | }); 35 | 36 | builder.Services.AddAuthorization(config => 37 | { 38 | config.AddPolicy(UserRoles.Admin, Policies.AdminPolicy()); 39 | config.AddPolicy(UserRoles.User, Policies.UserPolicy()); 40 | }); 41 | 42 | builder.Services.AddPooledDbContextFactory 43 | (options => 44 | options.UseSqlServer(builder.Configuration.GetConnectionString("DefaultConnection"))); 45 | 46 | // Add Service injection here 47 | builder.Services.AddScoped(); 48 | builder.Services.AddScoped(); 49 | builder.Services.AddScoped(); 50 | 51 | builder.Services.AddGraphQLServer() 52 | .AddAuthorization() 53 | .AddQueryType() 54 | .AddMutationType() 55 | .AddTypeExtension() 56 | .AddTypeExtension() 57 | .AddFiltering() 58 | .AddSorting(); 59 | 60 | var app = builder.Build(); 61 | 62 | // Configure the HTTP request pipeline. 63 | if (app.Environment.IsDevelopment()) 64 | { 65 | app.UseWebAssemblyDebugging(); 66 | } 67 | else 68 | { 69 | app.UseExceptionHandler("/Error"); 70 | // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. 71 | app.UseHsts(); 72 | } 73 | 74 | app.UseHttpsRedirection(); 75 | 76 | app.UseBlazorFrameworkFiles(); 77 | app.UseStaticFiles(); 78 | 79 | var FileProviderPath = app.Environment.ContentRootPath + "/Poster"; 80 | if (!Directory.Exists(FileProviderPath)) 81 | { 82 | Directory.CreateDirectory(FileProviderPath); 83 | } 84 | 85 | app.UseFileServer(new FileServerOptions 86 | { 87 | FileProvider = new PhysicalFileProvider(FileProviderPath), 88 | RequestPath = "/Poster", 89 | EnableDirectoryBrowsing = true 90 | }); 91 | 92 | app.UseRouting(); 93 | 94 | app.UseAuthentication(); 95 | app.UseAuthorization(); 96 | 97 | app.MapRazorPages(); 98 | app.MapControllers(); 99 | app.UseEndpoints(endpoints => 100 | { 101 | endpoints.MapGraphQL(); 102 | }); 103 | app.MapFallbackToFile("index.html"); 104 | 105 | app.Run(); 106 | -------------------------------------------------------------------------------- /BlazorWasmGraphQL/Server/GraphQL/MovieMutationResolver.cs: -------------------------------------------------------------------------------- 1 | using BlazorWasmGraphQL.Server.Interfaces; 2 | using BlazorWasmGraphQL.Server.Models; 3 | using BlazorWasmGraphQL.Shared.Models; 4 | using HotChocolate.AspNetCore.Authorization; 5 | 6 | namespace BlazorWasmGraphQL.Server.GraphQL 7 | { 8 | public class MovieMutationResolver 9 | { 10 | public record AddMoviePayload(Movie movie); 11 | 12 | readonly IWebHostEnvironment _hostingEnvironment; 13 | readonly IMovie _movieService; 14 | readonly IConfiguration _config; 15 | readonly string posterFolderPath = string.Empty; 16 | 17 | public MovieMutationResolver(IConfiguration config, IMovie movieService, IWebHostEnvironment hostingEnvironment) 18 | { 19 | _config = config; 20 | _movieService = movieService; 21 | _hostingEnvironment = hostingEnvironment; 22 | posterFolderPath = System.IO.Path.Combine(_hostingEnvironment.ContentRootPath, "Poster"); 23 | } 24 | 25 | [Authorize(Policy = UserRoles.Admin)] 26 | [GraphQLDescription("Add a new movie data.")] 27 | public AddMoviePayload AddMovie(Movie movie) 28 | { 29 | if (!string.IsNullOrEmpty(movie.PosterPath)) 30 | { 31 | string fileName = Guid.NewGuid() + ".jpg"; 32 | string fullPath = System.IO.Path.Combine(posterFolderPath, fileName); 33 | 34 | byte[] imageBytes = Convert.FromBase64String(movie.PosterPath); 35 | File.WriteAllBytes(fullPath, imageBytes); 36 | 37 | movie.PosterPath = fileName; 38 | } 39 | else 40 | { 41 | movie.PosterPath = _config["DefaultPoster"]; 42 | } 43 | 44 | _movieService.AddMovie(movie); 45 | 46 | return new AddMoviePayload(movie); 47 | } 48 | 49 | [Authorize(Policy = UserRoles.Admin)] 50 | [GraphQLDescription("Edit an existing movie data.")] 51 | public async Task EditMovie(Movie movie) 52 | { 53 | bool IsBase64String = CheckBase64String(movie.PosterPath); 54 | 55 | if (IsBase64String) 56 | { 57 | string fileName = Guid.NewGuid() + ".jpg"; 58 | string fullPath = System.IO.Path.Combine(posterFolderPath, fileName); 59 | 60 | byte[] imageBytes = Convert.FromBase64String(movie.PosterPath); 61 | File.WriteAllBytes(fullPath, imageBytes); 62 | 63 | movie.PosterPath = fileName; 64 | } 65 | 66 | await _movieService.UpdateMovie(movie); 67 | 68 | return new AddMoviePayload(movie); 69 | } 70 | 71 | [Authorize(Policy = UserRoles.Admin)] 72 | [GraphQLDescription("Delete a movie data.")] 73 | public async Task DeleteMovie(int movieId) 74 | { 75 | string coverFileName = await _movieService.DeleteMovie(movieId); 76 | 77 | if (!string.IsNullOrEmpty(coverFileName) && coverFileName != _config["DefaultPoster"]) 78 | { 79 | string fullPath = System.IO.Path.Combine(posterFolderPath, coverFileName); 80 | if (File.Exists(fullPath)) 81 | { 82 | File.Delete(fullPath); 83 | } 84 | } 85 | return movieId; 86 | } 87 | 88 | static bool CheckBase64String(string base64) 89 | { 90 | Span buffer = new(new byte[base64.Length]); 91 | return Convert.TryFromBase64String(base64, buffer, out int bytesParsed); 92 | } 93 | } 94 | } 95 | -------------------------------------------------------------------------------- /BlazorWasmGraphQL/Client/Pages/ManageMovies.razor: -------------------------------------------------------------------------------- 1 | @page "/admin/movies" 2 | @inherits ManageMoviesBase 3 | 4 |
5 | 11 |
12 | 13 |
14 | 15 | @if (lstMovie?.Count == 0) 16 | { 17 |

Loading...

18 | } 19 | else 20 | { 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | @if (lstMovie is not null) 34 | { 35 | @foreach (var movie in lstMovie) 36 | { 37 | 38 | 39 | 40 | 41 | 42 | 43 | 51 | 52 | } 53 | } 54 | 55 |
TitleGenreLanguageDuration (mins.)RatingActions
@movie.Title@movie.Genre@movie.Language@movie.Duration@movie.Rating 44 | 45 | Edit 46 | 47 | 50 |
56 | 57 | 97 | } -------------------------------------------------------------------------------- /BlazorWasmGraphQL/Client/wwwroot/css/open-iconic/README.md: -------------------------------------------------------------------------------- 1 | [Open Iconic v1.1.1](http://useiconic.com/open) 2 | =========== 3 | 4 | ### Open Iconic is the open source sibling of [Iconic](http://useiconic.com). It is a hyper-legible collection of 223 icons with a tiny footprint—ready to use with Bootstrap and Foundation. [View the collection](http://useiconic.com/open#icons) 5 | 6 | 7 | 8 | ## What's in Open Iconic? 9 | 10 | * 223 icons designed to be legible down to 8 pixels 11 | * Super-light SVG files - 61.8 for the entire set 12 | * SVG sprite—the modern replacement for icon fonts 13 | * Webfont (EOT, OTF, SVG, TTF, WOFF), PNG and WebP formats 14 | * Webfont stylesheets (including versions for Bootstrap and Foundation) in CSS, LESS, SCSS and Stylus formats 15 | * PNG and WebP raster images in 8px, 16px, 24px, 32px, 48px and 64px. 16 | 17 | 18 | ## Getting Started 19 | 20 | #### For code samples and everything else you need to get started with Open Iconic, check out our [Icons](http://useiconic.com/open#icons) and [Reference](http://useiconic.com/open#reference) sections. 21 | 22 | ### General Usage 23 | 24 | #### Using Open Iconic's SVGs 25 | 26 | We like SVGs and we think they're the way to display icons on the web. Since Open Iconic are just basic SVGs, we suggest you display them like you would any other image (don't forget the `alt` attribute). 27 | 28 | ``` 29 | icon name 30 | ``` 31 | 32 | #### Using Open Iconic's SVG Sprite 33 | 34 | Open Iconic also comes in a SVG sprite which allows you to display all the icons in the set with a single request. It's like an icon font, without being a hack. 35 | 36 | Adding an icon from an SVG sprite is a little different than what you're used to, but it's still a piece of cake. *Tip: To make your icons easily style able, we suggest adding a general class to the* `` *tag and a unique class name for each different icon in the* `` *tag.* 37 | 38 | ``` 39 | 40 | 41 | 42 | ``` 43 | 44 | Sizing icons only needs basic CSS. All the icons are in a square format, so just set the `` tag with equal width and height dimensions. 45 | 46 | ``` 47 | .icon { 48 | width: 16px; 49 | height: 16px; 50 | } 51 | ``` 52 | 53 | Coloring icons is even easier. All you need to do is set the `fill` rule on the `` tag. 54 | 55 | ``` 56 | .icon-account-login { 57 | fill: #f00; 58 | } 59 | ``` 60 | 61 | To learn more about SVG Sprites, read [Chris Coyier's guide](http://css-tricks.com/svg-sprites-use-better-icon-fonts/). 62 | 63 | #### Using Open Iconic's Icon Font... 64 | 65 | 66 | ##### …with Bootstrap 67 | 68 | You can find our Bootstrap stylesheets in `font/css/open-iconic-bootstrap.{css, less, scss, styl}` 69 | 70 | 71 | ``` 72 | 73 | ``` 74 | 75 | 76 | ``` 77 | 78 | ``` 79 | 80 | ##### …with Foundation 81 | 82 | You can find our Foundation stylesheets in `font/css/open-iconic-foundation.{css, less, scss, styl}` 83 | 84 | ``` 85 | 86 | ``` 87 | 88 | 89 | ``` 90 | 91 | ``` 92 | 93 | ##### …on its own 94 | 95 | You can find our default stylesheets in `font/css/open-iconic.{css, less, scss, styl}` 96 | 97 | ``` 98 | 99 | ``` 100 | 101 | ``` 102 | 103 | ``` 104 | 105 | 106 | ## License 107 | 108 | ### Icons 109 | 110 | All code (including SVG markup) is under the [MIT License](http://opensource.org/licenses/MIT). 111 | 112 | ### Fonts 113 | 114 | All fonts are under the [SIL Licensed](http://scripts.sil.org/cms/scripts/page.php?item_id=OFL_web). 115 | -------------------------------------------------------------------------------- /BlazorWasmGraphQL/Client/Pages/Registration.razor: -------------------------------------------------------------------------------- 1 | @page "/register" 2 | @inherits RegistrationBase 3 | 4 |
5 |
6 |
7 |
8 |
9 |

User Registration

10 |
11 | Already Registered? 12 | Login 13 |
14 |
15 |
16 |
17 | 18 | 19 | 20 | 21 |
22 | 23 |
24 | 25 | 26 |
27 |
28 | 29 |
30 | 31 |
32 | 33 | 34 |
35 |
36 | 37 |
38 | 39 |
40 | 41 | 42 |
43 |
44 | 45 |
46 | 47 |
48 | 49 | 50 |
51 |
52 | 53 |
54 | 55 |
56 | 57 | 58 |
59 |
60 | 61 |
62 | 63 |
64 | 65 | 66 | 67 | 68 | 69 | 70 |
71 |
72 | 73 |
74 | 75 |
76 |
77 |
78 |
79 |
80 |
-------------------------------------------------------------------------------- /BlazorWasmGraphQL/Server/DataAccess/MovieDataAccessLayer.cs: -------------------------------------------------------------------------------- 1 | using BlazorWasmGraphQL.Server.Interfaces; 2 | using BlazorWasmGraphQL.Server.Models; 3 | using Microsoft.EntityFrameworkCore; 4 | 5 | namespace BlazorWasmGraphQL.Server.DataAccess 6 | { 7 | public class MovieDataAccessLayer : IMovie 8 | { 9 | readonly MovieDBContext _dbContext; 10 | 11 | public MovieDataAccessLayer(IDbContextFactory dbContext) 12 | { 13 | _dbContext = dbContext.CreateDbContext(); 14 | } 15 | 16 | public async Task AddMovie(Movie movie) 17 | { 18 | try 19 | { 20 | await _dbContext.Movies.AddAsync(movie); 21 | await _dbContext.SaveChangesAsync(); 22 | } 23 | catch 24 | { 25 | throw; 26 | } 27 | } 28 | 29 | public async Task DeleteMovie(int movieId) 30 | { 31 | try 32 | { 33 | Movie? movie = await _dbContext.Movies.FindAsync(movieId); 34 | 35 | if (movie is not null) 36 | { 37 | _dbContext.Movies.Remove(movie); 38 | await _dbContext.SaveChangesAsync(); 39 | return movie.PosterPath; 40 | } 41 | 42 | return string.Empty; 43 | } 44 | catch 45 | { 46 | throw; 47 | } 48 | } 49 | 50 | public async Task> GetAllMovies() 51 | { 52 | return await _dbContext.Movies.AsNoTracking().ToListAsync(); 53 | } 54 | async Task GetMovieData(int movieId) 55 | { 56 | try 57 | { 58 | Movie? movie = new(); 59 | 60 | movie = await _dbContext.Movies.FindAsync(movieId); 61 | 62 | if (movie is not null) 63 | { 64 | _dbContext.Entry(movie).State = EntityState.Detached; 65 | } 66 | 67 | return movie; 68 | } 69 | catch 70 | { 71 | throw; 72 | } 73 | } 74 | 75 | public async Task> GetGenre() 76 | { 77 | return await _dbContext.Genres.AsNoTracking().ToListAsync(); 78 | } 79 | 80 | public async Task> GetMoviesAvailableInWatchlist(string watchlistID) 81 | { 82 | try 83 | { 84 | List userWatchlist = new(); 85 | List watchlistItems = 86 | _dbContext.WatchlistItems.Where(x => x.WatchlistId == watchlistID).ToList(); 87 | 88 | foreach (WatchlistItem item in watchlistItems) 89 | { 90 | Movie movie = await GetMovieData(item.MovieId); 91 | if (movie?.MovieId > 0) 92 | { 93 | userWatchlist.Add(movie); 94 | } 95 | } 96 | return userWatchlist; 97 | } 98 | catch 99 | { 100 | throw; 101 | } 102 | } 103 | 104 | public async Task UpdateMovie(Movie movie) 105 | { 106 | try 107 | { 108 | var result = await _dbContext.Movies.FirstOrDefaultAsync(e => e.MovieId == movie.MovieId); 109 | 110 | if (result is not null) 111 | { 112 | result.Title = movie.Title; 113 | result.Genre = movie.Genre; 114 | result.Duration = movie.Duration; 115 | result.PosterPath = movie.PosterPath; 116 | result.Rating = movie.Rating; 117 | result.Overview = movie.Overview; 118 | result.Language = movie.Language; 119 | } 120 | 121 | await _dbContext.SaveChangesAsync(); 122 | } 123 | catch 124 | { 125 | throw; 126 | } 127 | } 128 | } 129 | } 130 | -------------------------------------------------------------------------------- /BlazorWasmGraphQL/Client/wwwroot/css/open-iconic/FONT-LICENSE: -------------------------------------------------------------------------------- 1 | SIL OPEN FONT LICENSE Version 1.1 2 | 3 | Copyright (c) 2014 Waybury 4 | 5 | PREAMBLE 6 | The goals of the Open Font License (OFL) are to stimulate worldwide 7 | development of collaborative font projects, to support the font creation 8 | efforts of academic and linguistic communities, and to provide a free and 9 | open framework in which fonts may be shared and improved in partnership 10 | with others. 11 | 12 | The OFL allows the licensed fonts to be used, studied, modified and 13 | redistributed freely as long as they are not sold by themselves. The 14 | fonts, including any derivative works, can be bundled, embedded, 15 | redistributed and/or sold with any software provided that any reserved 16 | names are not used by derivative works. The fonts and derivatives, 17 | however, cannot be released under any other type of license. The 18 | requirement for fonts to remain under this license does not apply 19 | to any document created using the fonts or their derivatives. 20 | 21 | DEFINITIONS 22 | "Font Software" refers to the set of files released by the Copyright 23 | Holder(s) under this license and clearly marked as such. This may 24 | include source files, build scripts and documentation. 25 | 26 | "Reserved Font Name" refers to any names specified as such after the 27 | copyright statement(s). 28 | 29 | "Original Version" refers to the collection of Font Software components as 30 | distributed by the Copyright Holder(s). 31 | 32 | "Modified Version" refers to any derivative made by adding to, deleting, 33 | or substituting -- in part or in whole -- any of the components of the 34 | Original Version, by changing formats or by porting the Font Software to a 35 | new environment. 36 | 37 | "Author" refers to any designer, engineer, programmer, technical 38 | writer or other person who contributed to the Font Software. 39 | 40 | PERMISSION & CONDITIONS 41 | Permission is hereby granted, free of charge, to any person obtaining 42 | a copy of the Font Software, to use, study, copy, merge, embed, modify, 43 | redistribute, and sell modified and unmodified copies of the Font 44 | Software, subject to the following conditions: 45 | 46 | 1) Neither the Font Software nor any of its individual components, 47 | in Original or Modified Versions, may be sold by itself. 48 | 49 | 2) Original or Modified Versions of the Font Software may be bundled, 50 | redistributed and/or sold with any software, provided that each copy 51 | contains the above copyright notice and this license. These can be 52 | included either as stand-alone text files, human-readable headers or 53 | in the appropriate machine-readable metadata fields within text or 54 | binary files as long as those fields can be easily viewed by the user. 55 | 56 | 3) No Modified Version of the Font Software may use the Reserved Font 57 | Name(s) unless explicit written permission is granted by the corresponding 58 | Copyright Holder. This restriction only applies to the primary font name as 59 | presented to the users. 60 | 61 | 4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font 62 | Software shall not be used to promote, endorse or advertise any 63 | Modified Version, except to acknowledge the contribution(s) of the 64 | Copyright Holder(s) and the Author(s) or with their explicit written 65 | permission. 66 | 67 | 5) The Font Software, modified or unmodified, in part or in whole, 68 | must be distributed entirely under this license, and must not be 69 | distributed under any other license. The requirement for fonts to 70 | remain under this license does not apply to any document created 71 | using the Font Software. 72 | 73 | TERMINATION 74 | This license becomes null and void if any of the above conditions are 75 | not met. 76 | 77 | DISCLAIMER 78 | THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 79 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF 80 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT 81 | OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE 82 | COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 83 | INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL 84 | DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 85 | FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM 86 | OTHER DEALINGS IN THE FONT SOFTWARE. 87 | -------------------------------------------------------------------------------- /BlazorWasmGraphQL/Client/Pages/AddEditMovie.razor: -------------------------------------------------------------------------------- 1 | @page "/admin/movies/new" 2 | @page "/admin/movies/edit/{MovieID:int}" 3 | @inherits AddEditMovieBase 4 | 5 | @using BlazorWasmGraphQL.Shared.Models; 6 | @using Microsoft.AspNetCore.Authorization 7 | 8 | @attribute [Authorize(Policy = UserRoles.Admin)] 9 | 10 |
11 |
12 | 13 |

@Title Movie

14 |
15 | 16 | 17 | 18 | 19 |
20 |
21 |
22 | 23 |
24 | 25 |
26 | 27 |
28 | 29 |
30 | 31 |
32 | 33 | 34 | @if (lstGenre is not null) 35 | { 36 | @foreach (var genre in lstGenre) 37 | { 38 | 39 | } 40 | } 41 | 42 |
43 | 44 |
45 | 46 | 47 |
48 | 49 |
50 | 51 |
52 | 53 |
54 | 55 |
56 | 57 |
58 | 59 |
60 | 61 |
62 | 63 | 64 |
65 | 66 |
67 | 68 |
69 | 70 |
71 | 72 |
73 | 74 |
75 | 76 |
77 | 78 |
79 |
80 |
81 |
82 |
83 | 84 |
85 | 86 |

@status

87 |
88 |
89 |
90 | 91 |
92 | 93 | 94 |
95 |
96 |
97 |
-------------------------------------------------------------------------------- /BlazorWasmGraphQL/Client/GraphQLAPIClient/schema.graphql: -------------------------------------------------------------------------------- 1 | schema { 2 | query: MovieQueryResolver 3 | mutation: MovieMutationResolver 4 | } 5 | 6 | enum ApplyPolicy { 7 | BEFORE_RESOLVER 8 | AFTER_RESOLVER 9 | } 10 | 11 | type MovieQueryResolver { 12 | "Gets the list of genres." 13 | genreList: [Genre!]! 14 | "Gets the list of movies." 15 | movieList(order: [MovieSortInput!] where: MovieFilterInput): [Movie!]! 16 | } 17 | 18 | type MovieMutationResolver { 19 | "Add a new movie data." 20 | addMovie(movie: MovieInput!): AddMoviePayload! 21 | "Edit an existing movie data." 22 | editMovie(movie: MovieInput!): AddMoviePayload! 23 | "Delete a movie data." 24 | deleteMovie(movieId: Int!): Int! 25 | "Authenticate the user." 26 | userLogin(userDetails: UserLoginInput!): AuthResponse! 27 | "Register a new user." 28 | userRegistration(registrationData: UserRegistrationInput!): RegistrationResponse! 29 | "Get the user Watchlist." 30 | watchlist(userId: Int!): [Movie!]! 31 | "Toggle Watchlist item." 32 | toggleWatchlist(userId: Int! movieId: Int!): [Movie!]! 33 | } 34 | 35 | input MovieSortInput { 36 | movieId: SortEnumType 37 | title: SortEnumType 38 | overview: SortEnumType 39 | genre: SortEnumType 40 | language: SortEnumType 41 | duration: SortEnumType 42 | rating: SortEnumType 43 | posterPath: SortEnumType 44 | } 45 | 46 | input MovieFilterInput { 47 | and: [MovieFilterInput!] 48 | or: [MovieFilterInput!] 49 | movieId: ComparableInt32OperationFilterInput 50 | title: StringOperationFilterInput 51 | overview: StringOperationFilterInput 52 | genre: StringOperationFilterInput 53 | language: StringOperationFilterInput 54 | duration: ComparableInt32OperationFilterInput 55 | rating: ComparableDecimalOperationFilterInput 56 | posterPath: StringOperationFilterInput 57 | } 58 | 59 | enum SortEnumType { 60 | ASC 61 | DESC 62 | } 63 | 64 | input ComparableInt32OperationFilterInput { 65 | eq: Int 66 | neq: Int 67 | in: [Int!] 68 | nin: [Int!] 69 | gt: Int 70 | ngt: Int 71 | gte: Int 72 | ngte: Int 73 | lt: Int 74 | nlt: Int 75 | lte: Int 76 | nlte: Int 77 | } 78 | 79 | input StringOperationFilterInput { 80 | and: [StringOperationFilterInput!] 81 | or: [StringOperationFilterInput!] 82 | eq: String 83 | neq: String 84 | contains: String 85 | ncontains: String 86 | in: [String] 87 | nin: [String] 88 | startsWith: String 89 | nstartsWith: String 90 | endsWith: String 91 | nendsWith: String 92 | } 93 | 94 | input ComparableDecimalOperationFilterInput { 95 | eq: Decimal 96 | neq: Decimal 97 | in: [Decimal!] 98 | nin: [Decimal!] 99 | gt: Decimal 100 | ngt: Decimal 101 | gte: Decimal 102 | ngte: Decimal 103 | lt: Decimal 104 | nlt: Decimal 105 | lte: Decimal 106 | nlte: Decimal 107 | } 108 | 109 | input MovieInput { 110 | movieId: Int! 111 | title: String! 112 | overview: String! 113 | genre: String! 114 | language: String! 115 | duration: Int! 116 | rating: Decimal! 117 | posterPath: String 118 | } 119 | 120 | type AddMoviePayload { 121 | movie: Movie! 122 | } 123 | 124 | type Movie { 125 | movieId: Int! 126 | title: String! 127 | overview: String! 128 | genre: String! 129 | language: String! 130 | duration: Int! 131 | rating: Decimal! 132 | posterPath: String 133 | } 134 | 135 | type Genre { 136 | genreId: Int! 137 | genreName: String! 138 | } 139 | 140 | type AuthResponse { 141 | errorMessage: String 142 | token: String 143 | } 144 | 145 | input UserLoginInput { 146 | username: String! 147 | password: String! 148 | } 149 | 150 | type RegistrationResponse { 151 | isRegistrationSuccess: Boolean! 152 | errorMessage: String 153 | } 154 | 155 | input UserRegistrationInput { 156 | firstName: String! 157 | lastName: String! 158 | username: String! 159 | password: String! 160 | confirmPassword: String! 161 | gender: String! 162 | } 163 | 164 | "The built-in `Decimal` scalar type." 165 | scalar Decimal 166 | 167 | directive @authorize("The name of the authorization policy that determines access to the annotated resource." policy: String "Roles that are allowed to access the annotated resource." roles: [String!] "Defines when when the resolver shall be executed.By default the resolver is executed after the policy has determined that the current user is allowed to access the field." apply: ApplyPolicy! = BEFORE_RESOLVER) repeatable on SCHEMA | OBJECT | FIELD_DEFINITION -------------------------------------------------------------------------------- /BlazorWasmGraphQL/Client/Pages/AddToWatchlist.razor.cs: -------------------------------------------------------------------------------- 1 | using Syncfusion.Blazor.Notifications; 2 | using BlazorWasmGraphQL.Client.GraphQLAPIClient; 3 | using BlazorWasmGraphQL.Client.Shared; 4 | using BlazorWasmGraphQL.Server.Models; 5 | using Microsoft.AspNetCore.Components; 6 | using Microsoft.AspNetCore.Components.Authorization; 7 | 8 | namespace BlazorWasmGraphQL.Client.Pages 9 | { 10 | public class AddToWatchlistBase : ComponentBase 11 | { 12 | 13 | [Inject] 14 | AppStateContainer AppStateContainer { get; set; } = default!; 15 | 16 | public static SfToast ToastObj; 17 | 18 | [Inject] 19 | MovieClient MovieClient { get; set; } = default!; 20 | 21 | [Parameter] 22 | public int MovieID { get; set; } 23 | 24 | [Parameter] 25 | public EventCallback WatchListClick { get; set; } 26 | 27 | [CascadingParameter] 28 | Task AuthenticationState { get; set; } = default!; 29 | 30 | List userWatchlist = new(); 31 | protected bool toggle; 32 | protected string buttonText = string.Empty; 33 | 34 | public static List Toast = new List 35 | { 36 | new ToastModel{ Title = "SUCCESS", Content="Movie added to your Watchlist", CssClass="e-toast-success", Timeout=3000, ShowCloseButton=true}, 37 | new ToastModel{ Title = "INFO", Content="Movie removed from your Watchlist", CssClass="e-toast-info", Timeout=3000, ShowCloseButton=true}, 38 | new ToastModel{ Title = "SUCCESS", Content="Movie data is deleted successfully", CssClass="e-toast-success", Timeout=3000, ShowCloseButton=true} 39 | }; 40 | 41 | int UserId { get; set; } 42 | 43 | protected override async Task OnInitializedAsync() 44 | { 45 | AppStateContainer.OnAppStateChange += StateHasChanged; 46 | 47 | var authState = await AuthenticationState; 48 | if (authState.User.Identity is not null && 49 | authState.User.Identity.IsAuthenticated) 50 | { 51 | UserId = Convert.ToInt32(authState.User.FindFirst("userId").Value); 52 | } 53 | } 54 | 55 | protected override void OnParametersSet() 56 | { 57 | userWatchlist = AppStateContainer.userWatchlist; 58 | SetWatchlistStatus(); 59 | } 60 | void SetWatchlistStatus() 61 | { 62 | var favouriteMovie = userWatchlist.Find(m => m.MovieId == MovieID); 63 | 64 | if (favouriteMovie != null) 65 | { 66 | toggle = true; 67 | } 68 | else 69 | { 70 | toggle = false; 71 | } 72 | 73 | SetButtonText(); 74 | } 75 | void SetButtonText() 76 | { 77 | if (toggle) 78 | { 79 | buttonText = "Remove from Watchlist"; 80 | } 81 | else 82 | { 83 | buttonText = "Add to Watchlist"; 84 | } 85 | } 86 | 87 | protected async Task ToggleWatchList() 88 | { 89 | if (UserId > 0) 90 | { 91 | List watchlist = new(); 92 | toggle = !toggle; 93 | SetButtonText(); 94 | 95 | var response = await MovieClient.ToggleWatchList.ExecuteAsync(UserId, MovieID); 96 | 97 | if (response.Data is not null) 98 | { 99 | watchlist = response.Data.ToggleWatchlist.Select(x => new Movie 100 | { 101 | MovieId = x.MovieId, 102 | Title = x.Title, 103 | Duration = x.Duration, 104 | Genre = x.Genre, 105 | Language = x.Language, 106 | PosterPath = x.PosterPath, 107 | Rating = x.Rating, 108 | }).ToList(); 109 | } 110 | 111 | AppStateContainer.SetUserWatchlist(watchlist); 112 | 113 | if (toggle) 114 | { 115 | ToastObj.Show(Toast[0]); 116 | } 117 | else 118 | { 119 | ToastObj.Show(Toast[1]); 120 | } 121 | 122 | await WatchListClick.InvokeAsync(); 123 | } 124 | } 125 | 126 | public void Dispose() 127 | { 128 | AppStateContainer.OnAppStateChange -= StateHasChanged; 129 | } 130 | } 131 | } 132 | -------------------------------------------------------------------------------- /BlazorWasmGraphQL/Server/Models/MovieDBContext.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.EntityFrameworkCore; 2 | 3 | namespace BlazorWasmGraphQL.Server.Models 4 | { 5 | public partial class MovieDBContext : DbContext 6 | { 7 | public MovieDBContext(DbContextOptions options) 8 | : base(options) 9 | { 10 | } 11 | 12 | public virtual DbSet Genres { get; set; } = null!; 13 | public virtual DbSet Movies { get; set; } = null!; 14 | public virtual DbSet UserMasters { get; set; } = null!; 15 | public virtual DbSet UserTypes { get; set; } = null!; 16 | public virtual DbSet Watchlists { get; set; } = null!; 17 | public virtual DbSet WatchlistItems { get; set; } = null!; 18 | 19 | protected override void OnModelCreating(ModelBuilder modelBuilder) 20 | { 21 | modelBuilder.Entity(entity => 22 | { 23 | entity.ToTable("Genre"); 24 | 25 | entity.Property(e => e.GenreId).HasColumnName("GenreID"); 26 | 27 | entity.Property(e => e.GenreName) 28 | .HasMaxLength(20) 29 | .IsUnicode(false); 30 | }); 31 | 32 | modelBuilder.Entity(entity => 33 | { 34 | entity.ToTable("Movie"); 35 | 36 | entity.Property(e => e.MovieId).HasColumnName("MovieID"); 37 | 38 | entity.Property(e => e.Genre) 39 | .HasMaxLength(20) 40 | .IsUnicode(false); 41 | 42 | entity.Property(e => e.Language) 43 | .HasMaxLength(20) 44 | .IsUnicode(false); 45 | 46 | entity.Property(e => e.Overview) 47 | .HasMaxLength(1024) 48 | .IsUnicode(false); 49 | 50 | entity.Property(e => e.PosterPath) 51 | .HasMaxLength(100) 52 | .IsUnicode(false); 53 | 54 | entity.Property(e => e.Rating).HasColumnType("decimal(2, 1)"); 55 | 56 | entity.Property(e => e.Title) 57 | .HasMaxLength(100) 58 | .IsUnicode(false); 59 | }); 60 | 61 | modelBuilder.Entity(entity => 62 | { 63 | entity.HasKey(e => e.UserId) 64 | .HasName("PK__UserMast__1788CCAC5D461970"); 65 | 66 | entity.ToTable("UserMaster"); 67 | 68 | entity.Property(e => e.UserId).HasColumnName("UserID"); 69 | 70 | entity.Property(e => e.FirstName) 71 | .HasMaxLength(20) 72 | .IsUnicode(false); 73 | 74 | entity.Property(e => e.Gender) 75 | .HasMaxLength(6) 76 | .IsUnicode(false); 77 | 78 | entity.Property(e => e.LastName) 79 | .HasMaxLength(20) 80 | .IsUnicode(false); 81 | 82 | entity.Property(e => e.Password) 83 | .HasMaxLength(40) 84 | .IsUnicode(false); 85 | 86 | entity.Property(e => e.UserTypeName) 87 | .HasMaxLength(20) 88 | .IsUnicode(false); 89 | 90 | entity.Property(e => e.Username) 91 | .HasMaxLength(20) 92 | .IsUnicode(false); 93 | }); 94 | 95 | modelBuilder.Entity(entity => 96 | { 97 | entity.ToTable("UserType"); 98 | 99 | entity.Property(e => e.UserTypeId).HasColumnName("UserTypeID"); 100 | 101 | entity.Property(e => e.UserTypeName) 102 | .HasMaxLength(20) 103 | .IsUnicode(false); 104 | }); 105 | 106 | modelBuilder.Entity(entity => 107 | { 108 | entity.ToTable("Watchlist"); 109 | 110 | entity.Property(e => e.WatchlistId) 111 | .HasMaxLength(36) 112 | .IsUnicode(false); 113 | 114 | entity.Property(e => e.DateCreated).HasColumnType("datetime"); 115 | 116 | entity.Property(e => e.UserId).HasColumnName("UserID"); 117 | }); 118 | 119 | modelBuilder.Entity(entity => 120 | { 121 | entity.Property(e => e.WatchlistId) 122 | .HasMaxLength(36) 123 | .IsUnicode(false); 124 | }); 125 | 126 | OnModelCreatingPartial(modelBuilder); 127 | } 128 | 129 | partial void OnModelCreatingPartial(ModelBuilder modelBuilder); 130 | } 131 | } 132 | -------------------------------------------------------------------------------- /BlazorWasmGraphQL/Client/Pages/AddEditMovie.razor.cs: -------------------------------------------------------------------------------- 1 | using BlazorWasmGraphQL.Client.GraphQLAPIClient; 2 | using BlazorWasmGraphQL.Client.Shared; 3 | using BlazorWasmGraphQL.Server.Models; 4 | using Microsoft.AspNetCore.Components; 5 | using Microsoft.AspNetCore.Components.Forms; 6 | 7 | namespace BlazorWasmGraphQL.Client.Pages 8 | { 9 | public class AddEditMovieBase : ComponentBase 10 | { 11 | [Inject] 12 | public NavigationManager NavigationManager { get; set; } = default!; 13 | 14 | [Inject] 15 | MovieClient MovieClient { get; set; } = default!; 16 | 17 | [Inject] 18 | AppStateContainer AppStateContainer { get; set; } = default!; 19 | 20 | [Parameter] 21 | public int MovieID { get; set; } 22 | 23 | protected string Title = "Add"; 24 | public Movie movie = new(); 25 | protected List? lstGenre = new(); 26 | protected string? imagePreview; 27 | const int MaxFileSize = 10 * 1024 * 1024; // 10 MB 28 | const string DefaultStatus = "Maximum size allowed for the image is 10 MB"; 29 | protected string status = DefaultStatus; 30 | 31 | protected override void OnInitialized() 32 | { 33 | lstGenre = AppStateContainer.AvailableGenre; 34 | } 35 | 36 | protected override async Task OnParametersSetAsync() 37 | { 38 | if (MovieID != 0) 39 | { 40 | Title = "Edit"; 41 | 42 | MovieFilterInput movieFilterInput = new() 43 | { 44 | MovieId = new() 45 | { 46 | Eq = MovieID 47 | } 48 | }; 49 | 50 | var response = await MovieClient.FilterMovieByID.ExecuteAsync(movieFilterInput); 51 | var movieData = response?.Data?.MovieList[0]; 52 | 53 | if (movieData is not null) 54 | { 55 | movie.MovieId = movieData.MovieId; 56 | movie.Title = movieData.Title; 57 | movie.Genre = movieData.Genre; 58 | movie.Duration = movieData.Duration; 59 | movie.PosterPath = movieData.PosterPath; 60 | movie.Rating = movieData.Rating; 61 | movie.Overview = movieData.Overview; 62 | movie.Language = movieData.Language; 63 | 64 | imagePreview = "/Poster/" + movie.PosterPath; 65 | } 66 | } 67 | } 68 | 69 | protected async Task SaveMovie() 70 | { 71 | MovieInput movieData = new() 72 | { 73 | MovieId = movie.MovieId, 74 | Title = movie.Title, 75 | Overview = movie.Overview, 76 | Duration = movie.Duration, 77 | Rating = movie.Rating, 78 | Genre = movie.Genre, 79 | Language = movie.Language, 80 | PosterPath = movie.PosterPath, 81 | }; 82 | 83 | if (movieData.MovieId != 0) 84 | { 85 | await MovieClient.EditMovieData.ExecuteAsync(movieData); 86 | } 87 | else 88 | { 89 | await MovieClient.AddMovieData.ExecuteAsync(movieData); 90 | } 91 | 92 | NavigateToAdminPanel(); 93 | } 94 | 95 | protected void NavigateToAdminPanel() 96 | { 97 | NavigationManager?.NavigateTo("/admin/movies"); 98 | } 99 | 100 | protected async Task ViewImage(InputFileChangeEventArgs e) 101 | { 102 | if (e.File.Size > MaxFileSize) 103 | { 104 | status = $"The file size is {e.File.Size} bytes, this is more than the allowed limit of {MaxFileSize} bytes."; 105 | return; 106 | } 107 | else if (!e.File.ContentType.Contains("image")) 108 | { 109 | status = "Please upload a valid image file"; 110 | return; 111 | } 112 | else 113 | { 114 | using var reader = new StreamReader(e.File.OpenReadStream(MaxFileSize)); 115 | 116 | var format = "image/jpeg"; 117 | var imageFile = await e.File.RequestImageFileAsync(format, 640, 480); 118 | 119 | using var fileStream = imageFile.OpenReadStream(MaxFileSize); 120 | using var memoryStream = new MemoryStream(); 121 | await fileStream.CopyToAsync(memoryStream); 122 | 123 | imagePreview = $"data:{format};base64,{Convert.ToBase64String(memoryStream.ToArray())}"; 124 | movie.PosterPath = Convert.ToBase64String(memoryStream.ToArray()); 125 | 126 | status = DefaultStatus; 127 | } 128 | } 129 | } 130 | } 131 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | 4 | # User-specific files 5 | *.suo 6 | *.user 7 | *.userosscache 8 | *.sln.docstates 9 | 10 | # User-specific files (MonoDevelop/Xamarin Studio) 11 | *.userprefs 12 | 13 | # Build results 14 | [Dd]ebug/ 15 | [Dd]ebugPublic/ 16 | [Rr]elease/ 17 | [Rr]eleases/ 18 | x64/ 19 | x86/ 20 | bld/ 21 | [Bb]in/ 22 | [Oo]bj/ 23 | [Ll]og/ 24 | 25 | # Visual Studio 2015 cache/options directory 26 | .vs/ 27 | # Uncomment if you have tasks that create the project's static files in wwwroot 28 | #wwwroot/ 29 | 30 | # MSTest test Results 31 | [Tt]est[Rr]esult*/ 32 | [Bb]uild[Ll]og.* 33 | 34 | # NUNIT 35 | *.VisualState.xml 36 | TestResult.xml 37 | 38 | # Build Results of an ATL Project 39 | [Dd]ebugPS/ 40 | [Rr]eleasePS/ 41 | dlldata.c 42 | 43 | # DNX 44 | project.lock.json 45 | project.fragment.lock.json 46 | artifacts/ 47 | 48 | *_i.c 49 | *_p.c 50 | *_i.h 51 | *.ilk 52 | *.meta 53 | *.obj 54 | *.pch 55 | *.pdb 56 | *.pgc 57 | *.pgd 58 | *.rsp 59 | *.sbr 60 | *.tlb 61 | *.tli 62 | *.tlh 63 | *.tmp 64 | *.tmp_proj 65 | *.log 66 | *.vspscc 67 | *.vssscc 68 | .builds 69 | *.pidb 70 | *.svclog 71 | *.scc 72 | 73 | # Chutzpah Test files 74 | _Chutzpah* 75 | 76 | # Visual C++ cache files 77 | ipch/ 78 | *.aps 79 | *.ncb 80 | *.opendb 81 | *.opensdf 82 | *.sdf 83 | *.cachefile 84 | *.VC.db 85 | *.VC.VC.opendb 86 | 87 | # Visual Studio profiler 88 | *.psess 89 | *.vsp 90 | *.vspx 91 | *.sap 92 | 93 | # TFS 2012 Local Workspace 94 | $tf/ 95 | 96 | # Guidance Automation Toolkit 97 | *.gpState 98 | 99 | # ReSharper is a .NET coding add-in 100 | _ReSharper*/ 101 | *.[Rr]e[Ss]harper 102 | *.DotSettings.user 103 | 104 | # JustCode is a .NET coding add-in 105 | .JustCode 106 | 107 | # TeamCity is a build add-in 108 | _TeamCity* 109 | 110 | # DotCover is a Code Coverage Tool 111 | *.dotCover 112 | 113 | # NCrunch 114 | _NCrunch_* 115 | .*crunch*.local.xml 116 | nCrunchTemp_* 117 | 118 | # MightyMoose 119 | *.mm.* 120 | AutoTest.Net/ 121 | 122 | # Web workbench (sass) 123 | .sass-cache/ 124 | 125 | # Installshield output folder 126 | [Ee]xpress/ 127 | 128 | # DocProject is a documentation generator add-in 129 | DocProject/buildhelp/ 130 | DocProject/Help/*.HxT 131 | DocProject/Help/*.HxC 132 | DocProject/Help/*.hhc 133 | DocProject/Help/*.hhk 134 | DocProject/Help/*.hhp 135 | DocProject/Help/Html2 136 | DocProject/Help/html 137 | 138 | # Click-Once directory 139 | publish/ 140 | 141 | # Publish Web Output 142 | *.[Pp]ublish.xml 143 | *.azurePubxml 144 | # TODO: Comment the next line if you want to checkin your web deploy settings 145 | # but database connection strings (with potential passwords) will be unencrypted 146 | #*.pubxml 147 | *.publishproj 148 | 149 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 150 | # checkin your Azure Web App publish settings, but sensitive information contained 151 | # in these scripts will be unencrypted 152 | PublishScripts/ 153 | 154 | # NuGet Packages 155 | *.nupkg 156 | # The packages folder can be ignored because of Package Restore 157 | **/packages/* 158 | # except build/, which is used as an MSBuild target. 159 | !**/packages/build/ 160 | # Uncomment if necessary however generally it will be regenerated when needed 161 | #!**/packages/repositories.config 162 | # NuGet v3's project.json files produces more ignoreable files 163 | *.nuget.props 164 | *.nuget.targets 165 | 166 | # Microsoft Azure Build Output 167 | csx/ 168 | *.build.csdef 169 | 170 | # Microsoft Azure Emulator 171 | ecf/ 172 | rcf/ 173 | 174 | # Windows Store app package directories and files 175 | AppPackages/ 176 | BundleArtifacts/ 177 | Package.StoreAssociation.xml 178 | _pkginfo.txt 179 | 180 | # Visual Studio cache files 181 | # files ending in .cache can be ignored 182 | *.[Cc]ache 183 | # but keep track of directories ending in .cache 184 | !*.[Cc]ache/ 185 | 186 | # Others 187 | ClientBin/ 188 | ~$* 189 | *~ 190 | *.dbmdl 191 | *.dbproj.schemaview 192 | *.jfm 193 | *.pfx 194 | *.publishsettings 195 | node_modules/ 196 | orleans.codegen.cs 197 | 198 | # Since there are multiple workflows, uncomment next line to ignore bower_components 199 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 200 | #bower_components/ 201 | 202 | # RIA/Silverlight projects 203 | Generated_Code/ 204 | 205 | # Backup & report files from converting an old project file 206 | # to a newer Visual Studio version. Backup files are not needed, 207 | # because we have git ;-) 208 | _UpgradeReport_Files/ 209 | Backup*/ 210 | UpgradeLog*.XML 211 | UpgradeLog*.htm 212 | 213 | # SQL Server files 214 | *.mdf 215 | *.ldf 216 | 217 | # Business Intelligence projects 218 | *.rdl.data 219 | *.bim.layout 220 | *.bim_*.settings 221 | 222 | # Microsoft Fakes 223 | FakesAssemblies/ 224 | 225 | # GhostDoc plugin setting file 226 | *.GhostDoc.xml 227 | 228 | # Node.js Tools for Visual Studio 229 | .ntvs_analysis.dat 230 | 231 | # Visual Studio 6 build log 232 | *.plg 233 | 234 | # Visual Studio 6 workspace options file 235 | *.opt 236 | 237 | # Visual Studio LightSwitch build output 238 | **/*.HTMLClient/GeneratedArtifacts 239 | **/*.DesktopClient/GeneratedArtifacts 240 | **/*.DesktopClient/ModelManifest.xml 241 | **/*.Server/GeneratedArtifacts 242 | **/*.Server/ModelManifest.xml 243 | _Pvt_Extensions 244 | 245 | # Paket dependency manager 246 | .paket/paket.exe 247 | paket-files/ 248 | 249 | # FAKE - F# Make 250 | .fake/ 251 | 252 | # JetBrains Rider 253 | .idea/ 254 | *.sln.iml 255 | 256 | # CodeRush 257 | .cr/ 258 | 259 | # Python Tools for Visual Studio (PTVS) 260 | __pycache__/ 261 | *.pyc -------------------------------------------------------------------------------- /BlazorWasmGraphQL/Client/wwwroot/css/open-iconic/font/css/open-iconic-bootstrap.min.css: -------------------------------------------------------------------------------- 1 | @font-face{font-family:Icons;src:url(../fonts/open-iconic.eot);src:url(../fonts/open-iconic.eot?#iconic-sm) format('embedded-opentype'),url(../fonts/open-iconic.woff) format('woff'),url(../fonts/open-iconic.ttf) format('truetype'),url(../fonts/open-iconic.otf) format('opentype'),url(../fonts/open-iconic.svg#iconic-sm) format('svg');font-weight:400;font-style:normal}.oi{position:relative;top:1px;display:inline-block;speak:none;font-family:Icons;font-style:normal;font-weight:400;line-height:1;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.oi:empty:before{width:1em;text-align:center;box-sizing:content-box}.oi.oi-align-center:before{text-align:center}.oi.oi-align-left:before{text-align:left}.oi.oi-align-right:before{text-align:right}.oi.oi-flip-horizontal:before{-webkit-transform:scale(-1,1);-ms-transform:scale(-1,1);transform:scale(-1,1)}.oi.oi-flip-vertical:before{-webkit-transform:scale(1,-1);-ms-transform:scale(-1,1);transform:scale(1,-1)}.oi.oi-flip-horizontal-vertical:before{-webkit-transform:scale(-1,-1);-ms-transform:scale(-1,1);transform:scale(-1,-1)}.oi-account-login:before{content:'\e000'}.oi-account-logout:before{content:'\e001'}.oi-action-redo:before{content:'\e002'}.oi-action-undo:before{content:'\e003'}.oi-align-center:before{content:'\e004'}.oi-align-left:before{content:'\e005'}.oi-align-right:before{content:'\e006'}.oi-aperture:before{content:'\e007'}.oi-arrow-bottom:before{content:'\e008'}.oi-arrow-circle-bottom:before{content:'\e009'}.oi-arrow-circle-left:before{content:'\e00a'}.oi-arrow-circle-right:before{content:'\e00b'}.oi-arrow-circle-top:before{content:'\e00c'}.oi-arrow-left:before{content:'\e00d'}.oi-arrow-right:before{content:'\e00e'}.oi-arrow-thick-bottom:before{content:'\e00f'}.oi-arrow-thick-left:before{content:'\e010'}.oi-arrow-thick-right:before{content:'\e011'}.oi-arrow-thick-top:before{content:'\e012'}.oi-arrow-top:before{content:'\e013'}.oi-audio-spectrum:before{content:'\e014'}.oi-audio:before{content:'\e015'}.oi-badge:before{content:'\e016'}.oi-ban:before{content:'\e017'}.oi-bar-chart:before{content:'\e018'}.oi-basket:before{content:'\e019'}.oi-battery-empty:before{content:'\e01a'}.oi-battery-full:before{content:'\e01b'}.oi-beaker:before{content:'\e01c'}.oi-bell:before{content:'\e01d'}.oi-bluetooth:before{content:'\e01e'}.oi-bold:before{content:'\e01f'}.oi-bolt:before{content:'\e020'}.oi-book:before{content:'\e021'}.oi-bookmark:before{content:'\e022'}.oi-box:before{content:'\e023'}.oi-briefcase:before{content:'\e024'}.oi-british-pound:before{content:'\e025'}.oi-browser:before{content:'\e026'}.oi-brush:before{content:'\e027'}.oi-bug:before{content:'\e028'}.oi-bullhorn:before{content:'\e029'}.oi-calculator:before{content:'\e02a'}.oi-calendar:before{content:'\e02b'}.oi-camera-slr:before{content:'\e02c'}.oi-caret-bottom:before{content:'\e02d'}.oi-caret-left:before{content:'\e02e'}.oi-caret-right:before{content:'\e02f'}.oi-caret-top:before{content:'\e030'}.oi-cart:before{content:'\e031'}.oi-chat:before{content:'\e032'}.oi-check:before{content:'\e033'}.oi-chevron-bottom:before{content:'\e034'}.oi-chevron-left:before{content:'\e035'}.oi-chevron-right:before{content:'\e036'}.oi-chevron-top:before{content:'\e037'}.oi-circle-check:before{content:'\e038'}.oi-circle-x:before{content:'\e039'}.oi-clipboard:before{content:'\e03a'}.oi-clock:before{content:'\e03b'}.oi-cloud-download:before{content:'\e03c'}.oi-cloud-upload:before{content:'\e03d'}.oi-cloud:before{content:'\e03e'}.oi-cloudy:before{content:'\e03f'}.oi-code:before{content:'\e040'}.oi-cog:before{content:'\e041'}.oi-collapse-down:before{content:'\e042'}.oi-collapse-left:before{content:'\e043'}.oi-collapse-right:before{content:'\e044'}.oi-collapse-up:before{content:'\e045'}.oi-command:before{content:'\e046'}.oi-comment-square:before{content:'\e047'}.oi-compass:before{content:'\e048'}.oi-contrast:before{content:'\e049'}.oi-copywriting:before{content:'\e04a'}.oi-credit-card:before{content:'\e04b'}.oi-crop:before{content:'\e04c'}.oi-dashboard:before{content:'\e04d'}.oi-data-transfer-download:before{content:'\e04e'}.oi-data-transfer-upload:before{content:'\e04f'}.oi-delete:before{content:'\e050'}.oi-dial:before{content:'\e051'}.oi-document:before{content:'\e052'}.oi-dollar:before{content:'\e053'}.oi-double-quote-sans-left:before{content:'\e054'}.oi-double-quote-sans-right:before{content:'\e055'}.oi-double-quote-serif-left:before{content:'\e056'}.oi-double-quote-serif-right:before{content:'\e057'}.oi-droplet:before{content:'\e058'}.oi-eject:before{content:'\e059'}.oi-elevator:before{content:'\e05a'}.oi-ellipses:before{content:'\e05b'}.oi-envelope-closed:before{content:'\e05c'}.oi-envelope-open:before{content:'\e05d'}.oi-euro:before{content:'\e05e'}.oi-excerpt:before{content:'\e05f'}.oi-expand-down:before{content:'\e060'}.oi-expand-left:before{content:'\e061'}.oi-expand-right:before{content:'\e062'}.oi-expand-up:before{content:'\e063'}.oi-external-link:before{content:'\e064'}.oi-eye:before{content:'\e065'}.oi-eyedropper:before{content:'\e066'}.oi-file:before{content:'\e067'}.oi-fire:before{content:'\e068'}.oi-flag:before{content:'\e069'}.oi-flash:before{content:'\e06a'}.oi-folder:before{content:'\e06b'}.oi-fork:before{content:'\e06c'}.oi-fullscreen-enter:before{content:'\e06d'}.oi-fullscreen-exit:before{content:'\e06e'}.oi-globe:before{content:'\e06f'}.oi-graph:before{content:'\e070'}.oi-grid-four-up:before{content:'\e071'}.oi-grid-three-up:before{content:'\e072'}.oi-grid-two-up:before{content:'\e073'}.oi-hard-drive:before{content:'\e074'}.oi-header:before{content:'\e075'}.oi-headphones:before{content:'\e076'}.oi-heart:before{content:'\e077'}.oi-home:before{content:'\e078'}.oi-image:before{content:'\e079'}.oi-inbox:before{content:'\e07a'}.oi-infinity:before{content:'\e07b'}.oi-info:before{content:'\e07c'}.oi-italic:before{content:'\e07d'}.oi-justify-center:before{content:'\e07e'}.oi-justify-left:before{content:'\e07f'}.oi-justify-right:before{content:'\e080'}.oi-key:before{content:'\e081'}.oi-laptop:before{content:'\e082'}.oi-layers:before{content:'\e083'}.oi-lightbulb:before{content:'\e084'}.oi-link-broken:before{content:'\e085'}.oi-link-intact:before{content:'\e086'}.oi-list-rich:before{content:'\e087'}.oi-list:before{content:'\e088'}.oi-location:before{content:'\e089'}.oi-lock-locked:before{content:'\e08a'}.oi-lock-unlocked:before{content:'\e08b'}.oi-loop-circular:before{content:'\e08c'}.oi-loop-square:before{content:'\e08d'}.oi-loop:before{content:'\e08e'}.oi-magnifying-glass:before{content:'\e08f'}.oi-map-marker:before{content:'\e090'}.oi-map:before{content:'\e091'}.oi-media-pause:before{content:'\e092'}.oi-media-play:before{content:'\e093'}.oi-media-record:before{content:'\e094'}.oi-media-skip-backward:before{content:'\e095'}.oi-media-skip-forward:before{content:'\e096'}.oi-media-step-backward:before{content:'\e097'}.oi-media-step-forward:before{content:'\e098'}.oi-media-stop:before{content:'\e099'}.oi-medical-cross:before{content:'\e09a'}.oi-menu:before{content:'\e09b'}.oi-microphone:before{content:'\e09c'}.oi-minus:before{content:'\e09d'}.oi-monitor:before{content:'\e09e'}.oi-moon:before{content:'\e09f'}.oi-move:before{content:'\e0a0'}.oi-musical-note:before{content:'\e0a1'}.oi-paperclip:before{content:'\e0a2'}.oi-pencil:before{content:'\e0a3'}.oi-people:before{content:'\e0a4'}.oi-person:before{content:'\e0a5'}.oi-phone:before{content:'\e0a6'}.oi-pie-chart:before{content:'\e0a7'}.oi-pin:before{content:'\e0a8'}.oi-play-circle:before{content:'\e0a9'}.oi-plus:before{content:'\e0aa'}.oi-power-standby:before{content:'\e0ab'}.oi-print:before{content:'\e0ac'}.oi-project:before{content:'\e0ad'}.oi-pulse:before{content:'\e0ae'}.oi-puzzle-piece:before{content:'\e0af'}.oi-question-mark:before{content:'\e0b0'}.oi-rain:before{content:'\e0b1'}.oi-random:before{content:'\e0b2'}.oi-reload:before{content:'\e0b3'}.oi-resize-both:before{content:'\e0b4'}.oi-resize-height:before{content:'\e0b5'}.oi-resize-width:before{content:'\e0b6'}.oi-rss-alt:before{content:'\e0b7'}.oi-rss:before{content:'\e0b8'}.oi-script:before{content:'\e0b9'}.oi-share-boxed:before{content:'\e0ba'}.oi-share:before{content:'\e0bb'}.oi-shield:before{content:'\e0bc'}.oi-signal:before{content:'\e0bd'}.oi-signpost:before{content:'\e0be'}.oi-sort-ascending:before{content:'\e0bf'}.oi-sort-descending:before{content:'\e0c0'}.oi-spreadsheet:before{content:'\e0c1'}.oi-star:before{content:'\e0c2'}.oi-sun:before{content:'\e0c3'}.oi-tablet:before{content:'\e0c4'}.oi-tag:before{content:'\e0c5'}.oi-tags:before{content:'\e0c6'}.oi-target:before{content:'\e0c7'}.oi-task:before{content:'\e0c8'}.oi-terminal:before{content:'\e0c9'}.oi-text:before{content:'\e0ca'}.oi-thumb-down:before{content:'\e0cb'}.oi-thumb-up:before{content:'\e0cc'}.oi-timer:before{content:'\e0cd'}.oi-transfer:before{content:'\e0ce'}.oi-trash:before{content:'\e0cf'}.oi-underline:before{content:'\e0d0'}.oi-vertical-align-bottom:before{content:'\e0d1'}.oi-vertical-align-center:before{content:'\e0d2'}.oi-vertical-align-top:before{content:'\e0d3'}.oi-video:before{content:'\e0d4'}.oi-volume-high:before{content:'\e0d5'}.oi-volume-low:before{content:'\e0d6'}.oi-volume-off:before{content:'\e0d7'}.oi-warning:before{content:'\e0d8'}.oi-wifi:before{content:'\e0d9'}.oi-wrench:before{content:'\e0da'}.oi-x:before{content:'\e0db'}.oi-yen:before{content:'\e0dc'}.oi-zoom-in:before{content:'\e0dd'}.oi-zoom-out:before{content:'\e0de'} -------------------------------------------------------------------------------- /BlazorWasmGraphQL/Client/wwwroot/css/open-iconic/font/fonts/open-iconic.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | 7 | 8 | Created by FontForge 20120731 at Tue Jul 1 20:39:22 2014 9 | By P.J. Onori 10 | Created by P.J. Onori with FontForge 2.0 (http://fontforge.sf.net) 11 | 12 | 13 | 14 | 27 | 28 | 30 | 32 | 34 | 36 | 38 | 40 | 42 | 45 | 47 | 49 | 51 | 53 | 55 | 57 | 59 | 61 | 63 | 65 | 67 | 69 | 71 | 74 | 76 | 79 | 81 | 84 | 86 | 88 | 91 | 93 | 95 | 98 | 100 | 102 | 104 | 106 | 109 | 112 | 115 | 117 | 121 | 123 | 125 | 127 | 130 | 132 | 134 | 136 | 138 | 141 | 143 | 145 | 147 | 149 | 151 | 153 | 155 | 157 | 159 | 162 | 165 | 167 | 169 | 172 | 174 | 177 | 179 | 181 | 183 | 185 | 189 | 191 | 194 | 196 | 198 | 200 | 202 | 205 | 207 | 209 | 211 | 213 | 215 | 218 | 220 | 222 | 224 | 226 | 228 | 230 | 232 | 234 | 236 | 238 | 241 | 243 | 245 | 247 | 249 | 251 | 253 | 256 | 259 | 261 | 263 | 265 | 267 | 269 | 272 | 274 | 276 | 280 | 282 | 285 | 287 | 289 | 292 | 295 | 298 | 300 | 302 | 304 | 306 | 309 | 312 | 314 | 316 | 318 | 320 | 322 | 324 | 326 | 330 | 334 | 338 | 340 | 343 | 345 | 347 | 349 | 351 | 353 | 355 | 358 | 360 | 363 | 365 | 367 | 369 | 371 | 373 | 375 | 377 | 379 | 381 | 383 | 386 | 388 | 390 | 392 | 394 | 396 | 399 | 401 | 404 | 406 | 408 | 410 | 412 | 414 | 416 | 419 | 421 | 423 | 425 | 428 | 431 | 435 | 438 | 440 | 442 | 444 | 446 | 448 | 451 | 453 | 455 | 457 | 460 | 462 | 464 | 466 | 468 | 471 | 473 | 477 | 479 | 481 | 483 | 486 | 488 | 490 | 492 | 494 | 496 | 499 | 501 | 504 | 506 | 509 | 512 | 515 | 517 | 520 | 522 | 524 | 526 | 529 | 532 | 534 | 536 | 539 | 542 | 543 | 544 | --------------------------------------------------------------------------------