Skip to content

Commit

Permalink
Merge pull request ALCOpenSource#196 from PrinceJK/Backend_Messaging
Browse files Browse the repository at this point in the history
seeded mentor and mentor managers
  • Loading branch information
Honeyloveet committed Jun 21, 2023
2 parents 757522f + 254d66d commit 7d2824c
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions backend/src/mms.Infrastructure/Seeder/Seeder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using Microsoft.AspNetCore.Identity;
using Microsoft.Extensions.DependencyInjection;
using mms.Domain.Entities;
using mms.Domain.Enums;
using mms.Infrastructure.Context;
using mms.Infrastructure.Policy;

Expand Down Expand Up @@ -128,10 +129,23 @@ private static async Task SeederRun(UserManager<AppUser> userManager, Applicatio
AppUserId = user2.Id,
});

foreach (AppUser appUser in users)
for (var index = 0; index < users.Count; index++)
{
await userManager.CreateAsync(appUser, Password);
await userManager.AddToRoleAsync(appUser, Policies.Admin);
switch (index)
{
case 0:
await userManager.CreateAsync(users[index], Password);
await userManager.AddToRoleAsync(users[index], Policies.Admin);
break;
case 1:
await userManager.CreateAsync(users[index], Password);
await userManager.AddToRoleAsync(users[index], Policies.Mentor);
break;
default:
await userManager.CreateAsync(users[index], Password);
await userManager.AddToRoleAsync(users[index], Policies.Manager);
break;
}
}

await context.UserNotifications.AddRangeAsync(usersNotifications);
Expand Down

0 comments on commit 7d2824c

Please sign in to comment.