Skip to content

Commit

Permalink
Adding of new video project
Browse files Browse the repository at this point in the history
  • Loading branch information
Clifftech123 committed Feb 5, 2025
1 parent 3f5804e commit ffd9613
Show file tree
Hide file tree
Showing 28 changed files with 1,070 additions and 0 deletions.
22 changes: 22 additions & 0 deletions BlazorCRUD/BlazorCrudApp.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.12.35506.116 d17.12
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BlazorCrudApp", "BlazorCrudApp\BlazorCrudApp.csproj", "{FDA7E2F7-A15D-4464-8171-381DAFFCED43}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{FDA7E2F7-A15D-4464-8171-381DAFFCED43}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{FDA7E2F7-A15D-4464-8171-381DAFFCED43}.Debug|Any CPU.Build.0 = Debug|Any CPU
{FDA7E2F7-A15D-4464-8171-381DAFFCED43}.Release|Any CPU.ActiveCfg = Release|Any CPU
{FDA7E2F7-A15D-4464-8171-381DAFFCED43}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
19 changes: 19 additions & 0 deletions BlazorCRUD/BlazorCrudApp/BlazorCrudApp.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>


<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="9.0.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="9.0.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="9.0.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="MudBlazor" Version="8.*" />
</ItemGroup>
</Project>
21 changes: 21 additions & 0 deletions BlazorCRUD/BlazorCrudApp/Components/App.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<base href="/" />
<link href="https://fonts.googleapis.com/css?family=Roboto:300,400,500,700&display=swap" rel="stylesheet" />
<link href="_content/MudBlazor/MudBlazor.min.css" rel="stylesheet" />
<ImportMap />
<link rel="icon" type="image/ico" href="favicon.ico" />

</head>

<body>
<Routes @rendermode="InteractiveServer" />
<script src="_framework/blazor.web.js"></script>
<script src="_content/MudBlazor/MudBlazor.min.js"></script>
</body>

</html>
104 changes: 104 additions & 0 deletions BlazorCRUD/BlazorCrudApp/Components/Layout/MainLayout.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
@inherits LayoutComponentBase

<MudThemeProvider Theme="@_theme" IsDarkMode="_isDarkMode" />
<MudPopoverProvider />
<MudDialogProvider />
<MudSnackbarProvider />
<MudLayout>
<MudAppBar Elevation="1">
<MudIconButton Icon="@Icons.Material.Filled.Menu" Color="Color.Inherit" Edge="Edge.Start" OnClick="@((e) => DrawerToggle())" />
<MudText Typo="Typo.h5" Class="ml-3">Application</MudText>
<MudSpacer />
<MudIconButton Icon="@(DarkLightModeButtonIcon)" Color="Color.Inherit" OnClick="@DarkModeToggle" />
<MudIconButton Icon="@Icons.Material.Filled.MoreVert" Color="Color.Inherit" Edge="Edge.End" />
</MudAppBar>
<MudDrawer @bind-Open="_drawerOpen" ClipMode="DrawerClipMode.Always" Elevation="2">
<NavMenu />
</MudDrawer>
<MudMainContent Class="mt-16 pa-4">
@Body
</MudMainContent>
</MudLayout>


<div id="blazor-error-ui" data-nosnippet>
An unhandled error has occurred.
<a href="." class="reload">Reload</a>
<span class="dismiss">🗙</span>
</div>

@code {
private bool _drawerOpen = true;
private bool _isDarkMode = true;
private MudTheme? _theme = null;

protected override void OnInitialized()
{
base.OnInitialized();

_theme = new()
{
PaletteLight = _lightPalette,
PaletteDark = _darkPalette,
LayoutProperties = new LayoutProperties()
};
}


private void DrawerToggle()
{
_drawerOpen = !_drawerOpen;
}

private void DarkModeToggle()
{
_isDarkMode = !_isDarkMode;
}

private readonly PaletteLight _lightPalette = new()
{
Black = "#110e2d",
AppbarText = "#424242",
AppbarBackground = "rgba(255,255,255,0.8)",
DrawerBackground = "#ffffff",
GrayLight = "#e8e8e8",
GrayLighter = "#f9f9f9",
};

private readonly PaletteDark _darkPalette = new()
{
Primary = "#7e6fff",
Surface = "#1e1e2d",
Background = "#1a1a27",
BackgroundGray = "#151521",
AppbarText = "#92929f",
AppbarBackground = "rgba(26,26,39,0.8)",
DrawerBackground = "#1a1a27",
ActionDefault = "#74718e",
ActionDisabled = "#9999994d",
ActionDisabledBackground = "#605f6d4d",
TextPrimary = "#b2b0bf",
TextSecondary = "#92929f",
TextDisabled = "#ffffff33",
DrawerIcon = "#92929f",
DrawerText = "#92929f",
GrayLight = "#2a2833",
GrayLighter = "#1e1e2d",
Info = "#4a86ff",
Success = "#3dcb6c",
Warning = "#ffb545",
Error = "#ff3f5f",
LinesDefault = "#33323e",
TableLines = "#33323e",
Divider = "#292838",
OverlayLight = "#1e1e2d80",
};

public string DarkLightModeButtonIcon => _isDarkMode switch
{
true => Icons.Material.Rounded.AutoMode,
false => Icons.Material.Outlined.DarkMode,
};
}


10 changes: 10 additions & 0 deletions BlazorCRUD/BlazorCrudApp/Components/Layout/NavMenu.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@

<MudNavMenu>
<MudNavLink Href="" Match="NavLinkMatch.All" Icon="@Icons.Material.Filled.Home">Home</MudNavLink>
<MudNavLink Href="counter" Match="NavLinkMatch.Prefix" Icon="@Icons.Material.Filled.Add">Counter</MudNavLink>

<MudNavLink Href="weather" Match="NavLinkMatch.Prefix" Icon="@Icons.Material.Filled.List">Weather</MudNavLink>

</MudNavMenu>


18 changes: 18 additions & 0 deletions BlazorCRUD/BlazorCrudApp/Components/Pages/Counter.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
@page "/counter"

<PageTitle>Counter</PageTitle>

<MudText Typo="Typo.h3" GutterBottom="true">Counter</MudText>

<MudText Typo="Typo.body1" Class="mb-4">Current count: @currentCount</MudText>

<MudButton Color="Color.Primary" Variant="Variant.Filled" @onclick="IncrementCount">Click me</MudButton>

@code {
private int currentCount = 0;

private void IncrementCount()
{
currentCount++;
}
}
58 changes: 58 additions & 0 deletions BlazorCRUD/BlazorCrudApp/Components/Pages/CreateEmployee.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
@using BlazorCrudApp.Domain
@using BlazorCrudApp.Service
@inject IEmployeeService EmployeeService
@inject ISnackbar Snackbar
@inject IDialogService DialogService

<MudDialog>
<DialogContent>
<MudForm @ref="form" Model="@model">
<MudTextField T="string" @bind-Value="model.EmployeName" Label="Employee Name" Required="true"
RequiredError="Name is required!" />

<MudSelect T="string" Label="Gender" @bind-Value="model.Gender" Required="true"
RequiredError="Gender is required!">
<MudSelectItem Value="@("Male")">Male</MudSelectItem>
<MudSelectItem Value="@("Female")">Female</MudSelectItem>
<MudSelectItem Value="@("Other")">Other</MudSelectItem>
</MudSelect>


<MudTextField T="string" @bind-Value="model.City" Label="City" Required="true"
RequiredError="City is required!" />
</MudForm>
</DialogContent>
<DialogActions>
<MudButton OnClick="Cancel">Cancel</MudButton>
<MudButton Color="Color.Primary" OnClick="Submit">Create</MudButton>
</DialogActions>
</MudDialog>

@code {
[CascadingParameter] IMudDialogInstance MudDialog { get; set; } = default!;
private MudForm form = default!;
private CreateEmployeeDto model = new();

private void Cancel()
{
MudDialog.Cancel();
}

private async Task Submit()
{
await form.Validate();
if (form.IsValid)
{
try
{
await EmployeeService.CreateEmployeeAsync(model);
Snackbar.Add("Employee created successfully", Severity.Success);
MudDialog.Close(DialogResult.Ok(true));
}
catch (Exception)
{
Snackbar.Add("Error creating employee", Severity.Error);
}
}
}
}
35 changes: 35 additions & 0 deletions BlazorCRUD/BlazorCrudApp/Components/Pages/DeleteConfirmation.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
@using MudBlazor
@inject IDialogService DialogService
@inject ISnackbar Snackbar

<MudDialog>
<TitleContent>
<MudText Typo="Typo.h6">
<MudIcon Icon="@Icons.Material.Filled.DeleteForever" Class="mr-3" />
Confirm Deletion
</MudText>
</TitleContent>
<DialogContent>
<MudAlert Severity="Severity.Warning" Class="my-2">
<MudText>Are you sure you want to delete this employee?</MudText>
<MudText Typo="Typo.subtitle2">This action cannot be undone.</MudText>
</MudAlert>
</DialogContent>
<DialogActions>
<MudButton Variant="Variant.Outlined" Color="Color.Default" OnClick="Cancel"
StartIcon="@Icons.Material.Filled.Cancel">Cancel</MudButton>
<MudButton Variant="Variant.Filled" Color="Color.Error" OnClick="Submit"
StartIcon="@Icons.Material.Filled.Delete">Delete</MudButton>
</DialogActions>
</MudDialog>

@code {
[CascadingParameter] IMudDialogInstance MudDialog { get; set; }
[Parameter] public Guid EmployeeId { get; set; }
[Parameter] public string Message { get; set; }


private void Cancel() => MudDialog.Cancel();

private void Submit() => MudDialog.Close(DialogResult.Ok(true));
}
72 changes: 72 additions & 0 deletions BlazorCRUD/BlazorCrudApp/Components/Pages/EditEmployee.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
@using BlazorCrudApp.Domain
@using BlazorCrudApp.Service
@using MudBlazor
@inject IEmployeeService EmployeeService
@inject ISnackbar Snackbar




<MudDialog>
<TitleContent>
<MudText Typo="Typo.h6">Edit Employee</MudText>
</TitleContent>
<DialogContent>
<MudForm @ref="form" Model="@model">
<MudTextField T="string" @bind-Value="model.EmployeName" Label="Employee Name" Required="true"
RequiredError="Name is required!" />

<MudSelect T="string" Label="Gender" @bind-Value="model.Gender" Required="true"
RequiredError="Gender is required!">
<MudSelectItem Value="@("Male")">Male</MudSelectItem>
<MudSelectItem Value="@("Female")">Female</MudSelectItem>
</MudSelect>

<MudTextField T="string" @bind-Value="model.City" Label="City" Required="true"
RequiredError="City is required!" />
</MudForm>
</DialogContent>
<DialogActions>
<MudButton OnClick="Cancel">Cancel</MudButton>
<MudButton Color="Color.Primary" OnClick="Submit">Update</MudButton>
</DialogActions>
</MudDialog>

@code {
[CascadingParameter] IMudDialogInstance Dialog { get; set; }

[Parameter] public EmployeeDetailsDto Employee { get; set; }
[Parameter] public string Title { get; set; }


private MudForm form;
private UpdateEmployeeDto model = new();

protected override void OnInitialized()
{
model.Id = Employee.Id;
model.EmployeName = Employee.EmployeName;
model.Gender = Employee.Gender;
model.City = Employee.City;
}

private void Cancel() => Dialog.Cancel();

private async Task Submit()
{
await form.Validate();
if (form.IsValid)
{
try
{
await EmployeeService.UpdateEmployeeAsync(model);
Snackbar.Add("Employee updated successfully", Severity.Success);
Dialog.Close(DialogResult.Ok(true));
}
catch (Exception)
{
Snackbar.Add("Error updating employee", Severity.Error);
}
}
}
}
Loading

0 comments on commit ffd9613

Please sign in to comment.