Пример #1
0
        private void AddAdmin(BookshopDbContext context)
        {
            string       guid = Guid.NewGuid().ToString();
            IdentityRole r    = context.Roles.FirstOrDefault(x => x.Name == "Admin");

            if (r != null)
            {
                IdentityUserRole identityUserRole = new IdentityUserRole()
                {
                    RoleId = r.Id,
                    UserId = guid
                };
                string          password        = new PasswordHasher().HashPassword("Me.rahim29");
                var             s               = Guid.NewGuid().ToString("D");
                ApplicationUser applicationUser = new ApplicationUser()
                {
                    Id             = guid,
                    Email          = "*****@*****.**",
                    PhoneNumber    = "01673467667",
                    EmailConfirmed = true,
                    PasswordHash   = password,
                    Roles          = { identityUserRole },
                    UidId          = "011131148",
                    SecurityStamp  = s,
                    UserName       = "******"
                };
                context.Users.Add(applicationUser);
                context.SaveChanges();
            }
        }
Пример #2
0
 private void AddRoles(BookshopDbContext context)
 {
     string[] roles = { "Admin", "User" };
     foreach (string s in roles)
     {
         IdentityRole identityRole = context.Roles.FirstOrDefault(x => x.Name == s);
         if (identityRole == null)
         {
             IdentityRole role = new IdentityRole()
             {
                 Name = s
             };
             context.Roles.Add(role);
         }
         context.SaveChanges();
     }
 }
Пример #3
0
 private void AddCondition(BookshopDbContext context)
 {
     context.Conditions.AddOrUpdate(
         p => p.Name,
         new Condition()
     {
         Name = "Old"
     },
         new Condition()
     {
         Name = "Overall"
     },
         new Condition()
     {
         Name = "New"
     });
 }
Пример #4
0
 private void AddDepartments(BookshopDbContext context)
 {
     context.Departments.AddOrUpdate(
         p => p.Name,
         new Department()
     {
         Name = "CSE"
     },
         new Department()
     {
         Name = "EEE"
     },
         new Department()
     {
         Name = "BBA"
     }
         );
     context.SaveChanges();
 }
Пример #5
0
 private void AddCategory(BookshopDbContext context)
 {
     context.Categories.AddOrUpdate(
         p => p.Name,
         new Category()
     {
         Name = "Mathematics"
     },
         new Category()
     {
         Name = "Physics"
     },
         new Category()
     {
         Name = "English"
     }
         );
     context.SaveChanges();
 }
Пример #6
0
 public BookManager()
 {
     db = new BookshopDbContext();
 }
Пример #7
0
 public DepartmentManager()
 {
     db = new BookshopDbContext();
 }
Пример #8
0
 public ConditionManager()
 {
     db = new BookshopDbContext();
 }
Пример #9
0
 public CategoryManager()
 {
     db = new BookshopDbContext();
     db.Configuration.LazyLoadingEnabled   = true;
     db.Configuration.ProxyCreationEnabled = false;
 }
Пример #10
0
 public AccountController()
 {
     context = new BookshopDbContext();
 }