public async void LoadArticles(object input = null) { // 1. Clear existing data grid source Articles.Clear(); // 2. Fetch artilces from database List <Article> articles = new List <Article>(); _workStatus(true); await Task.Run(() => { new ArticleRepo().GetAllArticles(User, FilterTitle).ForEach((article) => { articles.Add(article); }); }); _workStatus(false); // 3. Populate collection foreach (Article article in articles) { Articles.Add(article); } }
private async Task LoadAsync(string id) { UserID = UserManager.GetUserId(User); Profile = await Context.Profiles .Where(p => p.ProfileID == id) .FirstOrDefaultAsync(); Follows = await Context.Follows .Include(f => f.Profile) .ThenInclude(p => p.Articles) .Where(f => f.FollowerID == id) .ToListAsync(); foreach (Follow follow in Follows) { if (follow.Profile != null) { foreach (Article article in follow.Profile.Articles) { Articles.Add(article); } } } Articles.OrderByDescending(a => a.UpdateTime).Take(100); }
private async Task ExecuteGetCPFeedCommand() { if (IsBusy) { return; } IsBusy = true; GetCPFeedCommand.ChangeCanExecute(); try { var articles = await BlobCache.LocalMachine.GetOrFetchObject <CPFeed>("DefaultArticle", async() => await cpFeed.GetArticleAsync(1), DateTimeOffset.Now.AddDays(1) ); foreach (var article in articles.items) { Articles.Add(article); } IsBusy = false; } catch (Exception ex) { } }
private Articles SupplierArticleValidInScene() { Articles articles = new Articles(); string supplierId = orderInformations.GetSupplierName(); string IDs = String.Empty; int objSupplierNb = this.GetObjectNbFromHeading(); if (objSupplierNb > 0) { for (int rank = 0; rank < objSupplierNb; rank++) { int objId = this.CurrentAppli.Scene.SupplierGetObjectId(supplierId, (int)KD.SDK.SceneEnum.ObjectList.ALLHEADINGS, false, rank); IDs += objId + KD.StringTools.Const.Comma; } //Get all supplier articles of all heading except linears Articles supplierArticles = new Articles(CurrentAppli, IDs); foreach (Article article in supplierArticles) { SegmentClassification segmentClassification = new SegmentClassification(article); if (article.IsValid && article.Type != 17 && !String.IsNullOrEmpty(article.Ref)) //&& !segmentClassification.IsArticleLinear()) // { articles.Add(article); } } //Must relist the articles, del linears and add graphic linear articles = this.DelLinearsArticles(articles); //add linear articles cause not in heading and need to all real object in the scene articles = this.AddLinearsGraphikArticles(articles); } return(articles); }
private void SaveChanges() { // ellenőrzések if (String.IsNullOrEmpty(EditedArticle.Title)) { OnMessageApplication("Az cím nincs megadva!"); return; } if (String.IsNullOrEmpty(EditedArticle.Summary)) { OnMessageApplication("Az összefoglaló nincs megadva!"); return; } if (String.IsNullOrEmpty(EditedArticle.Content)) { OnMessageApplication("A tartalom nincs megadva!"); return; } // mentés if (EditedArticle.Id == 0) // ha új az épület { _model.CreateArticle(EditedArticle); Articles.Add(EditedArticle); SelectedArticle = EditedArticle; } else // ha már létezik az épület { _model.UpdateArticle(EditedArticle); } EditedArticle = null; OnArticleEditingFinished(); }
/** * Command actions */ public async Task PopulateReferenceArticles() { try { _workStatus(true); Articles.Clear(); List <Article> articles = new List <Article>(); await Task.Run(() => { foreach (Article article in (new ReferenceRepo()).LoadArticlesForReference(Reference)) { articles.Add(article); } }); foreach (Article article in articles) { Articles.Add(article); } _workStatus(false); } catch (Exception e) { new BugTracker().Track("Reference View", "Populate references", e.Message, e.StackTrace); _dialogService.OpenDialog(new DialogOkViewModel("Something went wrong.", "Error", DialogType.Error)); } finally { _workStatus(false); } }
private async Task ExecuteGetCPFeedCommand(int cveCategoria) { if (IsBusy) { return; } IsBusy = true; //GetCPFeedCommand.ChangeCanExecute(); try { var articles = await cpFeed.GetArticleAsync(1, cveCategoria); //BlobCache.LocalMachine.GetOrFetchObject<CPFeed>("DefaultArticle", //async () => await cpFeed.GetArticleAsync(1, cveCategoria), // DateTimeOffset.Now.AddDays(0) //); Debug.WriteLine(articles); foreach (var article in articles.items) { Debug.WriteLine(article.titulo); //Debug.WriteLine(string.Join(",", article)); Articles.Add(article); } IsBusy = false; } catch (Exception ex) { } }
private Article(string word, bool isDefinite) { this.Word = word; this.IsDefinite = isDefinite; Articles.Add(this); }
/// <summary> /// Constructor, activates on page/frame load /// </summary> public CustomerViewModel() { if (IsInDesignMode) { return; } // Loaded Data from WebApi var items = Global.Articles.FindAll(ArticleIsActive); // One nav Button for The "Hem"-knapp FilterButtons.Add(new FilterButton { Type = "Hem" }); foreach (var item in items) { // Storage, used for filtering later on storedArticles.Add(new ArticleItemDataModel(item)); // Displayed Articles Articles.Add(new ArticleItemDataModel(item)); // Create nav buttons for each type once if (FilterButtons.Where(fb => fb.Type == item.Type).Count() < 1) { FilterButtons.Add(new FilterButton { Type = item.Type }); } } // ... RunAsyncActions(); }
private async Task ExecuteGetCPFeedCommand() { if (IsBusy) { return; } IsBusy = true; GetAuthorArticleCommand.ChangeCanExecute(); try { var articles = await cpFeed.MyArticles(1); foreach (var article in articles.items) { Articles.Add(article); } IsBusy = false; } catch (Exception ex) { } }
private async void OnLoadMore() { try { if (!_internetService.IsInternet()) { await _dialogService.ShowMessage(Resource.NoInternet, Resource.Error); return; } IsLoading = true; IsPageEnabled = false; pageNo++; var articles = await _articleService.GetFilterdArticleAsync(FacetSearch, pageNo, pageSize); if (articles != null) { foreach (var article in articles) { Articles.Add(article); } } } catch (System.Exception ex) { await _dialogService.ShowMessage(ex.Message, Resource.Error); } finally { IsLoading = false; IsPageEnabled = true; } }
protected async Task LoadArticles() { Articles.Clear(); try { IsDefaultVisible = false; var articleResults = await App.Database.GetArticlesAsync(); foreach (var counter in articleResults) { Articles.Add(counter); } if (articleResults.Count == 0) { IsDefaultVisible = true; } } catch (Exception ex) { await App.Current.MainPage.DisplayAlert("Warning", "Could not retrieve articles.", "OK"); IsDefaultVisible = true; } }
protected async Task LoadArticles() { Articles.Clear(); try { this.IsBusy = true; var articleResults = await this.TBService.GetAllArticles(); foreach (var counter in articleResults.Articles) { Articles.Add(counter); } this.IsBusy = false; if (articleResults.Articles.Count == 0) { } //await App.Current.MainPage.DisplayAlert("Warning", "No articles found.", "OK"); } catch (Exception ex) { //await App.Current.MainPage.DisplayAlert("Warning", "Could not retrieve articles.", "OK"); } }
public void AddArticle(Product article) { // add article to list if (article == null) { throw new ArgumentNullException(); } Articles.Add(article); }
// returns the object back to whoever pushed the pageModel public override void ReverseInit(object returnedData) { var newArticle = returnedData as Article; if (!Articles.Contains(newArticle)) { Articles.Add(newArticle); } }
public void UpdateView() { var articles = _articleRepository.GetEntities(); Articles.Clear(); foreach (var article in articles) { Articles.Add(article); } }
public ManageArticlesViewModel(Newspaper newspaper, IList <Article> articles, INewspaperService newspaperService, PagingParam pagingParam) { Info = new NewspaperInfoViewModel(newspaper, newspaperService); foreach (var article in articles) { Articles.Add(new ArticleForManagementViewModel(article)); } PagingParam = pagingParam; }
public void AddArticle(DateTimeOffset publishDateTime) { var month = publishDateTime.Month; var year = publishDateTime.Year; var article = Articles.FirstOrDefault(a => a.Month == month && a.Year == year); if (article == null) { article = DataSourceArticle.Create(month, year); Articles.Add(article); } article.Increment(); NbStoriesPerMonth = Articles.Sum(a => a.NbArticles) / Articles.Count(); }
public ActionResult Ajouter(Article article) { if (!ModelState.IsValid) { return(View(article)); } Utilisateur user = Utilisateurs.FindByCourriel(User.Identity.Name); article.IdContributeur = user.Id; article.Revision = 1; article.DateModification = DateTime.Now; Articles.Add(article); return(RedirectToAction("Index", "Home", new { id = article.Titre })); }
static void CreaArticolo() { decimal prezzo; string descrizione; Console.WriteLine("Inserisci la descrizione :"); descrizione = Console.ReadLine(); Console.WriteLine("Inserisci il prezzo : "); prezzo = decimal.Parse(Console.ReadLine()); // TODO gestire eccezioni Article myArticle1 = new Article(descrizione, prezzo); Articles.Add(myArticle1); Articles.List(); }
/// <summary> /// Swapping View Action /// </summary> public void ChangeArticleAction() { var item = Articles.FirstOrDefault(i => i.Article.Name == "Pizza_A"); if (item != null) { item.ChangeName("Uppdaterad"); item.ChangePrice(666.0f); } else { Articles.Add(new ArticleItemDataModel(new Article { Name = "Pizza_C", BasePrice = 129.0f })); } }
private Articles AddLinearsGraphikArticles(Articles articles) { string IDs = this.CurrentAppli.SceneComponent.SceneGetObjectIdList(null, KD.Analysis.FilterArticle.strFilterToGetValidPlacedParent());//strFilterToGetValidPlacedHostedAndChildren Articles articlesList = new Articles(CurrentAppli, IDs); foreach (Article article in articlesList) { SegmentClassification segmentClassification = new SegmentClassification(article); if (segmentClassification.IsArticleLinear())// && !article.HasParent()) // && article.IsValid { if (!articles.Contains(article)) { articles.Add(article); } } } return(articles); }
public ActionResult Ajouter(Article article) //Daily { if (ModelState.IsValid) { if (repo.Add(article)) { ViewBag.Erreur = "L'article a été ajouté"; ViewBag.Article = repo.Find(article.Titre); } else { ViewBag.Erreur = "L'article n'a pas été ajouté"; return(View("Error")); } } return(View("Index")); }
public Article CreateNewArticle(string title, string author, string text, string tags) { var article = new Article { Author = author, CreateDate = DateTime.Now, Tags = tags, Text = text, Title = title }; article.UniqueTitle = GetUniqueTitle(article); Articles.Add(article); SaveChanges(); article = Articles.Where(a => a.UniqueTitle == article.UniqueTitle).FirstOrDefault(); return(article); }
/// <summary> /// /// </summary> private async Task LoadData() { // Repo inits var articleRepo = new Library.Repository.ArticlesRepository("Articles"); var employeeRepo = new Library.Repository.EmployeesRepository("Employees"); var ingredientRepo = new Library.Repository.IngredientsRepository("Ingredients"); // The private lists are clones foreach (var item in await articleRepo.GetAllAsync()) { // IsActive check if (!(bool)item.IsActive) { continue; } var tempArticle = new ArticleModel { ID = item.ID, Name = item.Name, BasePrice = item.BasePrice, Type = item.Type, IsActive = item.IsActive }; tempArticle.Ingredients = new List <Ingredient>(); foreach (var itemIngredients in item.Ingredients.ToList()) { tempArticle.Ingredients.Add(new Ingredient { ID = itemIngredients.ID, Name = itemIngredients.Name, Price = itemIngredients.Price }); } Articles.Add(tempArticle); } foreach (var item in await employeeRepo.GetAllAsync()) { Employees.Add(new EmployeeModel { ID = item.ID, Name = item.Name, LastName = item.LastName, Email = item.Email, Password = item.Password }); } foreach (var item in await ingredientRepo.GetAllAsync()) { Ingredients.Add(new IngredientModel { ID = item.ID, Name = item.Name, Price = item.Price }); } }
public async Task <List <Article> > GetCategoryArticlesAsync(string category, string categoryUrl) { var listOfArticles = new List <Article>(); try { var newArticles = await _theHinduClient.GetArticlesAsync(category, categoryUrl); if (newArticles != null) { foreach (var article in newArticles) { if (listOfArticles.Find(o => o.ArticleId == article.ArticleId) == null) { listOfArticles.Add(article); } } } await DatabaseOperations.GetInstance().UpdateCategoryLastAccessedValueAsync(category, DateTime.UtcNow); } catch (Exception exception) { if (Debugger.IsAttached) { Debug.WriteLine("DataService:" + exception); } } if (Articles == null) { Articles = new List <Article>(); } foreach (var article in listOfArticles) { if (Articles.Find(o => o.ArticleId == article.ArticleId) == null) { Articles.Add(article); } } await SaveArticlesAsync(); return(listOfArticles); }
public ActionResult Index(String operation, Article a) { switch (operation) { case "Consulter": if (a.Titre == null) { ViewBag.Erreur = "Erreur : Vous devez saisir un titre !!!"; return(View()); } string titre = a.Titre; a = repo.Find(a.Titre); if (a == null) { ViewBag.Erreur = "L'article n'existe pas"; ViewBag.Titre = titre; } ViewBag.Article = a; break; case "Update": if (ModelState.IsValid) { a.IdContributeur = 1; repo.Update(a); } break; case "Add": if (ModelState.IsValid) { a.IdContributeur = 1; repo.Add(a); } break; case "Delete": repo.Delete(a.Titre); break; } return(View()); }
/// <summary> /// Loop and replace currently displayed articles /// </summary> /// <param name="arg">Name of article type</param> public void FilterArticleAction(object arg) { // From the buttons' commandArgument string selectedType = (string)arg; // Set hightlight display for navmenubutton foreach (var item in FilterButtons) { if (item.Type == selectedType) { item.IsActive = true; } else { item.IsActive = false; } } // When 'home' is hit. Reset displayed articles to show all if (selectedType == "All" || selectedType == "Hem") { Articles.Clear(); foreach (var item in storedArticles) { Articles.Add(item); } // Return point here return; } // If not, filter by selected type var _ = storedArticles.Where(a => a.Article.Type == selectedType); Articles.Clear(); foreach (var item in _) { Articles.Add(item); } }
private async Task RequestArticles() { try { IsBusy = true; _isLoading = true; var articlesPaginated = await _articleService.GetArticlesAsync(_pageIndex); _totalArticles = articlesPaginated.TotalCount; if (articlesPaginated.Data.Count > 0) { foreach (var articleModel in articlesPaginated.Data) { Articles.Add(articleModel); } } _isLoading = false; _pageIndex++; } catch (HttpRequestExceptionEx e) { await _userDialogs.AlertAsync(title : "Ошибка доступа к серверу", message : $"HttpCode: {e.HttpCode} Message: {e.Message}", okText : "Ok"); } catch (ServiceAuthenticationException e) { await _userDialogs.AlertAsync(title : "Ошибка авторизации", message : $"{e.Content}", okText : "Ok"); } catch (Exception e) { await _userDialogs.AlertAsync(title : "Ошибка", message : $"{e.Message}", okText : "Ok"); } finally { IsBusy = false; } }
public ActionResult Index(String operation, Article a) { switch (operation) { case "Find": if (a.Titre == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } a = repo.Find(a.Titre); if (a == null) { return(HttpNotFound()); } ViewBag.Article = a; break; case "Update": if (ModelState.IsValid) { a.IdContributeur = 1; repo.Update(a); } break; case "Add": if (ModelState.IsValid) { a.IdContributeur = 1; repo.Add(a); } break; case "Delete": repo.Delete(a.Titre); break; } return(View(repo.GetArticles())); }