Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 30 additions & 1 deletion Authentication/UserAccountService.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
namespace BlazorServerAuthenticationAndAuthorization.Authentication
/*
namespace BlazorServerAuthenticationAndAuthorization.Authentication
{
public class UserAccountService
{
Expand All @@ -19,3 +20,31 @@ public UserAccountService()
}
}
}
*/
using BlazorAppProjekt.Data;
using BlazorAppProjekt.Models;
using System.Collections.Generic;
using System.Linq;

namespace BlazorServerAuthenticationAndAuthorization.Authentication
{
public class UserAccountService
{
private readonly MyDbContext _dbContext;

public UserAccountService(MyDbContext dbContext)
{
_dbContext = dbContext;
}

public UserAccount? GetByUserName(string userName)
{
var user = _dbContext.Users.FirstOrDefault(x => x.UserName == userName);
if (user == null)
{
return null;
}
return new UserAccount { UserName = user.UserName, Password = user.Password, Role = user.userlevel };
}
}
}
13 changes: 12 additions & 1 deletion BlazorServerAuthenticationAndAuthorization.csproj
Original file line number Diff line number Diff line change
@@ -1,9 +1,20 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<Project Sdk="Microsoft.NET.Sdk.Web">

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

<ItemGroup>
<None Include="wwwroot\images\szechenyi-plusz-64px.png" />
<None Include="wwwroot\images\uj-logo-h121.png" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.5" />
<PackageReference Include="MySql.EntityFrameworkCore" Version="7.0.2" />
<PackageReference Include="Syncfusion.Blazor" Version="21.2.4" />
</ItemGroup>

</Project>
2 changes: 1 addition & 1 deletion BlazorServerAuthenticationAndAuthorization.sln
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.0.32126.317
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BlazorServerAuthenticationAndAuthorization", "BlazorServerAuthenticationAndAuthorization.csproj", "{884745B4-E6D7-419F-A9E2-082797D60CCE}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BlazorServerAuthenticationAndAuthorization", "BlazorServerAuthenticationAndAuthorization.csproj", "{884745B4-E6D7-419F-A9E2-082797D60CCE}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down
21 changes: 21 additions & 0 deletions Data/MyDbContext.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using Microsoft.EntityFrameworkCore;
using BlazorAppProjekt.Models;

namespace BlazorAppProjekt.Data
{
public class MyDbContext : DbContext
{
public MyDbContext(DbContextOptions<MyDbContext> options) : base(options) { }

public DbSet<Guest> Guests { get; set; }
public DbSet<User> Users { get; set; }
public DbSet<Event> Events { get; set; }
public DbSet<EventGuest> EventGuests { get; set; }
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
base.OnConfiguring(optionsBuilder);
optionsBuilder.EnableSensitiveDataLogging();
}
}
}

13 changes: 0 additions & 13 deletions Data/WeatherForecast.cs

This file was deleted.

20 changes: 0 additions & 20 deletions Data/WeatherForecastService.cs

This file was deleted.

26 changes: 26 additions & 0 deletions Models/Event.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;

namespace BlazorAppProjekt.Models
{
[Table("occurrence")]
public class Event
{
[Key]
[Column("idevent")]
public int Id { get; set; }

[Column("eventname")]
[MaxLength(45)]
public string EventName { get; set; }

[Column("eventdescription")]
[MaxLength(45)]
public string EventDescription { get; set; }

[Column("date")]
public DateTime EventDate { get; set; }
}
}

28 changes: 28 additions & 0 deletions Models/EventGuest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;

namespace BlazorAppProjekt.Models
{
[Table("eventguest")]
public class EventGuest
{
[Column("idguest")]
public int GuestId { get; set; }

[Column("idevent")]
public int EventId { get; set; }

[Key]
[Column("EventGuestId")]
public int EventGuestId { get; set; }


[ForeignKey("GuestId")]
public Guest Guest { get; set; }

[ForeignKey("EventId")]
public Event Event { get; set; }

}
}

24 changes: 24 additions & 0 deletions Models/User.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;

namespace BlazorAppProjekt.Models
{
[Table("user")]
public class User
{
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
[Column("iduser")]
public int Id { get; set; }
public string UserName { get; set; }

[Column("userpassword")]
public string Password { get; set; }

[Column("realname")]
public string FullName { get; set; }

[Column("userlevel")]
public string userlevel { get; set; }
}
}
42 changes: 42 additions & 0 deletions Models/guest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;

namespace BlazorAppProjekt.Models
{
// Models/Guest.cs
[Table("guest")]
public class Guest
{
[Key]
[Column("idguest")]
public int Id { get; set; }

[Column("name")]
[MaxLength(45)]
public string Name { get; set; }

[Column("title")]
[MaxLength(45)]
public string Title { get; set; }

[Column("datetime", TypeName = "date")]
public DateTime Date { get; set; }

[Column("mobil")]
[MaxLength(45)]
public string Mobile { get; set; }

[Column("email")]
[MaxLength(45)]
public string Email { get; set; }

[Column("note")]
[MaxLength(45)]
public string? Note { get; set; } // Módosítottam, hogy nullable string legyen

[Column("picture")]
[MaxLength(45)]
public string Picture { get; set; }
}
}
49 changes: 0 additions & 49 deletions Pages/FetchData.razor

This file was deleted.

Loading