public bool Add(TEntity entity) { _context.Entry(entity).State = EntityState.Added; int changes = _context.SaveChanges(); return(changes > 0); }
private void SeedPermissions(List <PermissionSeedModel> permissionSeedModels) { List <PermissionEntity> existingPermissions = _context.Permissions.ToList(); IEnumerable <PermissionEntity> missingPermissions = permissionSeedModels .Where(x => !existingPermissions.Any(c => c.Name.ToUpper() == x.Name.ToUpper())) .Select(x => x.ToEntity()); _context.Permissions.AddRange(missingPermissions); int addPermissionChanges = _context.SaveChanges(); if (addPermissionChanges != missingPermissions.Count()) { _logger.LogCritical($"Failed to seed Permission."); throw new Exception("Failed to seed Permission"); } existingPermissions = _context.Permissions.ToList(); foreach (PermissionSeedModel permission in permissionSeedModels) { bool exists = existingPermissions .Where(x => x.Name == permission.Name) .Any(); if (!exists) { _logger.LogCritical($"Failed to seed Permission. Permission name {permission.Name}"); throw new Exception("Failed to seed Permission"); } } }
public ActionResult ChangeName(ChangeNameViewModel model) { if (!ModelState.IsValid) { return(View(model)); } string userId = User.Identity.GetUserId(); User user = UserManager.Users.FirstOrDefault(s => s.Id == userId); user.Name = model.Name; try { var result = UserManager.Update(user); ApplicationDbContext.SaveChanges(); return(RedirectToAction("Index", new { Message = "Имя изменено" })); } catch (Exception ex) { ModelState.AddModelError("", ex); } return(View(model)); }
public ActionResult Create(Genre genre) { if (ModelState.IsValid) { db.Genre.Add(genre); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(genre)); }
public ActionResult Create(Book book) { if (ModelState.IsValid) { db.Book.Add(book); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(book)); }
public void PlaceOrder() { // Get cart list List <CartVM> cart = Session["cart"] as List <CartVM>; // Get username string username = User.Identity.Name; int orderId = 0; using (IdentityDbContext dab = new IdentityDbContext()) { // Init OrderDTO Order orderDTO = new Order(); // Get user id var q = dab.Users.FirstOrDefault(x => x.UserName == username); string userId = q.Id; // Add to Orders and save orderDTO.UserId = userId; orderDTO.CreatedAt = DateTime.Now; db.Orders.Add(orderDTO); dab.SaveChanges(); // Get inserted id orderId = orderDTO.Id; // Init OrderDetailsDTO OrderDetails orderDetailsDTO = new OrderDetails(); // Add to OrderDetails foreach (var item in cart) { orderDetailsDTO.OrderId = orderId; orderDetailsDTO.UserId = userId; orderDetailsDTO.ProductId = item.ProductId; orderDetailsDTO.Quantity = item.Quantity; db.OrderDetails.Add(orderDetailsDTO); dab.SaveChanges(); db.SaveChanges(); } } // Reset session Session["cart"] = null; }
protected bool UpdateEffectiveDateToken(Users user, DateTime date) { if (user != null) { var now = DateTime.Now; var entity = _db.Users.Find(user.Id); entity.TokenEffectiveTimeStick = now.Ticks; entity.TokenEffectiveDate = now; _db.Update(user); var result = _db.SaveChanges(); return(result == 1); } return(false); }
/// <summary> /// Метод добавляет тестовые специализации. /// </summary> /// <param name="pdbc">Контекст.</param> /// <param name="name">Логин исполнителя.</param> private int AddSpec(IdentityDbContext pdbc, string name) { ExecutorSpecialization[] aSpecies = new ExecutorSpecialization[] { new ExecutorSpecialization() { SpecName = "Специализация1" }, new ExecutorSpecialization() { SpecName = "Специализация2" } }; UserEntity oExecutor = pdbc.AspNetUsers .Where(e => e.UserName .Equals(name)) .FirstOrDefault(); if (oExecutor.Specializations == null) { oExecutor.Specializations = aSpecies; } pdbc.SaveChanges(); UserEntity getExecutor = pdbc.AspNetUsers .Where(e => e.UserName .Equals(name)) .FirstOrDefault(); return(getExecutor.Specializations.Count()); }
public static IdentityDbContext Create() { var options = new DbContextOptionsBuilder <IdentityDbContext>() .UseInMemoryDatabase("TestIdentityDb") .Options; var context = new IdentityDbContext(options); context.Database.EnsureCreated(); context.Users.AddRange(new[] { new AppUser() { UserName = "******", Email = "*****@*****.**" }, new AppUser() { UserName = "******", Email = "*****@*****.**" } }); context.SaveChanges(); return(context); }
public ActionResult EditRole(ViewRole Role) { using (var context = new IdentityDbContext()) { try { var roleStore = new RoleStore <IdentityRole>(context); var roleManager = new RoleManager <IdentityRole>(roleStore); var Data = new IdentityRole { Id = Role.Id, Name = Role.Name }; roleManager.Update(Data); context.SaveChanges(); return(RedirectToAction("ListRole", "Account")); } catch { return(View()); } } }
public static IdentityDbContext Create() { var options = new DbContextOptionsBuilder <IdentityDbContext>() .UseInMemoryDatabase(nameof(IdentityDbContext)) .Options; var context = new IdentityDbContext(options); context.Database.EnsureCreated(); var user = new SecurityUser { Id = DefaultId, UserName = DefaultUserName, Email = "*****@*****.**", PasswordHash = "bddadsadsa" }; user.AddRefreshToken(DefaultRefreshToken, DefaultIp); context.AppUsers.Add(user); context.SaveChanges(); return(context); }
public virtual void Save() { try { _context.SaveChanges(); } catch (ValidationException e) { StringBuilder outputLines = new StringBuilder(); outputLines.AppendFormat("Validation Error: {0}", e.Message); if (e.Data.Count > 0) { outputLines.AppendLine("Additional Information"); foreach (DictionaryEntry eve in e.Data) { outputLines.AppendFormat("{0}: Key: \"{0}\", Value: \"{1}\"", DateTime.Now, eve.Key, eve.Value); } } //_log.Info(outputLines.ToString()); throw; } catch (Exception ex) { StringBuilder outputLines = new StringBuilder(); outputLines.Append(ex.Message); //_log.Info(outputLines.ToString()); throw; } }
public ActionResult <dynamic> DeleteUser([FromBody] DeleteUser user) { if (string.IsNullOrEmpty(user.username) || string.IsNullOrEmpty(user.selfusername)) { return(BadRequest()); } else { var admin = db.Users.FirstOrDefault(u => u.Username == user.selfusername && u.Status == AppConstants.Verified); if (admin?.Role == AppConstants.Admin) { var usr = db.Users.FirstOrDefault(u => u.Username == user.username); if (usr == null) { return(NotFound()); } usr.IsDeleted = true; var result = db.Users.Update(usr); db.SaveChanges(); return(NoContent()); } else { return(Unauthorized()); } } }
public static void InitializeDbForTest(IdentityDbContext identityDbContext, ApplicationDbContext applicationDbContext) { var email = "*****@*****.**"; var userName = "******"; var appUser = new AppUser() { Email = email, UserName = userName, NormalizedEmail = email.Normalize().ToUpperInvariant(), NormalizedUserName = userName.Normalize().ToUpperInvariant(), PasswordHash = "AQAAAAEAACcQAAAAEEcMpYe1+501CVRMdMPxzPgc/VAzvYg6ql2pB3Rex9Lq3qyzcN5+QSSW2sRLRwqbAw==" //hash for "testpassword" }; identityDbContext.Users.Add(appUser); identityDbContext.SaveChanges(); var userPrifile = new UserProfile() { Id = appUser.Id, FirstName = "Firstname", LastName = "Lastname", BirthDate = DateTime.Now, City = "Dushambe", Country = "USA" }; applicationDbContext.UserProfiles.Add(userPrifile); applicationDbContext.SaveChanges(); }
public override void AfterSchemaChange(IdentityDbContext context) { int start = 0; int take = 1000; while (true) { List <AppUserEntity> appUsers = context.Users .Where(x => x.TwoFactorEnabled == true) .Skip(start) .Take(take) .ToList(); foreach (AppUserEntity appUser in appUsers) { appUser.TwoFactor = Core.Services.Auth.TwoFactorAuth.Models.TwoFactorAuthenticationType.Authenticator; context.Users.Update(appUser); } int changes = context.SaveChanges(); if (changes != appUsers.Count) { throw new System.Exception("Failed to update users authenticator"); } if (appUsers.Count != take) { break; } } }
private bool IsValidUser(UserLogOnViewModel model) { model.GeoLocation = GeoLocationInfo.GetGeolocationInfo(); //проверяем, есть ли емейл в базе var user = _identityDbContext.ApplicationUsers.Include("ApplicationUserPasswordHistories") .SingleOrDefault(p => p.Email == model.Email); if (user == null) { throw new Exception($"Пользователя с email {model.Email} нет в базе"); } //проверяем, подходит ли пароль емейлу var userPassword = user.ApplicationUserPasswordHistories.SingleOrDefault(p => p.Password == model.Password); if (userPassword == null) { user.FailedSignInCount += 1; _identityDbContext.SaveChanges(); throw new Exception("Неверный пароль"); } if (userPassword != null && userPassword.InvalidatedDate != null) { user.FailedSignInCount += 1; _identityDbContext.SaveChanges(); throw new Exception("Аккаунт пользователя заблокирован"); } //добавляем строку нового входа в таблице ApplicationUserSignInHistories в БД ApplicationUserSignInHistory userSignInHistory = new ApplicationUserSignInHistory() { Id = Guid.NewGuid(), ApplicationUserId = user.Id, SignInTime = DateTime.Now, MachineIp = model.GeoLocation.ip, IpToGeoCountry = model.GeoLocation.country_name, IpToGeoCity = model.GeoLocation.city, IpToGeoLatitude = model.GeoLocation.latitude, IpToGeoLongitude = model.GeoLocation.longitude }; _identityDbContext.ApplicationUserSignInHistories.Add(userSignInHistory); _identityDbContext.SaveChanges(); return(true); }
private void CreateRoles(IdentityDbContext context) { if (context.Roles.Any(x => x.Name == "Adminstrator") == false) { context.Roles.Add(new IdentityRole("Administrater")); context.SaveChanges(); } }
public ActionResult Delete(string RoleName) { IdentityDbContext context = new IdentityDbContext(); var thisRole = context.Roles.Where(r => r.Name.Equals(RoleName, StringComparison.CurrentCultureIgnoreCase)).FirstOrDefault(); context.Roles.Remove(thisRole); context.SaveChanges(); return(RedirectToAction("Index")); }
public ApplicationUser Delete(string id) { ApplicationUser user = _context.Users.FirstOrDefault(x => x.Id == id.ToString()); if (user != null) { _context.Users.Remove(user); _context.SaveChanges(); } return(user); }
public Task LogUserActivityAsync(string userSessionId, UserActivity userActivity) { var userSession = _context.UserSessions.First(a => a.Id == userSessionId); if (userSession.UserActivities == null) { userSession.UserActivities = new List <UserActivity>(); } userSession.UserActivities.Add(userActivity); _context.SaveChanges(); return(Task.CompletedTask); }
public ActionResult Edit(IdentityUser applicationUser, string[] roleId) { if (ModelState.IsValid) { db.Entry(applicationUser).State = EntityState.Modified; db.SaveChanges(); var rolesForUser = UserManager.GetRoles(applicationUser.Id); foreach (var item in rolesForUser) { UserManager.RemoveFromRole(applicationUser.Id, item.ToString()); } if (roleId != null) { foreach (var item in roleId) { UserManager.AddToRole(applicationUser.Id, item.ToString()); } } return(RedirectToAction("Index")); } return(View(applicationUser)); }
/// <summary> /// Updates the database. /// </summary> /// <param name="app">The application.</param> /// <param name="env">The environmental variable.</param> private static void UpdateDatabase(IApplicationBuilder app, IWebHostEnvironment env) { using IServiceScope serviceScope = app.ApplicationServices .GetRequiredService <IServiceScopeFactory>() .CreateScope(); using IdentityDbContext context = serviceScope.ServiceProvider.GetService <IdentityDbContext>(); context.Database.Migrate(); if (!context.IdentityUser.Any()) { context.IdentityUser.AddRange(TestUsers.GetDefaultIdentityUsers(env.IsProduction())); context.SaveChanges(); } }
public Task <bool> DeactiveRefreshToken(string refreshToken) { var stillAvailable = _context.IssuedTokens.Any(a => !a.Deactive && a.ExpiredRefreshToken > DateTime.UtcNow && a.RefreshToken == refreshToken); if (stillAvailable) { var token = _context.IssuedTokens.First(a => a.RefreshToken == refreshToken); token.Deactive = true; _context.SaveChanges(); return(Task.FromResult(true)); } return(Task.FromResult(false)); }
public ActionResult <string> SignUp(UsersDto _UsersDto) { Users userObj = new Users(); userObj.Email = _UsersDto.Email; userObj.Password = _UsersDto.Password; userObj.RoleName = _UsersDto.RoleName; userObj.UserName = _UsersDto.UserName; db.Users.Add(userObj); db.SaveChanges(); var Token = this._jwtBuilder.GetToken(_UsersDto); return(Ok(Token)); }
public ActionResult Edit(Microsoft.AspNet.Identity.EntityFramework.IdentityRole role) { try { IdentityDbContext context = new IdentityDbContext(); context.Entry(role).State = System.Data.Entity.EntityState.Modified; context.SaveChanges(); return(RedirectToAction("Index")); } catch { return(View()); } }
/// <summary> /// Create roles /// </summary> /// <param name="roleName">a string represetning the name of the role to be created</param> public void removeRole(string roleName) { //check if the role exists if (MyRoleManager.RoleExists(roleName)) { var role = m_idbctx.Roles.Where(r => r.Name == roleName).FirstOrDefault(); m_idbctx.Roles.Remove(role); m_idbctx.SaveChanges(); } else { HttpContext.Current.Session["Error"] = roleName + " does not exist"; HttpContext.Current.Response.Redirect("~/UserPages/ErrorPage.aspx"); } }
private async Task SeedPermissionsRoles(List <PermissionSeedModel> permissionSeedModels, List <RoleSeedModel> roleSeedModels) { IEnumerable <PermissionEntity> permissions = permissionSeedModels.Select(x => x.ToEntity()); _context.Permissions.AddRange(permissions); int addPermissionChanges = _context.SaveChanges(); if (addPermissionChanges != permissions.Count()) { _logger.LogCritical($"Failed to seed Permission."); throw new Exception("failed_to_seed_permission"); } permissions = _context.Permissions.ToList(); List <PermissionRoleEntity> permissionRoleEntities = new List <PermissionRoleEntity>(); foreach (RoleSeedModel role in roleSeedModels) { RoleEntity roleEntity = role.ToEntity(); IdentityResult createRoleResult = await _roleManager.CreateAsync(roleEntity); if (!createRoleResult.Succeeded) { _logger.LogCritical($"Failed to seed Role. RoleName {role.Name}, Error {string.Join(" ", createRoleResult.Errors.Select(x => x.Description))}"); throw new Exception($"Failed to seed Role."); } IEnumerable <PermissionEntity> validPermissions = permissions .Where(x => role.Permissions.Contains(x.Name)); if (validPermissions.Count() != role.Permissions.Count) { _logger.LogCritical($"Missing role permission. Role: {role.Name}"); throw new Exception("Missing role permission"); } IEnumerable <PermissionRoleEntity> rolePermissions = validPermissions .Select(x => new PermissionRoleEntity( permissionId: x.Id, roleId: roleEntity.Id)); permissionRoleEntities.AddRange(rolePermissions); } _context.PermissionRole.AddRange(permissionRoleEntities); int addPermissionRoleChanges = _context.SaveChanges(); if (addPermissionRoleChanges != permissionRoleEntities.Count()) { _logger.LogCritical($"Failed to seed role permissions"); throw new Exception("Failed to seed role permissions"); } }
public async Task <IActionResult> Register(RegisterModel model) { User user = db.Users.FirstOrDefault(u => u.Login == model.Login); if (user == null) { db.Users.Add(new User { Login = model.Login, Password = model.Password }); db.SaveChanges(); await Authenticate(model.Login); // аутентификация return(RedirectToAction("GetList", "Owner")); } return(View(model)); }
private static void InitializeUser() { using (var context = new IdentityDbContext("VinilConnectionString")) { var user = new IdentityUser(); user.UserName = "******"; user.Email = "*****@*****.**"; user.LockoutEnabled = true; var userStore = new UserStore <IdentityUser>(context); var userManager = new UserManager <IdentityUser>(userStore); string password = "******"; userManager.Create(user, password); userManager.AddToRole(user.Id, "User"); context.SaveChanges(); } }
public async Task ExecuteAsync() { if (!_context.Set <Account>().Any()) { #region UserAccount var userAccount = new Account("*****@*****.**", "Ngô Văn", "Quý", null, null, null, true, "123456"); userAccount.SetTenant(Guid.Parse(AuthRole.SuperAdminId)); await _userManager.CreateAsync(userAccount, "123456"); var role = _context.Set <Role>().ToList(); var superAdminRole = _context.Set <Role>().Where(x => x.Name == AuthRole.SuperAdmin).FirstOrDefault(); userAccount.SetRole(superAdminRole.Id); _context.SaveChanges(); #endregion } }
public bool SaveRole(RoleViewModel model) { if (model.NewName == null || model.NewName == "") { return false; } using (var identityContext = new IdentityDbContext()) { try { identityContext.Roles.AddOrUpdate(r => r.Name, new IdentityRole() { Name = model.NewName }); return identityContext.SaveChanges() == 1; } catch { return false; } } }
public bool removeRole(RoleViewModel model) { if (model.CurrentName == null || model.CurrentName == "" || model.CurrentName == "Admin" || model.CurrentName == "Staff") { return false; } using (var identityContext = new IdentityDbContext()) { try { identityContext.Roles.Remove(identityContext.Roles.Where(r => r.Name == model.CurrentName).FirstOrDefault()); return identityContext.SaveChanges() == 1; } catch { return false; } } }
private void CreateUserAndRoles(IdentityDbContext context) { //Admin role for tenancy owner var adminRoleForTenancyOwner = context.Roles.FirstOrDefault(r => r.TenantId == null && r.Name == "Admin"); if (adminRoleForTenancyOwner == null) { adminRoleForTenancyOwner = context.Roles.Add(new Role(null, "Admin", "Admin")); context.SaveChanges(); context.Permissions.Add(new RolePermissionSetting { RoleId = adminRoleForTenancyOwner.Id, Name = "CanCreateUsers", IsGranted = true }); context.Permissions.Add(new RolePermissionSetting { RoleId = adminRoleForTenancyOwner.Id, Name = "CanEditUsers", IsGranted = true }); context.Permissions.Add(new RolePermissionSetting { RoleId = adminRoleForTenancyOwner.Id, Name = "CanDeleteUsers", IsGranted = true }); context.Permissions.Add(new RolePermissionSetting { RoleId = adminRoleForTenancyOwner.Id, Name = "CanDeleteRoles", IsGranted = true }); context.Permissions.Add(new RolePermissionSetting { RoleId = adminRoleForTenancyOwner.Id, Name = "CanCreateMenues", IsGranted = true }); context.Permissions.Add(new RolePermissionSetting { RoleId = adminRoleForTenancyOwner.Id, Name = "CanEditMenues", IsGranted = true }); context.Permissions.Add(new RolePermissionSetting { RoleId = adminRoleForTenancyOwner.Id, Name = "CanDeleteMenues", IsGranted = true }); context.SaveChanges(); } //Admin user for tenancy owner var adminUserForTenancyOwner = context.Users.FirstOrDefault(u => u.TenantId == null && u.UserName == "admin"); if (adminUserForTenancyOwner == null) { adminUserForTenancyOwner = context.Users.Add( new User { TenantId = null, UserName = "******", Name = "System", Surname = "Administrator", EmailAddress = "*****@*****.**", IsEmailConfirmed = true, Password = "******" //123qwe }); context.SaveChanges(); context.UserRoles.Add(new UserRole(adminUserForTenancyOwner.Id, adminRoleForTenancyOwner.Id)); context.SaveChanges(); } //Default tenant var defaultTenant = context.Tenants.FirstOrDefault(t => t.TenancyName == "Default"); if (defaultTenant == null) { defaultTenant = context.Tenants.Add(new Tenant("Default", "Default")); context.SaveChanges(); } //Admin role for 'Default' tenant var adminRoleForDefaultTenant = context.Roles.FirstOrDefault(r => r.TenantId == defaultTenant.Id && r.Name == "Admin"); if (adminRoleForDefaultTenant == null) { adminRoleForDefaultTenant = context.Roles.Add(new Role(defaultTenant.Id, "Admin", "Admin")); context.SaveChanges(); //Permission definitions for Admin of 'Default' tenant context.Permissions.Add(new RolePermissionSetting { RoleId = adminRoleForDefaultTenant.Id, Name = "CanCreateUsers", IsGranted = true }); context.Permissions.Add(new RolePermissionSetting { RoleId = adminRoleForDefaultTenant.Id, Name = "CanEditUsers", IsGranted = true }); context.Permissions.Add(new RolePermissionSetting { RoleId = adminRoleForDefaultTenant.Id, Name = "CanDeleteUsers", IsGranted = true }); context.Permissions.Add(new RolePermissionSetting { RoleId = adminRoleForDefaultTenant.Id, Name = "CanDeleteRoles", IsGranted = true }); context.Permissions.Add(new RolePermissionSetting { RoleId = adminRoleForDefaultTenant.Id, Name = "CanCreateMenues", IsGranted = true }); context.Permissions.Add(new RolePermissionSetting { RoleId = adminRoleForDefaultTenant.Id, Name = "CanEditMenues", IsGranted = true }); context.Permissions.Add(new RolePermissionSetting { RoleId = adminRoleForDefaultTenant.Id, Name = "CanDeleteMenues", IsGranted = true }); context.SaveChanges(); } //User role for 'Default' tenant var userRoleForDefaultTenant = context.Roles.FirstOrDefault(r => r.TenantId == defaultTenant.Id && r.Name == "User"); if (userRoleForDefaultTenant == null) { userRoleForDefaultTenant = context.Roles.Add(new Role(defaultTenant.Id, "User", "User")); context.SaveChanges(); //Permission definitions for User of 'Default' tenant //context.Permissions.Add(new RolePermissionSetting { RoleId = userRoleForDefaultTenant.Id, Name = "CanCreateMenues", IsGranted = true }); //context.SaveChanges(); } //Admin for 'Default' tenant var adminUserForDefaultTenant = context.Users.FirstOrDefault(u => u.TenantId == defaultTenant.Id && u.UserName == "admin"); if (adminUserForDefaultTenant == null) { adminUserForDefaultTenant = context.Users.Add( new User { TenantId = defaultTenant.Id, UserName = "******", Name = "System", Surname = "Administrator", EmailAddress = "*****@*****.**", IsEmailConfirmed = true, Password = "******" //123qwe }); context.SaveChanges(); context.UserRoles.Add(new UserRole(adminUserForDefaultTenant.Id, adminRoleForDefaultTenant.Id)); context.UserRoles.Add(new UserRole(adminUserForDefaultTenant.Id, userRoleForDefaultTenant.Id)); context.SaveChanges(); } //User 'Emre' for 'Default' tenant var emreUserForDefaultTenant = context.Users.FirstOrDefault(u => u.TenantId == defaultTenant.Id && u.UserName == "emre"); if (emreUserForDefaultTenant == null) { emreUserForDefaultTenant = context.Users.Add( new User { TenantId = defaultTenant.Id, UserName = "******", Name = "Yunus Emre", Surname = "Kalkan", EmailAddress = "*****@*****.**", IsEmailConfirmed = true, Password = "******" //123qwe }); context.SaveChanges(); context.UserRoles.Add(new UserRole(emreUserForDefaultTenant.Id, userRoleForDefaultTenant.Id)); context.SaveChanges(); } //Menu context.Menues.Add(new Menu( "Menues", "Menues", defaultTenant.Id, url: "#/menues", icon: "fa fa-file", requiredPermissionName: "Menues" ) ); context.Menues.Add(new Menu( "Users", "Users", defaultTenant.Id, url: "#/users", icon: "fa fa-user", requiredPermissionName: "Users" ) ); context.Menues.Add(new Menu( "Roles", "Roles", defaultTenant.Id, url: "#/roles", icon: "fa fa-group", requiredPermissionName: "Roles" ) ); context.Menues.Add(new Menu( "UserRoles", "UserRoles", defaultTenant.Id, url: "#/userroles", icon: "fa fa-userplus", requiredPermissionName: "UserRoles" ) ); context.Menues.Add(new Menu( "MenuRoles", "MenuRoles", defaultTenant.Id, url: "#/menuroles", icon: "fa fa-gears", requiredPermissionName: "MenuRoles" )); context.SaveChanges(); }