public IActionResult Index() { List <ShowArtViewModel> showArtViewModel = new List <ShowArtViewModel>(); var Arts = service.GetAll(); if (Arts != null) { List <Art> Favourites; string UserID = manager.GetUserId(HttpContext.User); if (UserID == null) { Favourites = null; } else { Favourites = favouriteService.GetAll(UserID); } for (int i = 0; i < Arts.Count; i++) { ShowArtViewModel sh = new ShowArtViewModel(); sh.Name = Arts[i].Name; if (Arts[i].Photos != null) { sh.Path = Arts[i].Photos.FirstOrDefault().Path; } sh.DateTime = Arts[i].dateTime; sh.Description = Arts[i].Description; sh.price = Arts[i].Price; // if ((manager.GetUserId(HttpContext.User)) sh.TypeOfArt = Arts[i].TypeOfArt; sh.FullName = Arts[i].AppUser.FName + " " + Arts[i].AppUser.LName; sh.UserPicture = Arts[i].AppUser.ProfilePicture; sh.ArtId = Arts[i].ID; if (Favourites == null) { sh.color = "Black"; } else { if (Favourites.Contains(Arts[i])) { sh.color = "Red"; } else { sh.color = "Black"; } } showArtViewModel.Add(sh); } return(View(showArtViewModel)); } return(View()); }
public string SaveArticle() { var result = Serializator.BinarySerialize(_currentFeedItem); if (!Favourites.Contains(_currentFeedItem.HashCode)) { Favourites.Add(_currentFeedItem.HashCode, _currentFeedItem); } // Categories[CategoryType.Favourites.ToString()].(_currentFeedItem); return(result); }
public bool RemoveArticle() { bool result = false; if (_currentFeedItem != null) { int hash = _currentFeedItem.HashCode; if (Favourites.Contains(_currentFeedItem.HashCode)) { Favourites.Remove(hash); result = _currentFeedItem.RemoveFromFavourites(); MainFeed = MetaTag + FavouriteArticles; } } return(result); }