Esempio n. 1
0
        /// <summary>
        /// Constuctor.
        /// </summary>
        /// <param name="viewModelStore">The store this view model belongs to.</param>
        /// <param name="bCallIntialize">True if the Initialize method should be called.</param>
        protected BaseMainViewModel(ViewModelStore viewModelStore, bool bCallIntialize)
            : base(viewModelStore, false)
        {
            this.languagesViewModel = new LanguagesViewModel(this.ViewModelStore);
            this.availableModelModelContextViewModels = new List <ModelContextViewModel>();

            this.allModels           = new ObservableCollection <BaseDockingViewModel>();
            this.allModelsRO         = new ReadOnlyObservableCollection <BaseDockingViewModel>(allModels);
            this.unknownOpenedModels = new List <BaseDockingViewModel>();

            this.validateAllCommand      = new DelegateCommand(ValidateAllCommandExecuted);
            this.navigateBackwardCommand = new DelegateCommand(NavigateBackwardCommandExecuted, NavigateBackwardCommandCanExecute, true);
            this.navigateForwardCommand  = new DelegateCommand(NavigateForwardCommandExecuted, NavigateForwardCommandCanExecute, true);

            this.ModelData.PropertyChanged           += new System.ComponentModel.PropertyChangedEventHandler(ModelData_PropertyChanged);
            this.ModelData.BeforeModelContextChanged += new EventHandler(ModelData_BeforeModelContextChanged);
            this.ModelData.AfterModelContextChanged  += new EventHandler(ModelData_AfterModelContextChanged);

            if (this.activeViewModel == null)
            {
                this.activeViewModel = new NullDockingViewModel(this.ViewModelStore);
            }

            this.PreInitialize();
            if (bCallIntialize)
            {
                this.Initialize();
            }
        }
Esempio n. 2
0
        public ActionResult Languages(string SearchTerm = "")
        {
            try
            {
                IEnumerable <ILanguage> validEntries = ConfigDataCache.GetAll <ILanguage>();
                ApplicationUser         user         = null;
                string searcher = SearchTerm.Trim().ToLower();

                if (User.Identity.IsAuthenticated)
                {
                    user = UserManager.FindById(User.Identity.GetUserId());
                    StaffRank userRank = user.GetStaffRank(User);
                }

                LanguagesViewModel vModel = new LanguagesViewModel(validEntries.Where(item => item.Name.ToLower().Contains(searcher)))
                {
                    AuthedUser = user,
                    SearchTerm = SearchTerm,
                };

                return(View(vModel));
            }
            catch (Exception ex)
            {
                LoggingUtility.LogError(ex);
            }

            return(View());
        }
        public LanguagesPage()
        {
            InitializeComponent();

            viewModel = new LanguagesViewModel();

            ItemsSource = viewModel.Languages;
        }
Esempio n. 4
0
        public ActionResult Languages()
        {
            var user      = _svc.GetMember(User.Identity.GetUserId());
            var languages = _svc.GetAllLanguages();
            var model     = new LanguagesViewModel(languages, user);

            ViewBag.MemberId = model.User?.Id;
            return(View(model));
        }
        public void NavigateBack(LanguagesViewModel from, ResultCode code, SelectedLanguageResult result)
        {
            var controller = GetViewController <LanguagesViewController, LanguagesViewModel>(from);

            controller.SetResult(code, result);

            controller
            .GetNavigationController()
            .PopViewController(animated: true);
        }
Esempio n. 6
0
        public async Task <IActionResult> SignUpLanguages()
        {
            var userLanguages = HttpContext.Session.Get <SignUpProcess>("SignUpProcess").UserLanguages;
            var model         = new LanguagesViewModel();

            model.UserLanguagesJson = JsonConvert.SerializeObject(userLanguages);
            await model.BuildAsync(_db);

            return(View(model));
        }
Esempio n. 7
0
        public virtual ActionResult LanguagePanel()
        {
            var model = new LanguagesViewModel
            {
                Current = _localization.Current,
                All     = _localization.All()
            };

            return(PartialView(model));
        }
Esempio n. 8
0
        public ActionResult Index()
        {
            Uri hostWebUri = new Uri(Request.QueryString["SPHostUrl"]);
            Uri appWebUri  = new Uri(Request.QueryString["SPAppWebUrl"]);

            List <SupportedLanguage> languages = new List <SupportedLanguage>();
            List <Setting>           settings  = new List <Setting>();

            //Get supported cultures
            using (ClientContext ctx = TokenHelper.GetS2SClientContextWithWindowsIdentity(hostWebUri, Request.LogonUserIdentity))
            {
                IEnumerable <string> cultures = TranslationJob.EnumerateSupportedLanguages(ctx);
                ctx.ExecuteQuery();

                foreach (string culture in cultures)
                {
                    languages.Add(new SupportedLanguage()
                    {
                        Culture     = culture,
                        DisplayName = CultureInfo.GetCultureInfo(culture).DisplayName,
                        Selected    = false
                    });
                }
            }

            //Get the app settings
            using (ClientContext ctx = TokenHelper.GetS2SClientContextWithWindowsIdentity(appWebUri, Request.LogonUserIdentity))
            {
                List settingsList = ctx.Web.Lists.GetByTitle("Settings");
                ctx.Load(settingsList);

                ListItemCollection settingItems = settingsList.GetItems(CamlQuery.CreateAllItemsQuery());
                ctx.Load(settingItems);

                ctx.ExecuteQuery();

                foreach (ListItem settingItem in settingItems)
                {
                    settings.Add(new Setting()
                    {
                        Title = settingItem["Title"].ToString(),
                        Value = settingItem["Value"].ToString(),
                    });
                }
            }

            //Set up the ViewModel
            LanguagesViewModel viewModel = new LanguagesViewModel();

            viewModel.SelectedCulture = settings.Where <Setting>(s => s.Title == "Culture").FirstOrDefault().Value;
            viewModel.Destination     = settings.Where <Setting>(s => s.Title == "Destination").FirstOrDefault().Value;
            viewModel.Languages       = languages;
            viewModel.AppWebUrl       = Request.QueryString["SPAppWebUrl"]; //Save the AppWebUrl for future use
            return(View(viewModel));
        }
Esempio n. 9
0
        public virtual ActionResult LangPanel()
        {
            var lang  = DependencyResolver.Current.GetService <ILocalizationContext>();
            var model = new LanguagesViewModel
            {
                All     = lang.All(),
                Current = lang.Current
            };

            return(PartialView(model));
        }
Esempio n. 10
0
        // GET: Languages
        public ActionResult Index(int id)
        {
            var languages = _context.Languages.Where(l => l.PersonId == id).ToList();
            var viewModel = new LanguagesViewModel
            {
                Languages = languages,
                PersonId  = id
            };

            return(View(viewModel));
        }
Esempio n. 11
0
        public void NavigateBack(LanguagesViewModel from, ResultCode resultCode, SelectedLanguageResult result)
        {
            var languagesActivity = GetActivity <LanguagesActivity, LanguagesViewModel>(from);

            var intent = new Intent(languagesActivity, typeof(UserProfileActivity));

            intent.PutResult(result);

            languagesActivity.SetResult(resultCode, intent);
            languagesActivity.Finish();
        }
Esempio n. 12
0
        public void NavigateBack(LanguagesViewModel from, ResultCode code, SelectedLanguageResult?result)
        {
            var view = NavigationViewProvider.Get(from);

            NavigateBack(view, code, result, true);

            /* Here's what is done by Navigate() above:
             *
             * view.SetResult(code, result);
             * view.GetNavigationController().PopViewController(true);
             *
             */
        }
        public async Task InitializeAsync_Should_Initialize()
        {
            // arrange
            var repo = await SetupAsync();

            LanguagesViewModel vm = new LanguagesViewModel(repo);

            //act
            await vm.InitializeAsync();

            //assert
            vm.Languages.Count.ShouldBe(3);
        }
Esempio n. 14
0
        public async Task <IActionResult> SignUpLanguages(LanguagesViewModel model)
        {
            var signUpProcess = HttpContext.Session.Get <SignUpProcess>("SignUpProcess");

            signUpProcess.UserLanguages = model.GetUserLanguages();

            var info = await _signInManager.GetExternalLoginInfoAsync();

            if (info == null)
            {
                return(RedirectToAction(nameof(Login)));
            }
            var user = new User
            {
                UserName  = $"{info.LoginProvider}-{info.ProviderKey}",
                Email     = signUpProcess.Profile.Email,
                Name      = signUpProcess.Profile.Name,
                Country   = signUpProcess.Profile.Country,
                Gender    = signUpProcess.Profile.Gender,
                BirthYear = signUpProcess.Profile.GetBirthYear()
            };
            var result = await _userManager.CreateAsync(user);

            if (result.Succeeded)
            {
                result = await _userManager.AddLoginAsync(user, info);

                if (result.Succeeded)
                {
                    await _signInManager.SignInAsync(user, isPersistent : false);

                    _logger.LogInformation("User created an account using {Name} provider.", info.LoginProvider);
                    user.Languages = new List <UserLanguage>();
                    foreach (var language in signUpProcess.UserLanguages)
                    {
                        user.Languages.Add(new UserLanguage
                        {
                            LanguageId = language.Key,
                            Level      = language.Value
                        });
                    }
                    await _db.SaveChangesAsync();

                    return(Redirect("~/"));
                }
            }
            AddErrors(result);
            await model.BuildAsync(_db);

            return(View(model));
        }
Esempio n. 15
0
        public ActionResult Languages(string memberId)
        {
            if (string.IsNullOrEmpty(memberId))
            {
                return(RedirectToAction("Index"));
            }

            var user      = svc.GetMember(memberId);
            var languages = svc.GetAllLanguages();
            var model     = new LanguagesViewModel(languages, user);

            ViewBag.MemberId = model.User?.Id;
            return(View(model));
        }
Esempio n. 16
0
        public void NavigateBack(LanguagesViewModel from, ResultCode code, SelectedLanguageResult?result)
        {
            var view = NavigationViewProvider.Get(from);

            NavigateBack(view, code, result);

            /* Here's what is approximately done by Navigate() above:
             *
             * var source = view.GetActivity();
             * var intent = new Intent(source, typeof(UserProfileActivity));
             * intent.PutResult(result);
             * source.SetResult(code, intent);
             * source.Finish();
             *
             */
        }
Esempio n. 17
0
 public void SetActiveLanguage()
 {
     try
     {
         LanguageService _languageService = new LanguageService();
         var             _paramters       = new LanguagesViewModel()
         {
             LanguageId = (GetActiveLanguage() == 1) ? 2 : 1
         };
         int result = _languageService.Update(_paramters);
     }
     catch (Exception ex)
     {
         throw;
     }
 }
        public async Task Progress_Update_Should_Be_Saved()
        {
            // arrange
            var repo = await SetupAsync();

            LanguagesViewModel vm = new LanguagesViewModel(repo);
            await vm.InitializeAsync();

            var lang = vm.Languages[0];

            // act
            lang.GainProgressCommand.Execute(null);
            await vm.SaveAsync();

            // assert
            var model = await repo.GetOrDefaultAsync(lang.GetModel().ID);

            model.Progress.ShouldBe(0.2f);
            lang.Progress.ShouldBe(0.2f);
        }
 // Opens the language selection as modal page and pops them both when the language was selected.
 public async void OpenLanguageSelection()
 {
     _languageViewModel = _languageFactory(_selectedLocation);
     _languageViewModel.OnLanguageSelectedCommand = new Command <object>(OnLanguageSelected);
     await _navigator.PushAsync(_languageViewModel);
 }
 public Languages(EntitiesDataContext context)
 {
     InitializeComponent();
     DataContext = new LanguagesViewModel(context);
 }
Esempio n. 21
0
 public MoveLanguagesAvailableToKnownCommand(LanguagesViewModel vm)
 {
     _source      = vm.AvailableLanguages;
     _destination = vm.KnownLanguages;
     _owner       = vm;
 }
Esempio n. 22
0
        /// <summary>
        /// Clean up.
        /// </summary>
        protected override void OnDispose()
        {
            this.EventManager.GetEvent <ShowViewModelRequestEvent>().Unsubscribe(new Action <ShowViewModelRequestEventArgs>(ShowViewModel));
            this.EventManager.GetEvent <OpenViewModelEvent>().Unsubscribe(new Action <OpenViewModelEventArgs>(OpenViewModel));
            this.EventManager.GetEvent <CloseViewModelRequestEvent>().Unsubscribe(new Action <CloseViewModelRequestEventArgs>(CloseViewModel));
            this.EventManager.GetEvent <BringToFrontViewModelRequestEvent>().Unsubscribe(new Action <BringToFrontViewModelRequestEventArgs>(BringtToFrontViewModel));
            this.EventManager.GetEvent <SelectionChangedEvent>().Unsubscribe(new Action <SelectionChangedEventArgs>(ReactOnViewSelection));
            this.EventManager.GetEvent <ActiveViewChangedEvent>().Unsubscribe(new Action <ActiveViewChangedEventArgs>(ReactOnViewActivation));

            this.ModelData.PropertyChanged           -= new System.ComponentModel.PropertyChangedEventHandler(ModelData_PropertyChanged);
            this.ModelData.BeforeModelContextChanged -= new EventHandler(ModelData_BeforeModelContextChanged);
            this.ModelData.AfterModelContextChanged  -= new EventHandler(ModelData_AfterModelContextChanged);

            this.UnregisterModelDataEvents();

            // dispose view models
            if (this.LanguagesViewModel != null)
            {
                this.LanguagesViewModel.Dispose();
            }
            this.languagesViewModel = null;

            if (this.Ribbon != null)
            {
                this.Ribbon = null;
            }

            if (this.ActiveViewModel != null)
            {
                this.ActiveViewModel = null;
            }

            //if (this.SelectedModelContextViewModel != null)
            //    this.SelectedModelContextViewModel = null;

            foreach (ModelContextViewModel vm in this.availableModelModelContextViewModels)
            {
                vm.Dispose();
            }
            this.availableModelModelContextViewModels.Clear();

            foreach (BaseDockingViewModel vm in this.AllViewModels)
            {
                if (vm.IsDockingPaneVisible)
                {
                    this.EventManager.GetEvent <CloseViewModelRequestEvent>().Publish(new CloseViewModelRequestEventArgs(vm));
                }
                vm.Dispose();
            }
            this.AllViewModels.Clear();

            foreach (BaseDockingViewModel vm in this.UnknownOpenedModels)
            {
                if (vm.IsDockingPaneVisible)
                {
                    this.EventManager.GetEvent <CloseViewModelRequestEvent>().Publish(new CloseViewModelRequestEventArgs(vm, true));
                }
                vm.Dispose();
            }

            if (this.creditsViewModel != null)
            {
                this.creditsViewModel.Dispose();
            }
            this.creditsViewModel = null;

            if (this.furtherReadingViewModel != null)
            {
                this.furtherReadingViewModel.Dispose();
            }
            this.furtherReadingViewModel = null;

            this.navigationManager.Reset();

            base.OnDispose();
        }
Esempio n. 23
0
 public MoveLanguagesKnownToAvailableCommand(LanguagesViewModel vm)
 {
     _source      = vm.KnownLanguages;
     _destination = vm.AvailableLanguages;
 }