public void CreateDummySupplyItem(PortalDbContext context) { context.SupplyItems.Add(new Supply.SupplyItem() { Available = true, Code = "Test-123", InStock = 20, Name = "Gundamdam", Price = 20000, CreatorUser = context.Users.First(e=>e.Id == 1), CreatorUserId = 1, Weight = 10, CreationTime = DateTime.Now }); }
public void Dispose() { // Remove all created databases if (AllowMongoDB) { MongoClient mongoClient = new MongoClient(MongoDatabaseConenction.ConnectionString); mongoClient.DropDatabase(MongoDatabaseConenction.DataSource); } if (AllowPostgreSQL) { PortalDbContext postgreContext = GetPostgreSQLContext(); postgreContext.Database.EnsureDeleted(); postgreContext.Dispose(); LetPortalServiceManagementDbContext postgreServiceContext = GetPostgreServiceContext(); postgreServiceContext.Database.EnsureDeleted(); postgreServiceContext.Dispose(); } if (AllowSQLServer) { PortalDbContext sqlContext = GetSQLServerContext(); sqlContext.Database.EnsureDeleted(); sqlContext.Dispose(); LetPortalServiceManagementDbContext sqlServiceContext = GetSQLServerServiceContext(); sqlServiceContext.Database.EnsureDeleted(); sqlServiceContext.Dispose(); } if (AllowMySQL) { PortalDbContext mysqlContext = GetMySQLContext(); mysqlContext.Database.EnsureDeleted(); mysqlContext.Dispose(); LetPortalServiceManagementDbContext mysqlServiceContext = GetMySQLServiceContext(); mysqlServiceContext.Database.EnsureDeleted(); mysqlServiceContext.Dispose(); } GC.SuppressFinalize(this); }
private static void SeedData(PortalDbContext context) { var lang1 = new UserLanguage() { Description = "Deutsch" }; var lang2 = new UserLanguage() { Description = "English" }; context.UserLanguages.Add(lang1); context.UserLanguages.Add(lang2); context.UserDateTimeFormats.Add(new UserDateTimeFormat() { Description = "dd.MM.yyyy" }); context.UserDateTimeFormats.Add(new UserDateTimeFormat() { Description = "dd/MM/yyyy" }); context.UserDateTimeFormats.Add(new UserDateTimeFormat() { Description = "dd-MM-yyyy" }); context.UserDateTimeFormats.Add(new UserDateTimeFormat() { Description = "MM/dd/yyyy" }); context.UserDateTimeFormats.Add(new UserDateTimeFormat() { Description = "yyyy-MM-dd" }); context.PortalLinks.Add(new PortalLink() { IsAdmin = false, Language = lang1, Title = "UserManagement", Link = "/EventManagement/UserManagement" }); context.PortalLinks.Add(new PortalLink() { IsAdmin = false, Language = lang2, Title = "UserManagement", Link = "/EventManagement/UserManagement" }); context.SaveChanges(); }
public static void Seed(PortalDbContext context) { if (!context.Menus.Any(x => x.MenuName == "Main Menu")) { var menuItems = new List <MenuItem>(); menuItems.Add(new MenuItem { LinkText = "Home", LinkURL = "/Home/Index", LinkIcon = "fa-home" }); menuItems.Add(new MenuItem { LinkText = "Blog", LinkURL = "/Blog/Read/Index", LinkIcon = "fa-book" }); context.Menus.Add(new MenuSystem { MenuName = "Main Menu", MenuItems = menuItems }); context.SaveChanges(); } }
public ActionResult LogIn(LogInModel model) { if (ModelState.IsValid) { using (var db = PortalDbContext.Get()) { var user = db.Users.FirstOrDefault( u => u.Email.Equals(model.Email, StringComparison.InvariantCultureIgnoreCase)); if (user != null) { if (Hashing.CheckPassword(model.Password, user.PasswordHash)) { FormsAuthentication.SetAuthCookie(user.Id.ToString(), model.RememberMe); return(RedirectToAction("Edit")); } } } } return(View(model)); }
public virtual ActionResult Edit(string id, Web100Tango.ManageController.ManageMessageId? Message = null) { var Db = new PortalDbContext(); var user = Db.Users.First(u => u.UserName == id); var model = new EditUserViewModel(user); ViewBag.MessageId = Message; // Get connected logins var usr = UserManager.FindById(User.Identity.GetUserId()); if (usr == null) { return View("Error"); } var userLogins = UserManager.GetLogins(user.Id); var fbLogin = userLogins.SingleOrDefault(l => l.LoginProvider == "Facebook"); var gLogin = userLogins.SingleOrDefault(l => l.LoginProvider == "Google"); model.FacebookId = fbLogin != null ? fbLogin.ProviderKey : null; model.GoogleId = gLogin != null ? gLogin.ProviderKey : null; return View(model); }
public async Task Same_Student_Can_Not_Be_Added_To_Class() { var options = new DbContextOptionsBuilder <PortalDbContext>() .UseInMemoryDatabase(databaseName: "Same_Student_Db") .Options; using (var context = new PortalDbContext(options)) { var service = new StudentService(context); await service.Add(new Domain.Entities.Student() { ClassId = 1, Age = 19, GPA = 3.2f, Name = "Jones" }); await Assert.ThrowsAsync <Exception>(async() => { await service.Add(new Domain.Entities.Student() { ClassId = 1, Age = 18, GPA = 3.0f, Name = "Jones" }); }); } }
public static void Initialize(PortalDbContext context) { context.Database.EnsureCreated(); if (!context.Foods.Any()) { context.Foods.Add(new Food("Desert", new Mony(1000), FoodType.Desert) { TimeCreated = DateTime.Now, IsEnable = true, Description = "Description1" }); context.Foods.Add(new Food("kola", new Mony(2000), FoodType.Drink) { TimeCreated = DateTime.Now, IsEnable = true, Description = "Description2" }); context.Foods.Add(new Food("chicken", new Mony(3000), FoodType.Meal) { TimeCreated = DateTime.Now, IsEnable = true, Description = "Description3" }); context.SaveChanges(); } if (!context.Users.Any()) { context.Users.Add(new User { Email = "*****@*****.**", FirstName = "admin", LastName = "admin", IsEnable = true, Password = "******", Phone = "999999", TimeCreated = DateTime.Now, UserName = "******", SocialAddress = new SocialMedia(instageram: "ins_admin", telegramCanal: "telchanal_admin", telegramGroup: "telgroup_admin"), Address = new Domain.Address(street: "monzeviler", city: "cankaya", state: "ankara", country: "Turkiye", zipcode: "12345") }); context.SaveChanges(); } }
public HomeController(PortalDbContext dbContext) { _dbContext = dbContext; }
public OrganizationInformationRepository(PortalDbContext context) { this.context = context; }
public virtual ActionResult Delete(string id) { var Db = new PortalDbContext(); var user = Db.Users.First(u => u.UserName == id); var model = new EditUserViewModel(user); if (user == null) { return HttpNotFound(); } return View(model); }
public TenantRoleAndUserBuilder(PortalDbContext context, int tenantId) { _context = context; _tenantId = tenantId; }
public TestSubscriptionPaymentBuilder(PortalDbContext context, int tenantId) { _context = context; _tenantId = tenantId; }
public UsersService(PortalDbContext _dbContext) { this._dbContext = _dbContext; }
public DetailsModel(PortalDbContext db) { _db = db; }
public PagePartialService(PortalDbContext context) { _context = context; }
public virtual async Task<ActionResult> Edit(EditUserViewModel model) { if (ModelState.IsValid) { string userid = null; string username = model.OldUserName ?? model.UserName; using (var Db = new PortalDbContext()) { var user = Db.Users.First(u => u.UserName == username); // Update the user data: user.UserName = model.UserName; user.FirstName = model.FirstName; user.LastName = model.LastName; user.Email = model.Email; Db.Entry(user).State = System.Data.Entity.EntityState.Modified; userid = user.Id; await Db.SaveChangesAsync(); } // Update Facebook and Google id var usr = await UserManager.FindByIdAsync(userid); if (usr == null) { return View("Error"); } var userLogins = await UserManager.GetLoginsAsync(userid); // Facebook var fbLogin = userLogins.SingleOrDefault(l => l.LoginProvider == "Facebook"); if (fbLogin != null) { if (model.FacebookId.Empty()) { var res = await UserManager.RemoveLoginAsync(userid, fbLogin); if (!res.Succeeded) DependencyResolver.Current.GetService<IAlertsProvider>().Add(string.Format("Failed to remove Facebook account: {0}", string.Concat(res.Errors)), AlertType.Danger, true); } else { if (fbLogin.ProviderKey != model.FacebookId) { await UserManager.RemoveLoginAsync(userid, fbLogin); await UserManager.AddLoginAsync(usr.Id, new UserLoginInfo("Facebook", model.FacebookId)); } } } else { if (model.FacebookId.NotEmpty()) { var res = await UserManager.AddLoginAsync(usr.Id, new UserLoginInfo("Facebook", model.FacebookId)); if (!res.Succeeded) DependencyResolver.Current.GetService<IAlertsProvider>().Add(string.Format("Failed to add Facebook account: {0}", string.Concat(res.Errors)), AlertType.Danger, true); } } // Google var gLogin = userLogins.SingleOrDefault(l => l.LoginProvider == "Google"); if (gLogin != null) { if (model.GoogleId.Empty()) { var res = await UserManager.RemoveLoginAsync(userid, gLogin); if (!res.Succeeded) DependencyResolver.Current.GetService<IAlertsProvider>().Add(string.Format("Failed to remove Google account: {0}", string.Concat(res.Errors)), AlertType.Danger, true); } else { if (gLogin.ProviderKey != model.GoogleId) { await UserManager.RemoveLoginAsync(userid, fbLogin); await UserManager.AddLoginAsync(usr.Id, new UserLoginInfo("Facebook", model.FacebookId)); } } } else { if (model.GoogleId.NotEmpty()) { var res = await UserManager.AddLoginAsync(usr.Id, new UserLoginInfo("Google", model.GoogleId)); if (!res.Succeeded) DependencyResolver.Current.GetService<IAlertsProvider>().Add(string.Format("Failed to add Google account: {0}", string.Concat(res.Errors)), AlertType.Danger, true); } } return RedirectToAction("Index"); } // If we got this far, something failed, redisplay form return View(model); }
public virtual ActionResult Index() { var Db = new PortalDbContext(); var users = Db.Users; var model = new List<EditUserViewModel>(); foreach (var user in users) { var u = new EditUserViewModel(user); model.Add(u); } return View(model); }
public virtual ActionResult UserRoles(string id) { var Db = new PortalDbContext(); var user = Db.Users.First(u => u.UserName == id); var model = new SelectUserRolesViewModel(user); return View(model); }
public virtual ActionResult DeleteConfirmed(string id) { var Db = new PortalDbContext(); var user = Db.Users.First(u => u.UserName == id); Db.Users.Remove(user); Db.SaveChanges(); return RedirectToAction("Index"); }
public MenuService(PortalDbContext context, IUserService userService, IRoleService roleService) { _context = context; _userService = userService; _roleService = roleService; }
public DynamicListEFRepository(PortalDbContext context) : base(context) { _context = context; }
public DefaultLanguagesCreator(PortalDbContext context) { _context = context; }
public HostRoleAndUserCreator(PortalDbContext context) { _context = context; }
public virtual ActionResult Test() { var dbc = new PortalDbContext(); var a = dbc.Users.Count(); return View(a); }
public FoodService(PortalDbContext db, IMapper mapper, ILogger <FoodService> logger) { _db = db; _mapper = mapper; _logger = logger; }
public UserCreateCommandHandler(PortalDbContext db, IMapper mapper) { _db = db; _mapper = mapper; }
public static void Seed(PortalDbContext context) { var fonts = new List <Font>(); if (!context.Fonts.Any()) { fonts.Add(new Font { FontName = "Portal", FontPath = "/Content/Fonts/Emeric.ttf", FontType = "truetype", DateAdded = DateTime.Now, DateUpdated = DateTime.Now }); fonts.Add(new Font { FontName = "AllerDisplay", FontPath = "/Content/Fonts/AllerDisplay.ttf", FontType = "truetype", DateAdded = DateTime.Now, DateUpdated = DateTime.Now }); fonts.Add(new Font { FontName = "Anagram", FontPath = "/Content/Fonts/Anagram.ttf", FontType = "truetype", DateAdded = DateTime.Now, DateUpdated = DateTime.Now }); fonts.Add(new Font { FontName = "Architect", FontPath = "/Content/Fonts/ArchitectsDaughter.ttf", FontType = "truetype", DateAdded = DateTime.Now, DateUpdated = DateTime.Now }); fonts.Add(new Font { FontName = "Blackout", FontPath = "/Content/Fonts/Blackout-2am.ttf", FontType = "truetype", DateAdded = DateTime.Now, DateUpdated = DateTime.Now }); fonts.Add(new Font { FontName = "BreeSerif", FontPath = "/Content/Fonts/BreeSerif-regular.otf", FontType = "opentype", DateAdded = DateTime.Now, DateUpdated = DateTime.Now }); fonts.Add(new Font { FontName = "Bubblegum", FontPath = "/Content/Fonts/BubblegumSans-Regular.otf", FontType = "opentype", DateAdded = DateTime.Now, DateUpdated = DateTime.Now }); fonts.Add(new Font { FontName = "CarbonType", FontPath = "/Content/Fonts/carbontype.ttf", FontType = "truetype", DateAdded = DateTime.Now, DateUpdated = DateTime.Now }); fonts.Add(new Font { FontName = "DancingScript", FontPath = "/Content/Fonts/dancingscript-regular.otf", FontType = "opentype", DateAdded = DateTime.Now, DateUpdated = DateTime.Now }); fonts.Add(new Font { FontName = "GrandHotel-Regular", FontPath = "/Content/Fonts/grandhotel-regular.otf", FontType = "opentype", DateAdded = DateTime.Now, DateUpdated = DateTime.Now }); fonts.Add(new Font { FontName = "Organo", FontPath = "/Content/Fonts/Organo.ttf", FontType = "truetype", DateAdded = DateTime.Now, DateUpdated = DateTime.Now }); fonts.Add(new Font { FontName = "Railway", FontPath = "/Content/Fonts/Railway.otf", FontType = "opentype", DateAdded = DateTime.Now, DateUpdated = DateTime.Now }); fonts.Add(new Font { FontName = "Roboto-Bold", FontPath = "/Content/Fonts/roboto-bold.ttf", FontType = "truetype", DateAdded = DateTime.Now, DateUpdated = DateTime.Now }); fonts.Add(new Font { FontName = "Sniglet", FontPath = "/Content/Fonts/sniglet-regular.otf", FontType = "opentype", DateAdded = DateTime.Now, DateUpdated = DateTime.Now }); fonts.Add(new Font { FontName = "OpenSans-Regular", FontPath = "/Content/Fonts/OpenSans-Regular.ttf", FontType = "truetype", DateAdded = DateTime.Now, DateUpdated = DateTime.Now }); context.Fonts.AddRange(fonts); } context.SaveChanges(); var themes = new List <CustomTheme>(); if (!context.Themes.Any()) { var fontList = context.Fonts.ToList(); var defaultFont = fontList.First(x => x.FontName == "Portal"); var allerDisplayFont = fontList.First(x => x.FontName == "AllerDisplay"); var snigletFont = fontList.First(x => x.FontName == "Sniglet"); themes.Add(new CustomTheme { ThemeName = "Portal", TitleFontId = defaultFont.FontId, TextFontId = defaultFont.FontId, IsDefault = true, DateAdded = DateTime.Now, DateUpdated = DateTime.Now, TitleLargeFontSize = 35, TitleMediumFontSize = 35, TitleSmallFontSize = 24, TitleTinyFontSize = 22, TextStandardFontSize = 20, PageBackgroundColour = "#000000", MenuBackgroundColour = "#000000", MenuTextColour = "#9d9d9d" }); themes.Add(new CustomTheme { ThemeName = "Impact", TitleFontId = allerDisplayFont.FontId, TextFontId = snigletFont.FontId, IsDefault = false, DateAdded = DateTime.Now, DateUpdated = DateTime.Now, TitleLargeFontSize = 35, TitleMediumFontSize = 35, TitleSmallFontSize = 24, TitleTinyFontSize = 22, TextStandardFontSize = 20, PageBackgroundColour = "#000000", MenuBackgroundColour = "#000000", MenuTextColour = "#9d9d9d" }); context.Themes.AddRange(themes); } context.SaveChanges(); }
public ClassService(PortalDbContext db, ClassValidator validator) { _db = db; _validator = validator; }
public void Build(PortalDbContext context) { context.DisableAllFilters(); //CreateUserAndRoles(context); }
public DefaultEditionCreator(PortalDbContext context) { _context = context; }
public void CreateUserAndRoles(PortalDbContext context) { //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(); //} //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(); context.Permissions.Add(new RolePermissionSetting { RoleId = adminRoleForDefaultTenant.Id, Name = "CanAccessAdministrator", IsGranted = false }); context.Permissions.Add(new RolePermissionSetting { RoleId = adminRoleForDefaultTenant.Id, Name = "CanAccessLogistic", IsGranted = false}); context.Permissions.Add(new RolePermissionSetting { RoleId = adminRoleForDefaultTenant.Id, Name = "CanAccessAccounting", IsGranted = false }); context.Permissions.Add(new RolePermissionSetting { RoleId = adminRoleForDefaultTenant.Id, Name = "CanAccessMarketing", IsGranted = false }); context.Permissions.Add(new RolePermissionSetting { RoleId = adminRoleForDefaultTenant.Id, Name = "CanAccessRetailer", IsGranted = false }); context.SaveChanges(); } //User role for 'Default' tenant var userRoleForDefaultTenant = context.Roles.FirstOrDefault(r => r.TenantId == defaultTenant.Id && r.Name == "User"); if (userRoleForDefaultTenant == null) { var roleLogistic = context.Roles.Add(new Role(defaultTenant.Id, "Logistic", "Logistic")); context.SaveChanges(); var roleAccounting = context.Roles.Add(new Role(defaultTenant.Id, "Accounting", "Accounting")); context.SaveChanges(); var roleMarketing = context.Roles.Add(new Role(defaultTenant.Id, "Marketing", "Marketing")); context.SaveChanges(); userRoleForDefaultTenant = context.Roles.Add(new Role(defaultTenant.Id, "Retailer", "Retailer") { IsDefault = true }); context.SaveChanges(); context.Permissions.Add(new RolePermissionSetting { RoleId = roleAccounting.Id, Name = "CanAccessAccounting", IsGranted = true }); context.Permissions.Add(new RolePermissionSetting { RoleId = roleMarketing.Id, Name = "CanAccessMarketing", IsGranted = true }); context.Permissions.Add(new RolePermissionSetting { RoleId = roleLogistic.Id, Name = "CanAccessLogistic", IsGranted = true }); context.Permissions.Add(new RolePermissionSetting { RoleId = userRoleForDefaultTenant.Id, Name = "CanAccessRetailer", 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(); } }
public FontService(PortalDbContext context) { _context = context; }
public TestEditionsBuilder(PortalDbContext context) { _context = context; }
public BookCreator(PortalDbContext context) { _context = context; }
public TestOrganizationUnitsBuilder(PortalDbContext context, int tenantId) { _context = context; _tenantId = tenantId; }
public LocalizationEFRepository(PortalDbContext context) : base(context) { _context = context; }
public OrderRepository(PortalDbContext db) { _db = db; }
public PostCommentService(PortalDbContext context) { _context = context; }
public HomeController(PortalDbContext c) { _context = c; }
public DownloaderAgentController(PortalDbContext dbContext, ILogger <DownloaderAgentController> logger) { _logger = logger; _dbContext = dbContext; }