Example #1
0
        public static ApplicationThemeDataSet_ApplicationThemeDTO GetInstance(object key, string jbID)
        {
            if (key == null)
            {
                return(null);
            }
            var rawKey     = key.ToString();
            var parsedKey  = int.Parse(rawKey);
            var foundEntry = new DAL.Repository().GetById <zAppDev.DotNet.Framework.Identity.Model.ApplicationTheme>(parsedKey, false);

            if (foundEntry == null && !string.IsNullOrWhiteSpace(jbID))
            {
                if (int.TryParse(rawKey, out int _uniqueKey))
                {
                    var controller = new UserPreferencesController();
                    var method     = controller.GetType().GetMethod($"Get_{jbID}_DatasourceQueryable");
                    var records    = method.Invoke(controller, new object[] { null }) as IQueryable <zAppDev.DotNet.Framework.Identity.Model.ApplicationTheme>;
                    foundEntry = records.Where(c => c._GetUniqueIdentifier() == _uniqueKey).FirstOrDefault();
                }
            }
            if (foundEntry != null)
            {
                return(new ApplicationThemeDataSet_ApplicationThemeDTO(foundEntry));
            }
            return(null);
        }
        public void SetUp()
        {
            // Setup Mocks and Stub
            mockDataService = new Mock<IDataService>();
            mockCacheProvider = MockComponentProvider.CreateDataCacheProvider();

            DataService.RegisterInstance(mockDataService.Object);
            SetupCachingProviderHelper.SetupCachingProvider(mockCacheProvider);

            // Setup SUT
            userPrefencesController = new UserPreferencesController();
        }
Example #3
0
        public void SetUp()
        {
            // Setup Mocks and Stub
            mockDataService   = new Mock <IDataService>();
            mockCacheProvider = MockComponentProvider.CreateDataCacheProvider();

            DataService.RegisterInstance(mockDataService.Object);
            SetupCachingProviderHelper.SetupCachingProvider(mockCacheProvider);

            // Setup SUT
            userPrefencesController = new UserPreferencesController();
        }
Example #4
0
        public void FillDropDownsInitialValues(UserPreferencesViewModel original, UserPreferencesController _controller)
        {
            LanguageBox__InitialSelection = new List <SelectedItemInfo <ViewModels.UserPreferences.LanguageBoxDataSet_ApplicationLanguageDTO> >();
            LocaleBox__InitialSelection   = new List <SelectedItemInfo <ViewModels.UserPreferences.LocaleBoxDataSet_ApplicationLanguageDTO> >();
            DropdownApplicationThemeDataSet__InitialSelection = new List <SelectedItemInfo <ViewModels.UserPreferences.ApplicationThemeDataSet_ApplicationThemeDTO> >();
            if (original == null)
            {
                return;
            }
            var LanguageBoxInitiallySelectedItem = original?.ApplicationUser?.Profile == null
                                                   ? null
                                                   : zAppDev.DotNet.Framework.Identity.ProfileHelper.GetAllAvailableLanguages().Where(c => c.Id == original.ApplicationUser.Profile.LanguageLCID).FirstOrDefault();

            if (LanguageBoxInitiallySelectedItem != null)
            {
                LanguageBox__InitialSelection.Add
                (
                    new SelectedItemInfo <ViewModels.UserPreferences.LanguageBoxDataSet_ApplicationLanguageDTO>(new List <ViewModels.UserPreferences.LanguageBoxDataSet_ApplicationLanguageDTO>
                {
                    new LanguageBoxDataSet_ApplicationLanguageDTO(LanguageBoxInitiallySelectedItem)
                }, "_", false)
                );
            }
            var LocaleBoxInitiallySelectedItem = original?.ApplicationUser?.Profile == null
                                                 ? null
                                                 : zAppDev.DotNet.Framework.Identity.ProfileHelper.GetAllAvailableLanguages().Where(c => c.Id == original.ApplicationUser.Profile.LocaleLCID).FirstOrDefault();

            if (LocaleBoxInitiallySelectedItem != null)
            {
                LocaleBox__InitialSelection.Add
                (
                    new SelectedItemInfo <ViewModels.UserPreferences.LocaleBoxDataSet_ApplicationLanguageDTO>(new List <ViewModels.UserPreferences.LocaleBoxDataSet_ApplicationLanguageDTO>
                {
                    new LocaleBoxDataSet_ApplicationLanguageDTO(LocaleBoxInitiallySelectedItem)
                }, "_", false)
                );
            }
            var DropdownApplicationThemeDataSetInitiallySelectedItem = original?.ApplicationUser?.Profile == null
                    ? null
                    : zAppDev.DotNet.Framework.Identity.ProfileHelper.GetAllAvailableThemes().Where(c => c.Name == original.ApplicationUser.Profile.Theme).FirstOrDefault();

            if (DropdownApplicationThemeDataSetInitiallySelectedItem != null)
            {
                DropdownApplicationThemeDataSet__InitialSelection.Add
                (
                    new SelectedItemInfo <ViewModels.UserPreferences.ApplicationThemeDataSet_ApplicationThemeDTO>(new List <ViewModels.UserPreferences.ApplicationThemeDataSet_ApplicationThemeDTO>
                {
                    new ApplicationThemeDataSet_ApplicationThemeDTO(DropdownApplicationThemeDataSetInitiallySelectedItem)
                }, "_", false)
                );
            }
        }
Example #5
0
        public void Initialize()
        {
            AutoMapperConfig.Configure();

            mockCtx = new Mock <ApplicationDbContext>();

            // Mock user to get User ID
            var claim    = new Claim("id", "123");
            var identity = Mock.Of <ClaimsIdentity>(
                x => x.FindFirst(It.IsAny <string>()) == claim
                );

            controller = new UserPreferencesController(mockCtx.Object)
            {
                User = Mock.Of <IPrincipal>(x => x.Identity == identity)
            };
        }
        public UserPreferencesControllerTests()
        {
            options = new DbContextOptionsBuilder <HubDbContext>()
                      .UseInMemoryDatabase(Guid.NewGuid().ToString())
                      .Options;
            context = new HubDbContext(options);
            logger  = new Mock <ILogger <UserPreferencesController> >();
            var mockMapper = new MapperConfiguration(cfg =>
            {
                cfg.AddProfile(new MappingProfile());
            });

            mapper = mockMapper.CreateMapper();

            httpContext       = new DefaultHttpContext();
            controllerContext = new ControllerContext()
            {
                HttpContext = httpContext,
            };
            var config = new ConfigurationBuilder().Build();

            controller = new UserPreferencesController(context, logger.Object, mapper, config);
            controller.ControllerContext = controllerContext;
        }
 public UserPreferencesView()
 {
     _controller = new UserPreferencesController(this);
     InitializeComponent();
 }
Example #8
0
 private void UserPreferences_Load(object sender, EventArgs e)
 {
     _controller = new UserPreferencesController(this);
     checkClockTick.CheckedChanged += _controller.PreferencesChanged;
 }