public ActionResult CreateDictionary() { DictionaryViewModel model = new DictionaryViewModel(); model.State = true; return(View(model)); }
public ActionResult EditDictionary(DictionaryViewModel model) { DictionaryDAL ddal = new DictionaryDAL(); ddal.Update(model.CastDB(model)); ddal.AcceptAllChange(); return(Content("Success")); }
public ActionResult Index() { var model = new DictionaryViewModel { TreeViewModel = GetTreeViewModel() }; return(View(model)); }
protected override void Arrange() { DictionaryService = new Mock <IDictionaryService>(); if (ShouldConstruct) { DictionaryViewModel = new DictionaryViewModel(DictionaryService.Object); } }
private void ApplyChanges() { DictionaryViewModel.ApplyChanges(); OtherViewModel.ApplyChanges(); PointingAndSelectingViewModel.ApplyChanges(); SoundsViewModel.ApplyChanges(); VisualsViewModel.ApplyChanges(); WordsViewModel.ApplyChanges(); }
public DictionaryView( ) { InitializeComponent(); DictionaryViewModel dic = new DictionaryViewModel(); DataContext = dic; _ctx = new DiamondDBEntities(); this.Language = XmlLanguage.GetLanguage(Thread.CurrentThread.CurrentCulture.Name); // potrzebne do zmiany wyswietlanej waluty $ -> zl }
public DictionaryController( IOptions <Dictionary> dictionaryConfiguration, IWordsRepository wordsRepository, IDictionaryService dictionaryService) { _dictionaryConfiguration = dictionaryConfiguration.Value; _dictionaryService = dictionaryService; _wordsRepository = wordsRepository; _dictionaryModel = new DictionaryViewModel(); }
public void Should_Return_View_With_Model_Containing_Some_Words(string searchValue) { _wordsRepository.GetSearchedWords(searchValue).Returns(new List <WordResponseModel> { new WordResponseModel(searchValue, 1), new WordResponseModel(searchValue, 2) }); ViewResult result = (ViewResult)_dictionaryController.Search(searchValue); DictionaryViewModel model = (DictionaryViewModel)result.Model; Assert.IsTrue(model.wordsDictionary.Count > 1); }
public IActionResult Index(int pageNum) { var list = _wordService.GetDictionary(pageNum).Values.SelectMany(x => x); //.ToList(); var pager = new Pager(pageNum, _wordService.TotalItems()); var viewModel = new DictionaryViewModel { Items = list, //.Skip((pageNum - 1) * 100).Take(pager.PageSize), Pager = pager, }; return(View(viewModel)); }
public virtual ActionResult Edit(DictionaryViewModel model) { if (ModelState.IsValid) { var dictionary = _dictionariesRepository.GetById(model.BaseDictionaryId); dictionary.DictionaryType = model.DictionaryType; dictionary.Value = model.Value; _dictionariesRepository.Update(dictionary); return(RedirectToAction(MVC.Admin.Dictionaries.List())); } return(View(model)); }
public IActionResult Dictionary() { var viewModel = new DictionaryViewModel(); viewModel = ModelForDictionary(viewModel); // FOR READ FROM TXT FILE AND WRITE TO DATABASE if (_dbContext.RussianDictionaries.FirstOrDefault() == null) { DefaultDataDB dict = new DefaultDataDB(_dbContext); dict.Dictionary(); } return(View("~/Views/Widgets/Dictionary.cshtml", viewModel)); }
public ManagementViewModel( IAudioService audioService, IDictionaryService dictionaryService) { //Instantiate child VMs DictionaryViewModel = new DictionaryViewModel(dictionaryService); OtherViewModel = new OtherViewModel(); PointingAndSelectingViewModel = new PointingAndSelectingViewModel(); SoundsViewModel = new SoundsViewModel(audioService); VisualsViewModel = new VisualsViewModel(); WordsViewModel = new WordsViewModel(dictionaryService); //Instantiate interaction requests and commands ConfirmationRequest = new InteractionRequest <Confirmation>(); OkCommand = new DelegateCommand <Window>(Ok); //Can always click Ok CancelCommand = new DelegateCommand <Window>(Cancel); //Can always click Cancel }
public virtual ActionResult Create(DictionaryViewModel model) { if (ModelState.IsValid) { var dictionary = new BaseDictionary() { DictionaryType = model.DictionaryType, Value = model.Value }; _dictionariesRepository.Create(dictionary); return(RedirectToAction(MVC.Admin.Dictionaries.List())); } return(View(model)); }
public async Task <HttpResponseMessage> CreateDictionary(DictionaryViewModel vm) { Dictionary newDictionary = new Dictionary() { Name = vm.Name, Description = vm.Description, SourceLanguage = vm.SourceLanguage, TargetLanguage = vm.TargetLanguage, IsPublic = vm.IsPublic, CreationDate = DateTime.Now, LastChangeDate = DateTime.Now, OwnerId = User.Identity.Name }; _dbContext.CreateDictionary(newDictionary); await _dbContext.SaveDbChangesAsync(); return(Request.CreateResponse(HttpStatusCode.OK, newDictionary)); }
public async Task <ActionResult <string> > EditUserDictinory(DictionaryViewModel dictionary) { if (dictionary == null) { return(BadRequest()); } if (User.Identity.Name == null) { return(Ok("Вы не зарегестрированы")); } User user = await _userManager.FindByEmailAsync(User.Identity.Name); if (user == null) { return(Ok("Пользователь не найден")); } if (user.Dictionary == null) { List <DictionaryViewModel> userDictinory1 = new List <DictionaryViewModel>(); userDictinory1.Add(dictionary); user.Dictionary = JsonSerializer.Serialize(userDictinory1); var result2 = await _userManager.UpdateAsync(user); return(Ok("Успешно")); } List <DictionaryViewModel> userDictinory = JsonSerializer.Deserialize <List <DictionaryViewModel> >(user.Dictionary); userDictinory.Add(dictionary); user.Dictionary = JsonSerializer.Serialize(userDictinory); var result = await _userManager.UpdateAsync(user); if (result.Succeeded) { return(Ok("Успешно")); } else { return(Ok("Не успешно")); } }
public ActionResult Index() { // var model = new GetDictionaryInput {FilterText = Request.QueryString["filterText"]}; try { var model = new DictionaryViewModel { ParentCode = Request.QueryString["parentCode"], ParentList = _DictionaryAppService.GetParentList(Request.QueryString["parentCode"]) }; return(View(model)); } catch { return(RedirectToAction("Index", "Home")); } }
private async Task listView_ItemSelected(object sender, SelectedItemChangedEventArgs e) { var concept = (Concept)e.SelectedItem; ((ListView)sender).SelectedItem = null; var value = concept.value; var getDictionaryResult = Realms.Realm.GetInstance().All <Dictionary>().Count(it => it.originalWord == value); if (getDictionaryResult == 0) { UserDialogs.Instance.ShowLoading("Getting Dictionary"); await NetworkService.AddDictonaryOfConcept(concept); UserDialogs.Instance.HideLoading(); } var dictionaryViewModel = new DictionaryViewModel(concept.value); await NavigationService.Navigate(dictionaryViewModel); }
// Основной метод для Get и Post public DictionaryViewModel ModelForDictionary(DictionaryViewModel viewModel) { viewModel.UserName = CurrentUserName; viewModel.AvatarPath = CurrentAvatarPath; viewModel.CountWord = _dbContext.RussianDictionaries.Count(); // проверяю или у юзера уже есть что-то в БД, чтоб не выбросило ошибку var isAssociationUser = _dbContext.SavedUserAssociations.FirstOrDefault(a => a.UserId == UserID); //var userAssociations; if (isAssociationUser != null) { SavedUserAssociation listAssociation = new SavedUserAssociation(); var userAssociations = _dbContext.SavedUserAssociations.Where(a => a.UserId == UserID); foreach (SavedUserAssociation ass in userAssociations) { viewModel.ListAssociation.Add(ass); } } return(viewModel); }
public async Task <IActionResult> Index() { /*return View(await _context.Products * .Include(p => p.Category) * .ToListAsync());*/ var products = _context.Products .Include(p => p.Category) .AsQueryable(); var categoryQuery = _context.Categories.OrderBy(c => c.Name); /*SELECT DISTINCT [c].[Id], [c].[Description], [c].[ImageName], [c].[Name] * FROM [Categories] AS [c]*/ var categoryList = new List <Category>(await categoryQuery.AsNoTracking().Distinct().ToListAsync()); /*SELECT [p].[Id], [p].[BatteryId], [p].[CategoryId], [p].[Description], [p].[HousingId], [p].[ImageFile], [p].[MemoryId], [p].[Name], [p].[ProcessorId], [p].[ScreenId], [p].[Slug], [p].[Summary], [p].[UnitPrice], [p].[UnitsInStock], [c].[Id], [c].[Description], [c].[ImageName], [c].[Name] * FROM [Products] AS [p] * LEFT JOIN [Categories] AS [c] ON [p].[CategoryId] = [c].[Id]*/ var productList = await products.AsNoTracking().ToListAsync(); var dictionary = new DictionaryViewModel { CategoryProducts = categoryList .ToDictionary(category => category, category => productList.Where(p => p.Category.Id == category.Id).ToList()), Products = productList }; /*var productCategory = new ProductCategoryViewModel * { * Categories = new List<Models.Category>(await categoryQuery.Distinct().ToListAsync()), * Products = await products.ToListAsync() * };*/ return(View(dictionary)); }
public async Task <ActionResult <string> > DeleteWord(DictionaryViewModel dictionary) { if (dictionary == null) { return(BadRequest()); } if (User.Identity.Name == null) { return(Ok("Вы не зарегестрированы")); } User user = await _userManager.FindByEmailAsync(User.Identity.Name); if (user == null) { return(Ok("Пользователь не найден")); } if (user.Dictionary == null) { return(Ok("Элеинь для удаления отувствует")); } List <DictionaryViewModel> userDictinory = JsonSerializer.Deserialize <List <DictionaryViewModel> >(user.Dictionary); //userDictinory.Remove(dictionary); userDictinory = userDictinory.Where(p => p.Arab != dictionary.Arab).ToList(); user.Dictionary = JsonSerializer.Serialize(userDictinory); var result = await _userManager.UpdateAsync(user); if (result.Succeeded) { return(Ok("Успешно")); } else { return(Ok("Не успешно")); } }
public void ShowDictionary() { var catalog = new DictionaryViewModel(); WindowService.Current.MainWindow.Transition(catalog, typeof(DictionaryWindow)); }
public async Task <HttpResponseMessage> EditDictionary([FromUri] Guid dictionaryId, DictionaryViewModel vm) { var dictionary = await _dbContext.Dictionaries.FirstOrDefaultAsync(d => d.Id == dictionaryId); if (dictionary != null) { dictionary.Name = vm.Name; dictionary.Description = vm.Description; dictionary.IsPublic = vm.IsPublic; dictionary.LastChangeDate = DateTime.Now; await _dbContext.SaveDbChangesAsync(); return(Request.CreateResponse(HttpStatusCode.OK, dictionary)); } return(Request.CreateResponse(HttpStatusCode.NotFound)); }
public void ThenEntriesShouldBeLoaded() { DictionaryViewModel.Load(); Assert.IsNotNull(DictionaryViewModel.Entries); Assert.AreEqual(DictionaryEntries.Count, DictionaryViewModel.Entries.Count); }
protected override void Act() { DictionaryViewModel = new DictionaryViewModel(DictionaryService.Object); }
private void btnSett_Click(object sender, RoutedEventArgs e) { DataContext = new DictionaryViewModel(); }
public IActionResult Dictionary(DictionaryViewModel viewModel) { var vm = ModelForDictionary(viewModel); return(View("~/Views/Widgets/Dictionary.cshtml", vm)); }
public async Task <Dictionary> ImportWordlist(DictionaryViewModel dictionaryViewModel, CancellationToken cancellationToken) { return(await OpenTransactedConnection(async connection => { WordlistReader wordlistReader = dictionaryViewModel.WordlistReader; string tableName = GetDictionaryTableName(wordlistReader.OriginLanguageCode, wordlistReader.DestinationLanguageCode); await using (DbCommand command = connection.CreateCommand()) { command.CommandText = $"CREATE VIRTUAL TABLE {tableName} USING fts4(Word1 VARCHAR NOT NULL, Word2 VARCHAR NOT NULL, WordClasses VARCHAR, tokenize=unicode61, notindexed=WordClasses)"; await command.ExecuteNonQueryAsync(); } await using (DbCommand command = connection.CreateCommand()) { command.CommandText = $"INSERT INTO {tableName}(Word1, Word2, WordClasses) VALUES (@Word1, @Word2, @WordClasses)"; command.Parameters.Add(new SqliteParameter("@Word1", SqliteType.Text, 512)); command.Parameters.Add(new SqliteParameter("@Word2", SqliteType.Text, 512)); command.Parameters.Add(new SqliteParameter("@WordClasses", SqliteType.Text, 64)); await command.PrepareAsync(); while (true) { cancellationToken.ThrowIfCancellationRequested(); IReadOnlyList <DictionaryEntry> entries = await wordlistReader.ReadEntries(2500); if (entries.Count == 0) { break; } // run on the thread pool for better UI responsiveness await Task.Run(delegate() { foreach (DictionaryEntry entry in entries) { command.Parameters[0].Value = entry.Word1; command.Parameters[1].Value = entry.Word2; command.Parameters[2].Value = (object)entry.WordClasses ?? DBNull.Value; command.ExecuteNonQuery(); } }); dictionaryViewModel.NumberOfEntries += entries.Count; dictionaryViewModel.ImportProgress = wordlistReader.Progress; } } dictionaryViewModel.ImportProgress = 1.0; Dictionary dictionary = new Dictionary(wordlistReader.OriginLanguageCode, wordlistReader.DestinationLanguageCode, wordlistReader.CreationDate, dictionaryViewModel.NumberOfEntries); await using (DbCommand command = connection.CreateCommand()) { command.CommandText = "INSERT INTO Dictionaries(OriginLanguageCode, DestinationLanguageCode, CreationDate, NumberOfEntries) VALUES (@OriginLanguageCode, @DestinationLanguageCode, @CreationDate, @NumberOfEntries)"; command.Parameters.Add(new SqliteParameter("@OriginLanguageCode", dictionary.OriginLanguageCode)); command.Parameters.Add(new SqliteParameter("@DestinationLanguageCode", dictionary.DestinationLanguageCode)); command.Parameters.Add(new SqliteParameter("@CreationDate", dictionary.CreationDate.UtcTicks)); command.Parameters.Add(new SqliteParameter("@NumberOfEntries", dictionary.NumberOfEntries)); await command.ExecuteNonQueryAsync(); } await using (DbCommand command = connection.CreateCommand()) { command.CommandText = "SELECT last_insert_rowid()"; dictionary.ID = (int)(long)await command.ExecuteScalarAsync(); } dictionaryViewModel.Dictionary = dictionary; return dictionary; })); }
public void ThenEntriesShouldBeLoaded() { DictionaryViewModel.Load(); Assert.That(DictionaryViewModel.Entries, Is.Not.Null); Assert.That(DictionaryViewModel.Entries.Count, Is.EqualTo(DictionaryEntries.Count)); }
public virtual ActionResult Create() { var model = new DictionaryViewModel(); return(View(model)); }
public DictionaryWindow() { InitializeComponent(); DataContext = new DictionaryViewModel(ListViewType.EconomicEvents); }