public async Task <IActionResult> SaveNewsInformation([FromBody] NewsInformationViewModel model) { if (await _context.NewsInformationAction.AnyAsync(x => x.UserId == model.UserId)) { var newsUserDetected = await _context.NewsInformationAction.Where(x => x.UserId == model.UserId).FirstOrDefaultAsync(); newsUserDetected.Tittle = model.Tittle; newsUserDetected.UserId = model.UserId; newsUserDetected.Description = model.Description; newsUserDetected.Index = model.Index; await _context.SaveChangesAsync(); return(Ok()); } else { var newinformation = new NewsInformation() { Tittle = model.Tittle, Description = model.Description, UserId = model.UserId, Index = model.Index }; await _context.NewsInformationAction.AddAsync(newinformation); await _context.SaveChangesAsync(); return(Ok()); } //var booleanTable = await _context.BooleanTables.Where(x => x.UserId == model.UserId).FirstOrDefaultAsync(); //booleanTable.Email = true; }
public async static Task <FavoriteInfromation> AsFavorite(this NewsInformation article, string categoryTitle) { return(new FavoriteInfromation() { ArticleDate = article.CreatedDate, Description = article.Description, ImageUrl = article.ImageUrl, Title = article.Title, CategoryTitle = categoryTitle, }); }
public async void ToggleFavoriteAsync(NewsInformation articel) { _isBusy = true; RaiseCanExecuteChanged(); App.viewModel.IsBusy = true; await App.viewModel.Favorites.AddAsync(await articel.AsFavorite("Technology")); _isBusy = false; RaiseCanExecuteChanged(); App.viewModel.IsBusy = false; }
public void Execute(object parameter) { NewsInformation newsInformation = parameter as News.NewsInformation; if (newsInformation == null) { NavigateToDetailAsync(parameter as FavoriteInformation); } else { NavigateToDetailAsync(newsInformation); } }
public ItemDetailPage(NewsInformation currentArticle) { InitializeComponent(); CurrentArticle = currentArticle; }
public ItemDetailPage(FavoriteInformation currentArticle) { InitializeComponent(); this.CurrentArticle = currentArticle.AsArticle(); }
private async void NavigateToDetailAsync(NewsInformation article) { await App.MainNavigation.PushAsync(new ItemDetailPage(article), true); }