public ActionResult CardList(int i = 1, int page = 1) { ListResponse listResponse = new ListResponse(); listResponse.Word = listService.GetAllWords(i); //MAPPING WordListViewModel wordListViewModel = new WordListViewModel(); wordListViewModel.Words = ToList(listResponse.Word); ((IEnumerable <Word>)wordListViewModel.Words).OrderBy(w => w.Id).Skip((page - 1) * PageSize).Take(PageSize); //Pagination //Palabra de 4 caracteres no se muestran correctamente wordListViewModel.Words = wordListViewModel.Words.OrderBy(w => w.Id).Skip((page - 1) * PageSize).Take(PageSize); wordListViewModel.PagingInfo = new PagingInfo { CurrentPage = page, ItemsPerPage = PageSize, TotalItems = listResponse.Word.Count }; return(View("CardList", wordListViewModel)); }
public ActionResult BatchInsert(WordListViewModel wordViewModel) { string[] wordList = wordViewModel.WordList.Split( new string[] { "\n", "\r\n" }, StringSplitOptions.RemoveEmptyEntries); List <Exception> exceptionList = new List <Exception>(); List <string> failedWords = new List <string>(); foreach (string word in wordList) { if (word != null) { try { _wordService.GetAndSaveWordInformation(word.ToLower()); } catch (Exception e) { failedWords.Add(word); exceptionList.Add(e); } } } wordViewModel.WordList = string.Join(string.Empty, failedWords); return(View(wordViewModel)); }
private WordListViewModel workListVM = null; // 界面对应的ViewModel /// <summary> /// 构造方法 /// </summary> public WordList() { InitializeComponent(); this.workListVM = new WordListViewModel(); this.DataContext = this.workListVM; this.RegisterMessage(); this.Focusable = true; }
public ActionResult DeleteConfirmed(int id) { WordListViewModel wordListViewModel = db.WordListViewModels.Find(id); db.WordListViewModels.Remove(wordListViewModel); db.SaveChanges(); return(RedirectToAction("Index")); }
public WordsListPage() { InitializeComponent(); BindingContext = new WordListViewModel() { Navigation = this.Navigation }; }
public ActionResult Edit([Bind(Include = "ID,text,type")] WordListViewModel wordListViewModel) { if (ModelState.IsValid) { db.Entry(wordListViewModel).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(wordListViewModel)); }
public WordList() { InitializeComponent(); Model = new WordListViewModel(); DataContext = Model; foreach (var word in UI.Words.AllWords.Where(word => !Model.WordList.Contains(word))) { Model.WordList.Add(word); } }
public ViewResult List(int page = 1) { //ADDING PAGINATION WordListViewModel model = new WordListViewModel { Words = repository.Words.OrderBy(w => w.Id).Skip((page - 1) * PageSize).Take(PageSize), PagingInfo = new PagingInfo { CurrentPage = page, ItemsPerPage = PageSize, TotalItems = repository.Words.Count() } }; return(View(model)); }
public IActionResult WordList(int?id) { var words = wordSource.GetWords(20); var vm = new WordListViewModel(); vm.Words = words; if (id != null) { vm.SelectedWord = words.FirstOrDefault(z => z.Id == id); } return(View(vm)); }
// GET: WordList/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } WordListViewModel wordListViewModel = db.WordListViewModels.Find(id); if (wordListViewModel == null) { return(HttpNotFound()); } return(View(wordListViewModel)); }
public ActionResult Create([Bind(Include = "ID,text,type")] WordListViewModel wlm) { WordList wordList = new WordList(); wordList.text = wlm.text; wordList.type = 1; if (ModelState.IsValid) { db.WordLists.Add(wordList); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(wlm)); }
public IActionResult List(string key) { if (key == null) { key = ""; } var words = from m in _context.Words where m.InEnglish.Contains(key) || m.InAzerbaijan.Contains(key) select m; string sortType = HttpContext.Request.Query["sortType"]; if (sortType == "AzerbaijanAtoZ") { words = words.OrderBy(w => w.InAzerbaijan); } else if (sortType == "AzerbaijanZtoA") { words = words.OrderBy(w => w.InAzerbaijan).Reverse(); } else if (sortType == "EnglishAtoZ") { words = words.OrderBy(w => w.InEnglish); } else if (sortType == "EnglishZtoA") { words = words.OrderBy(w => w.InEnglish).Reverse(); } else if (sortType == "date") { words = words.OrderBy(w => w.AddedTime); } var model = new WordListViewModel() { Words = words.ToList() }; return(View(model)); }
public ActionResult BatchInsert() { WordListViewModel viewModel = new WordListViewModel(); return(View(viewModel)); }