Beispiel #1
0
        private static void CreateDefaultVehicleModels(PanelMasterMVC5SeparateDbContext _context)
        {
            var data = new List <VehicleModels>();

            data.AddRange(GetDefaultVehicleModelss());
            _context.VehicleModel.AddOrUpdate(data.ToArray());
            _context.SaveChanges();
        }
Beispiel #2
0
        private static void CreateDefaultTowOperator(PanelMasterMVC5SeparateDbContext _context)
        {
            var data = new List <TowOperator>();

            data.AddRange(GetDefaultTowOperators());
            _context.TowOperators.AddOrUpdate(data.ToArray());
            _context.SaveChanges();
        }
Beispiel #3
0
        public void Create()
        {
            _context.DisableAllFilters();

            new TestOrganizationUnitsBuilder(_context, _tenantId).Create();

            _context.SaveChanges();
        }
Beispiel #4
0
        private static void CreateDefaultVendorMain(PanelMasterMVC5SeparateDbContext _context)
        {
            var data = new List <VendorMain>();

            data.AddRange(GetDefaultVendorMains());
            _context.VendorMain.AddOrUpdate(data.ToArray());
            _context.SaveChanges();
        }
Beispiel #5
0
        private static void CreateDefaultBanks(PanelMasterMVC5SeparateDbContext _context)
        {
            var data = new List <Banks>();

            data.AddRange(GetDefaultBanks());
            _context.Banks.AddOrUpdate(data.ToArray());
            _context.SaveChanges();
        }
        public void Create()
        {
            new DefaultEditionCreator(_context).Create();
            new DefaultLanguagesCreator(_context).Create();
            new HostRoleAndUserCreator(_context).Create();
            new DefaultSettingsCreator(_context).Create();

            _context.SaveChanges();
        }
Beispiel #7
0
        private static void AddInsurerMaster(PanelMasterMVC5SeparateDbContext _context)
        {
            var data = new List <InsurerMaster>();

            data.AddRange(GetDefaultInsurerMasters());
            _context.InsurerMasters.AddOrUpdate(data.ToArray());
            _context.SaveChanges();

            var pics = new List <InsurerPics>();
            var Ids  = (from f in data
                        select new InsurerMaster()
            {
                Id = f.Id, LogoPicture = f.LogoPicture
            }).ToList();

            pics.AddRange(GetDefaultInsurerMastersPics(Ids));
            _context.InsurerPics.AddOrUpdate(pics.ToArray());
            _context.SaveChanges();
        }
        private OrganizationUnit CreateOU(string displayName, string code, long?parentId = null)
        {
            var ou = _context.OrganizationUnits.Add(new OrganizationUnit(_tenantId, displayName, parentId)
            {
                Code = code
            });

            _context.SaveChanges();
            return(ou);
        }
        private void AddSettingIfNotExists(string name, string value, int?tenantId = null)
        {
            if (_context.Settings.Any(s => s.Name == name && s.TenantId == tenantId && s.UserId == null))
            {
                return;
            }

            _context.Settings.Add(new Setting(tenantId, null, name, value));
            _context.SaveChanges();
        }
Beispiel #10
0
        private static void CreateDefaultVehicleMakes(PanelMasterMVC5SeparateDbContext _context)
        {
            var data = new List <VehicleMake>();

            data.AddRange(GetDefaultVehicleMakess());
            _context.VehicleMake.AddOrUpdate(data.ToArray());
            _context.SaveChanges();


            var pics = new List <VehicleModelLogos>();
            var Ids  = (from f in data
                        select new VehicleMake()
            {
                Id = f.Id, LogoPicture = f.LogoPicture
            }).ToList();

            pics.AddRange(GetDefaultVehicleMakeLogos(Ids));
            _context.VehicleModelLogo.AddOrUpdate(pics.ToArray());
            _context.SaveChanges();
        }
Beispiel #11
0
        private void CreateDefaultTenant()
        {
            //Default tenant

            var defaultTenant = _context.Tenants.FirstOrDefault(t => t.TenancyName == MultiTenancy.Tenant.DefaultTenantName);

            if (defaultTenant == null)
            {
                defaultTenant = new MultiTenancy.Tenant(MultiTenancy.Tenant.DefaultTenantName, MultiTenancy.Tenant.DefaultTenantName);

                var defaultEdition = _context.Editions.FirstOrDefault(e => e.Name == EditionManager.DefaultEditionName);
                if (defaultEdition != null)
                {
                    defaultTenant.EditionId = defaultEdition.Id;
                }

                _context.Tenants.Add(defaultTenant);
                _context.SaveChanges();
            }
        }
        private void AddLanguageIfNotExists(ApplicationLanguage language)
        {
            if (_context.Languages.Any(l => l.TenantId == language.TenantId && l.Name == language.Name))
            {
                return;
            }

            _context.Languages.Add(language);

            _context.SaveChanges();
        }
        private void CreateDefaultTowOperators()
        {
            var defaultTenant = _context.Tenants.Select(x => x.Id).ToList();

            if (defaultTenant != null)
            {
                var data = new List <TowOperator>();
                foreach (var s in defaultTenant)
                {
                    data.AddRange(GetTowOperators(s));
                }
                _context.TowOperators.AddOrUpdate(data.ToArray());
                _context.SaveChanges();
            }
        }
Beispiel #14
0
        private void CreateEditions()
        {
            var defaultEdition = _context.Editions.FirstOrDefault(e => e.Name == EditionManager.DefaultEditionName);

            if (defaultEdition == null)
            {
                defaultEdition = new Edition {
                    Name = EditionManager.DefaultEditionName, DisplayName = EditionManager.DefaultEditionName
                };
                _context.Editions.Add(defaultEdition);
                _context.SaveChanges();

                //TODO: Add desired features to the standard edition, if wanted!
            }

            if (defaultEdition.Id > 0)
            {
                CreateFeatureIfNotExists(defaultEdition.Id, AppFeatures.ChatFeature, true);
                CreateFeatureIfNotExists(defaultEdition.Id, AppFeatures.TenantToTenantChatFeature, true);
                CreateFeatureIfNotExists(defaultEdition.Id, AppFeatures.TenantToHostChatFeature, true);
            }
        }
Beispiel #15
0
        static void Main(string[] args)
        {
            var context = new PanelMasterMVC5SeparateDbContext("Data Source=localhost;Initial Catalog=PanelMasterMVC5Separate;Integrated Security=True");

            System.Console.WriteLine("Would you like to add master data to tblJobstatus? Y/N");
            var anwser = System.Console.ReadLine();

            if (anwser?.ToLower() == "Y".ToLower())
            {
                AddJobstatus(context);
            }

            System.Console.WriteLine("Would you like to add master data to CreateDefaultVehicleMakes? Y /N");
            anwser = System.Console.ReadLine();
            if (anwser?.ToLower() == "Y".ToLower())
            {
                CreateDefaultVehicleMakes(context);
            }

            System.Console.WriteLine("Would you like to add master data to CreateDefaultVehicleModels? Y /N");
            anwser = System.Console.ReadLine();
            if (anwser?.ToLower() == "Y".ToLower())
            {
                CreateDefaultVehicleModels(context);
            }

            System.Console.WriteLine("Would you like to add master data to CreateDefaultVendorMain? Y /N");
            anwser = System.Console.ReadLine();
            if (anwser?.ToLower() == "Y".ToLower())
            {
                CreateDefaultVendorMain(context);
            }

            System.Console.WriteLine("Would you like to add master data to tblInsurerMaster? Y /N");
            anwser = System.Console.ReadLine();
            if (anwser?.ToLower() == "Y".ToLower())
            {
                AddInsurerMaster(context);
            }

            System.Console.WriteLine("Would you like to add master data to CreateBrokerMaster? Y /N");
            anwser = System.Console.ReadLine();
            if (anwser?.ToLower() == "Y".ToLower())
            {
                CreateBrokerMaster(context);
            }

            System.Console.WriteLine("Would you like to add master data to tblCountries? Y /N");
            anwser = System.Console.ReadLine();
            if (anwser?.ToLower() == "Y".ToLower())
            {
                AddCountries();
            }

            System.Console.WriteLine("Would you like to add master data to CreateDefaultBanks ? Y /N");
            anwser = System.Console.ReadLine();
            if (anwser?.ToLower() == "Y".ToLower())
            {
                CreateDefaultBanks(context);
            }

            System.Console.WriteLine("Would you like to add master data to tblTowOperator? Y /N");
            anwser = System.Console.ReadLine();
            if (anwser?.ToLower() == "Y".ToLower())
            {
                CreateDefaultTowOperator(context);
            }

            System.Console.WriteLine("Would you like to add master data to tblJobstatusMask? Y /N");
            anwser = System.Console.ReadLine();
            if (anwser?.ToLower() == "Y".ToLower())
            {
                AddJobstatusMask(context);
            }

            System.Console.WriteLine("Would you like to create for tblNotProceedReason? Y/N");
            anwser = System.Console.ReadLine();

            if (anwser?.ToLower() == "Y".ToLower())
            {
                NotProceedReason(context);
            }

            System.Console.WriteLine("Would you like to create master SignOnPlans? Y/N");
            anwser = System.Console.ReadLine();

            if (anwser?.ToLower() == "Y".ToLower())
            {
                SignOnPlans(context);
            }

            System.Console.WriteLine("Would you like to create master Quote Status? Y/N");
            anwser = System.Console.ReadLine();

            if (anwser?.ToLower() == "Y".ToLower())
            {
                AddQuoteStatus(context);
            }

            System.Console.WriteLine("Would you like to create master repair types? Y/N");
            anwser = System.Console.ReadLine();

            if (anwser?.ToLower() == "Y".ToLower())
            {
                AddRepairTypes(context);
            }

            System.Console.WriteLine("Would you like to create master quote categories? Y/N");
            anwser = System.Console.ReadLine();

            if (anwser?.ToLower() == "Y".ToLower())
            {
                AddQuoteCategories(context);
            }

            try
            {
                context.SaveChanges();
            }
            catch (Exception e)
            {
                DisplayMessage(e.Message);
            }

            System.Console.WriteLine("complete");
            System.Console.ReadLine();
        }
Beispiel #16
0
        private void CreateRolesAndUsers()
        {
            //Admin role

            var adminRole = _context.Roles.FirstOrDefault(r => r.TenantId == _tenantId && r.Name == StaticRoleNames.Tenants.Admin);

            if (adminRole == null)
            {
                adminRole = _context.Roles.Add(new Role(_tenantId, StaticRoleNames.Tenants.Admin, StaticRoleNames.Tenants.Admin)
                {
                    IsStatic = true, RoleCategoryID = 1
                });
                _context.SaveChanges();

                //Grant all permissions to admin role
                var permissions = PermissionFinder
                                  .GetAllPermissions(new AppAuthorizationProvider(false))
                                  .Where(p => p.MultiTenancySides.HasFlag(MultiTenancySides.Tenant))
                                  .ToList();

                foreach (var permission in permissions)
                {
                    _context.Permissions.Add(
                        new RolePermissionSetting
                    {
                        TenantId  = _tenantId,
                        Name      = permission.Name,
                        IsGranted = true,
                        RoleId    = adminRole.Id
                    });
                }

                _context.SaveChanges();
            }

            //User role

            var userRole = _context.Roles.FirstOrDefault(r => r.TenantId == _tenantId && r.Name == StaticRoleNames.Tenants.User);

            if (userRole == null)
            {
                _context.Roles.Add(new Role(_tenantId, StaticRoleNames.Tenants.User, StaticRoleNames.Tenants.User)
                {
                    IsStatic = true, IsDefault = true, RoleCategoryID = 2
                });
                _context.SaveChanges();
            }

            var Claims_HandlerRole = _context.Roles.FirstOrDefault(r => r.TenantId == _tenantId && r.Name == StaticRoleNames.Tenants.Claims_Handler);

            if (Claims_HandlerRole == null)
            {
                _context.Roles.Add(new Role(_tenantId, StaticRoleNames.Tenants.Claims_Handler, StaticRoleNames.Tenants.Claims_Handler)
                {
                    IsStatic = true, IsDefault = false, RoleCategoryID = 3
                });
                _context.SaveChanges();
            }

            var CSARole = _context.Roles.FirstOrDefault(r => r.TenantId == _tenantId && r.Name == StaticRoleNames.Tenants.CSA);

            if (CSARole == null)
            {
                _context.Roles.Add(new Role(_tenantId, StaticRoleNames.Tenants.CSA, StaticRoleNames.Tenants.CSA)
                {
                    IsStatic = true, IsDefault = false, RoleCategoryID = 4
                });
                _context.SaveChanges();
            }

            var PartsBuyerRole = _context.Roles.FirstOrDefault(r => r.TenantId == _tenantId && r.Name == StaticRoleNames.Tenants.Parts_Buyer);

            if (PartsBuyerRole == null)
            {
                _context.Roles.Add(new Role(_tenantId, StaticRoleNames.Tenants.Parts_Buyer, StaticRoleNames.Tenants.Parts_Buyer)
                {
                    IsStatic = true, IsDefault = false, RoleCategoryID = 5
                });
                _context.SaveChanges();
            }

            var EstimatorRole = _context.Roles.FirstOrDefault(r => r.TenantId == _tenantId && r.Name == StaticRoleNames.Tenants.Estimator);

            if (EstimatorRole == null)
            {
                _context.Roles.Add(new Role(_tenantId, StaticRoleNames.Tenants.Estimator, StaticRoleNames.Tenants.Estimator)
                {
                    IsStatic = true, IsDefault = false, RoleCategoryID = 6
                });
                _context.SaveChanges();
            }

            var KeyAccountManagerRole = _context.Roles.FirstOrDefault(r => r.TenantId == _tenantId && r.Name == StaticRoleNames.Tenants.Key_Accounts_Manager);

            if (KeyAccountManagerRole == null)
            {
                _context.Roles.Add(new Role(_tenantId, StaticRoleNames.Tenants.Key_Accounts_Manager, StaticRoleNames.Tenants.Key_Accounts_Manager)
                {
                    IsStatic = true, IsDefault = false, RoleCategoryID = 7
                });
                _context.SaveChanges();
            }

            var SwithchboardRole = _context.Roles.FirstOrDefault(r => r.TenantId == _tenantId && r.Name == StaticRoleNames.Tenants.Swithchboard);

            if (SwithchboardRole == null)
            {
                _context.Roles.Add(new Role(_tenantId, StaticRoleNames.Tenants.Swithchboard, StaticRoleNames.Tenants.Swithchboard)
                {
                    IsStatic = true, IsDefault = false, RoleCategoryID = 8
                });
                _context.SaveChanges();
            }

            var PartsReceiverRole = _context.Roles.FirstOrDefault(r => r.TenantId == _tenantId && r.Name == StaticRoleNames.Tenants.Parts_Receiver);

            if (PartsReceiverRole == null)
            {
                _context.Roles.Add(new Role(_tenantId, StaticRoleNames.Tenants.Parts_Receiver, StaticRoleNames.Tenants.Parts_Receiver)
                {
                    IsStatic = true, IsDefault = false, RoleCategoryID = 9
                });
                _context.SaveChanges();
            }

            var CostingClerkRole = _context.Roles.FirstOrDefault(r => r.TenantId == _tenantId && r.Name == StaticRoleNames.Tenants.Costing_Clerk);

            if (CostingClerkRole == null)
            {
                _context.Roles.Add(new Role(_tenantId, StaticRoleNames.Tenants.Costing_Clerk, StaticRoleNames.Tenants.Costing_Clerk)
                {
                    IsStatic = true, IsDefault = false, RoleCategoryID = 10
                });
                _context.SaveChanges();
            }

            var FinancialManagerRole = _context.Roles.FirstOrDefault(r => r.TenantId == _tenantId && r.Name == StaticRoleNames.Tenants.Financial_Manager);

            if (FinancialManagerRole == null)
            {
                _context.Roles.Add(new Role(_tenantId, StaticRoleNames.Tenants.Financial_Manager, StaticRoleNames.Tenants.Financial_Manager)
                {
                    IsStatic = true, IsDefault = false, RoleCategoryID = 11
                });
                _context.SaveChanges();
            }

            var InsurerRole = _context.Roles.FirstOrDefault(r => r.TenantId == _tenantId && r.Name == StaticRoleNames.Tenants.Insurer);

            if (InsurerRole == null)
            {
                _context.Roles.Add(new Role(_tenantId, StaticRoleNames.Tenants.Insurer, StaticRoleNames.Tenants.Insurer)
                {
                    IsStatic = true, IsDefault = false, RoleCategoryID = 12
                });
                _context.SaveChanges();
            }

            var BrokerRole = _context.Roles.FirstOrDefault(r => r.TenantId == _tenantId && r.Name == StaticRoleNames.Tenants.Broker);

            if (BrokerRole == null)
            {
                _context.Roles.Add(new Role(_tenantId, StaticRoleNames.Tenants.Broker, StaticRoleNames.Tenants.Broker)
                {
                    IsStatic = true, IsDefault = false, RoleCategoryID = 13
                });
                _context.SaveChanges();
            }

            //admin user

            var adminUser = _context.Users.FirstOrDefault(u => u.TenantId == _tenantId && u.UserName == User.AdminUserName);

            if (adminUser == null)
            {
                adminUser = User.CreateTenantAdminUser(_tenantId, "*****@*****.**", "123qwe");
                adminUser.IsEmailConfirmed = true;
                adminUser.ShouldChangePasswordOnNextLogin = true;
                adminUser.IsActive = true;

                _context.Users.Add(adminUser);
                _context.SaveChanges();

                //Assign Admin role to admin user
                _context.UserRoles.Add(new UserRole(_tenantId, adminUser.Id, adminRole.Id));
                _context.SaveChanges();

                //User account of admin user
                if (_tenantId == 1)
                {
                    _context.UserAccounts.Add(new UserAccount
                    {
                        TenantId     = _tenantId,
                        UserId       = adminUser.Id,
                        UserName     = User.AdminUserName,
                        EmailAddress = adminUser.EmailAddress
                    });
                    _context.SaveChanges();
                }
            }
        }
Beispiel #17
0
        private void CreateRolesCategory()
        {
            var AdminRoleDesc = _context.RolesCategory.FirstOrDefault(r => r.Description.ToLower() == StaticRoleNames.Tenants.Admin.ToLower());

            if (AdminRoleDesc == null)
            {
                AdminRoleDesc = _context.RolesCategory.Add(
                    new RolesCategories.RolesCategory {
                    Description = StaticRoleNames.Tenants.Admin,
                    Enabled     = true
                });

                _context.SaveChanges();
            }

            var UserRoleDesc = _context.RolesCategory.FirstOrDefault(r => r.Description.ToLower() == StaticRoleNames.Tenants.User.ToLower());

            if (UserRoleDesc == null)
            {
                UserRoleDesc = _context.RolesCategory.Add(
                    new RolesCategories.RolesCategory
                {
                    Description = StaticRoleNames.Tenants.User,
                    Enabled     = true
                });

                _context.SaveChanges();
            }

            var ClaimHandlerRoleDesc = _context.RolesCategory.FirstOrDefault(r => r.Description.ToLower() == StaticRoleNames.Tenants.Claims_Handler.ToLower());

            if (ClaimHandlerRoleDesc == null)
            {
                ClaimHandlerRoleDesc = _context.RolesCategory.Add(
                    new RolesCategories.RolesCategory
                {
                    Description = StaticRoleNames.Tenants.Claims_Handler,
                    Enabled     = true
                });

                _context.SaveChanges();
            }

            var CSARoleDesc = _context.RolesCategory.FirstOrDefault(r => r.Description.ToLower() == StaticRoleNames.Tenants.CSA.ToLower());

            if (CSARoleDesc == null)
            {
                CSARoleDesc = _context.RolesCategory.Add(
                    new RolesCategories.RolesCategory
                {
                    Description = StaticRoleNames.Tenants.CSA,
                    Enabled     = true
                });

                _context.SaveChanges();
            }

            var PartsBuyerRoleDesc = _context.RolesCategory.FirstOrDefault(r => r.Description.ToLower() == StaticRoleNames.Tenants.Parts_Buyer.ToLower());

            if (PartsBuyerRoleDesc == null)
            {
                PartsBuyerRoleDesc = _context.RolesCategory.Add(
                    new RolesCategories.RolesCategory
                {
                    Description = StaticRoleNames.Tenants.Parts_Buyer,
                    Enabled     = true
                });

                _context.SaveChanges();
            }

            var EstimatorRoleDesc = _context.RolesCategory.FirstOrDefault(r => r.Description.ToLower() == StaticRoleNames.Tenants.Estimator.ToLower());

            if (EstimatorRoleDesc == null)
            {
                EstimatorRoleDesc = _context.RolesCategory.Add(
                    new RolesCategories.RolesCategory
                {
                    Description = StaticRoleNames.Tenants.Estimator,
                    Enabled     = true
                });

                _context.SaveChanges();
            }

            var KeyAccountsManagerRoleDesc = _context.RolesCategory.FirstOrDefault(r => r.Description.ToLower() == StaticRoleNames.Tenants.Key_Accounts_Manager.ToLower());

            if (KeyAccountsManagerRoleDesc == null)
            {
                KeyAccountsManagerRoleDesc = _context.RolesCategory.Add(
                    new RolesCategories.RolesCategory
                {
                    Description = StaticRoleNames.Tenants.Key_Accounts_Manager,
                    Enabled     = true
                });

                _context.SaveChanges();
            }

            var SwithchboardRoleDesc = _context.RolesCategory.FirstOrDefault(r => r.Description.ToLower() == StaticRoleNames.Tenants.Swithchboard.ToLower());

            if (SwithchboardRoleDesc == null)
            {
                SwithchboardRoleDesc = _context.RolesCategory.Add(
                    new RolesCategories.RolesCategory
                {
                    Description = StaticRoleNames.Tenants.Swithchboard,
                    Enabled     = true
                });

                _context.SaveChanges();
            }

            var PartsReceiverRoleDesc = _context.RolesCategory.FirstOrDefault(r => r.Description.ToLower() == StaticRoleNames.Tenants.Parts_Receiver.ToLower());

            if (PartsReceiverRoleDesc == null)
            {
                PartsReceiverRoleDesc = _context.RolesCategory.Add(
                    new RolesCategories.RolesCategory
                {
                    Description = StaticRoleNames.Tenants.Parts_Receiver,
                    Enabled     = true
                });

                _context.SaveChanges();
            }

            var CostingClerkRoleDesc = _context.RolesCategory.FirstOrDefault(r => r.Description.ToLower() == StaticRoleNames.Tenants.Costing_Clerk.ToLower());

            if (CostingClerkRoleDesc == null)
            {
                CostingClerkRoleDesc = _context.RolesCategory.Add(
                    new RolesCategories.RolesCategory
                {
                    Description = StaticRoleNames.Tenants.Costing_Clerk,
                    Enabled     = true
                });

                _context.SaveChanges();
            }

            var FinancialManagerRoleDesc = _context.RolesCategory.FirstOrDefault(r => r.Description.ToLower() == StaticRoleNames.Tenants.Financial_Manager.ToLower());

            if (FinancialManagerRoleDesc == null)
            {
                FinancialManagerRoleDesc = _context.RolesCategory.Add(
                    new RolesCategories.RolesCategory
                {
                    Description = StaticRoleNames.Tenants.Financial_Manager,
                    Enabled     = true
                });

                _context.SaveChanges();
            }

            var InsurerRoleDesc = _context.RolesCategory.FirstOrDefault(r => r.Description.ToLower() == StaticRoleNames.Tenants.Insurer.ToLower());

            if (InsurerRoleDesc == null)
            {
                InsurerRoleDesc = _context.RolesCategory.Add(
                    new RolesCategories.RolesCategory
                {
                    Description = StaticRoleNames.Tenants.Insurer,
                    Enabled     = true
                });

                _context.SaveChanges();
            }

            var BrokerRoleDesc = _context.RolesCategory.FirstOrDefault(r => r.Description.ToLower() == StaticRoleNames.Tenants.Broker.ToLower());

            if (BrokerRoleDesc == null)
            {
                BrokerRoleDesc = _context.RolesCategory.Add(
                    new RolesCategories.RolesCategory
                {
                    Description = StaticRoleNames.Tenants.Broker,
                    Enabled     = true
                });

                _context.SaveChanges();
            }

            var NoneRoleDesc = _context.RolesCategory.FirstOrDefault(r => r.Description.ToLower() == StaticRoleNames.Tenants.None.ToLower());

            if (NoneRoleDesc == null)
            {
                NoneRoleDesc = _context.RolesCategory.Add(
                    new RolesCategories.RolesCategory
                {
                    Description = StaticRoleNames.Tenants.None,
                    Enabled     = true
                });

                _context.SaveChanges();
            }
        }