Skip to content

Commit

Permalink
Final Changes of Course
Browse files Browse the repository at this point in the history
  • Loading branch information
AbrarKhalifa committed Jul 19, 2024
1 parent d03d823 commit d8718c5
Show file tree
Hide file tree
Showing 66 changed files with 1,612 additions and 3,545 deletions.
63 changes: 30 additions & 33 deletions Bulky.DataAccess/DBInitializer/DBInitializer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,48 +40,45 @@ public void Initialize()
_db.Database.Migrate();
}

}catch (Exception ex)
}catch (Exception ex) { }



// Create roles if they are not created
if (!_roleManager.RoleExistsAsync(SD.Role_Customer).GetAwaiter().GetResult())
{

_roleManager.CreateAsync(new IdentityRole(SD.Role_Customer)).GetAwaiter().GetResult();
_roleManager.CreateAsync(new IdentityRole(SD.Role_Employee)).GetAwaiter().GetResult();
_roleManager.CreateAsync(new IdentityRole(SD.Role_Admin)).GetAwaiter().GetResult();
_roleManager.CreateAsync(new IdentityRole(SD.Role_Company)).GetAwaiter().GetResult();

// Create roles if they are not created
if (!_roleManager.RoleExistsAsync(SD.Role_Customer).GetAwaiter().GetResult())

//if roles are not created, then we will create admin user as well

_userManager.CreateAsync(new ApplicationUser
{
_roleManager.CreateAsync(new IdentityRole(SD.Role_Customer)).GetAwaiter().GetResult();
_roleManager.CreateAsync(new IdentityRole(SD.Role_Employee)).GetAwaiter().GetResult();
_roleManager.CreateAsync(new IdentityRole(SD.Role_Admin)).GetAwaiter().GetResult();
_roleManager.CreateAsync(new IdentityRole(SD.Role_Company)).GetAwaiter().GetResult();


//if roles are not created, then we will create admin user as well

_userManager.CreateAsync(new ApplicationUser
{
UserName = "[email protected]",
Email = "[email protected]",
Name = "Abrar Khalifa",
PhoneNumber = "6353666071",
StreetAddress = "Barkociya Road",
State = "Gujarat",
City = "Nadiad",
PostalCode = "387001"
}, "admin@1234").GetAwaiter().GetResult();


ApplicationUser user = _db.ApplicationUsers.FirstOrDefault(u=>u.Email == "[email protected]");

_userManager.AddToRoleAsync(user, SD.Role_Admin).GetAwaiter().GetResult();



}
UserName = "[email protected]",
Email = "[email protected]",
Name = "Abrar Khalifa",
PhoneNumber = "6353666071",
StreetAddress = "Barkociya Road",
State = "Gujarat",
PostalCode = "387001",
City = "Nadiad"
}, "Admin@1234").GetAwaiter().GetResult();

return;

ApplicationUser user = _db.ApplicationUsers.FirstOrDefault(u => u.Email == "[email protected]");

_userManager.AddToRoleAsync(user, SD.Role_Admin).GetAwaiter().GetResult();

}

return;




}
}
}
1 change: 1 addition & 0 deletions Bulky.DataAccess/Data/ApplicationDbContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public ApplicationDbContext(DbContextOptions<ApplicationDbContext> options) : ba

public DbSet<Category> Categories { get; set; }
public DbSet<Product> Products { get; set; }
public DbSet<ProductImage> ProductImages { get; set; }
public DbSet<Company> Companies { get; set; }
public DbSet<ShoppingCart> ShoppingCarts { get; set; }
public DbSet<ApplicationUser> ApplicationUsers { get; set; }
Expand Down

This file was deleted.

35 changes: 0 additions & 35 deletions Bulky.DataAccess/Migrations/20240701114454_addCategoryToDb.cs

This file was deleted.

This file was deleted.

45 changes: 0 additions & 45 deletions Bulky.DataAccess/Migrations/20240701120329_seedCategory.cs

This file was deleted.

Loading

0 comments on commit d8718c5

Please sign in to comment.