commit 1af8a62ad7f3f34deddc82145fbbcfc1c2a42896
Author: Dominik Chlouba <dchlouba@students.zcu.cz>
Date:   Mon May 3 22:51:38 2021 +0200

    Added application role and user seed, users list and create/update bug fixes

diff --git a/src/Core/Application/Leuze.Core.Application.UI/Pages/Users/Components/UserAside.razor b/src/Core/Application/Leuze.Core.Application.UI/Pages/Users/Components/UserAside.razor
index 17825fd..d6b56b6 100644
--- a/src/Core/Application/Leuze.Core.Application.UI/Pages/Users/Components/UserAside.razor
+++ b/src/Core/Application/Leuze.Core.Application.UI/Pages/Users/Components/UserAside.razor
@@ -56,7 +56,11 @@
 
                         @foreach (var user in Users)
                         {
-                            <option value="@user.Id" selected="@(Senior == user.Id)">@user.Name</option>
+                            @if (UserId != default(Guid) && user.Id == UserId) { }
+                            else
+                            {
+                                <option value="@user.Id" selected="@(Senior == user.Id)">@user.Name</option>
+                            }
                         }
                     </select>
                 }
@@ -287,6 +291,7 @@
             Name = result.Result.User.Name;
             Email = result.Result.User.Email;
             Role = result.Result.User.Role.Id;
+            Senior = result.Result.User.SeniorId ?? default(Guid);
             Loading = false;
         }
     }
diff --git a/src/Core/Domain/Leuze.Core.Domain/Domains/Users/DTOs/UserDetailDto.cs b/src/Core/Domain/Leuze.Core.Domain/Domains/Users/DTOs/UserDetailDto.cs
index 4411191..1e89bf8 100644
--- a/src/Core/Domain/Leuze.Core.Domain/Domains/Users/DTOs/UserDetailDto.cs
+++ b/src/Core/Domain/Leuze.Core.Domain/Domains/Users/DTOs/UserDetailDto.cs
@@ -6,5 +6,5 @@ namespace Leuze.Core.Domain.Domains.Users.DTOs
     /// <summary>
     /// 
     /// </summary>
-    public record UserDetailDto(Guid Id, string Name, string Email, bool IsAdUser, RoleItem Role);
+    public record UserDetailDto(Guid Id, string Name, string Email, bool IsAdUser, Guid? SeniorId, RoleItem Role);
 }
diff --git a/src/Core/Infrastructure/Leuze.Core.Infrastructure.Persistence/Repository/DomainUserRepository.cs b/src/Core/Infrastructure/Leuze.Core.Infrastructure.Persistence/Repository/DomainUserRepository.cs
index 2fe7209..b4725e0 100644
--- a/src/Core/Infrastructure/Leuze.Core.Infrastructure.Persistence/Repository/DomainUserRepository.cs
+++ b/src/Core/Infrastructure/Leuze.Core.Infrastructure.Persistence/Repository/DomainUserRepository.cs
@@ -67,7 +67,7 @@ namespace Leuze.Core.Infrastructure.Persistence.Repository
         /// <inheritdoc/>
         public async Task<UserDetailDto> GetDetailByIdAsync(Guid id)
             => await dbSet.Include(o => o.User).ThenInclude(o => o.Roles).Where(o => o.UserId == id)
-                .Select(o => new UserDetailDto(o.UserId, o.Name.FullName, o.EmailAddress.Email, o.User.IsAdUser, o.User.Roles.Select(a => new RoleItem(a.Id, a.Name)).FirstOrDefault()))
+                .Select(o => new UserDetailDto(o.UserId, o.Name.FullName, o.EmailAddress.Email, o.User.IsAdUser, o.SeniorUserId, o.User.Roles.Select(a => new RoleItem(a.Id, a.Name)).Single()))
                 .SingleOrDefaultAsync();
 
         /// <inheritdoc/>
diff --git a/src/Core/Infrastructure/Leuze.Core.Infrastructure.Persistence/Seeds/ApplicationSeed.cs b/src/Core/Infrastructure/Leuze.Core.Infrastructure.Persistence/Seeds/ApplicationSeed.cs
index 8b7ca4c..25fb9cd 100644
--- a/src/Core/Infrastructure/Leuze.Core.Infrastructure.Persistence/Seeds/ApplicationSeed.cs
+++ b/src/Core/Infrastructure/Leuze.Core.Infrastructure.Persistence/Seeds/ApplicationSeed.cs
@@ -24,9 +24,12 @@ namespace Leuze.Core.Infrastructure.Persistence.Seeds
         public static void Run(LeuzeDbContext context, UserManager<ApplicationUser> userManager, RoleManager<ApplicationRole> roleManager)
         {
             var permissions = context.Set<ApplicationPermission>().ToList();
-            var role1 = context.Set<ApplicationRole>().Single(o => o.Id == CreateRole("Administrátor", false, roleManager, permissions).Id);
-            var role2 = context.Set<ApplicationRole>().Single(o => o.Id == CreateRole("MA", false, roleManager, permissions).Id);
-            var role3 = context.Set<ApplicationRole>().Single(o => o.Id == CreateRole("Uživatel", true, roleManager, permissions).Id);
+            var role1 = CreateRole("Admin", false, roleManager, permissions);
+            var role2 = CreateRole("TL", false, roleManager, permissions);
+            var role3 = CreateRole("MA", true, roleManager, permissions);
+            CreateUser("Testovací admin", "admin@test.cz", role1, context, userManager);
+            CreateUser("Testovací TL", "tl@test.cz", role2, context, userManager);
+            CreateUser("Testovací MA", "ma@test.cz", role3, context, userManager);
         }
 
         private static void CreateUser(string name, string email, ApplicationRole role, LeuzeDbContext context, UserManager<ApplicationUser> userManager)
@@ -34,8 +37,9 @@ namespace Leuze.Core.Infrastructure.Persistence.Seeds
             ApplicationUser user = new(email, email, false);
             userManager.CreateAsync(user).Wait();
             userManager.AddPasswordAsync(user, "Test123*").Wait();
+            userManager.AddToRoleAsync(user, role.Name).Wait();
             user = context.Set<ApplicationUser>().Single(o => o.Id == user.Id);
-            DomainUser domainUser = new(user, new("Testovací uživatel"), new("test@test.cz"), null!);
+            DomainUser domainUser = new(user, new(name), new(email), null!);
             context.Add(domainUser);
             context.SaveChanges();
         }
