public override async Task InitializeViewModel(string param) { if (HasInitialized) { return; } if (param != "") { var currentProduct = await DataManager.ProductDataSource.GetDetailsAsync(param); if (currentProduct != null) { ProductDetails = currentProduct; ProductName = currentProduct.Name; List <Product> products = ((await DataManager.ProductDataSource.GetProductsBySubCategoryIdAsync(currentProduct.SubCategory)) .Where(item => item.Id != currentProduct.Id) .Where(item => item.GroupNumber.Equals(currentProduct.GroupNumber))).ToList(); CategoryName = (await DataManager.CategoryDataSource.GetCategoryNameAsync(currentProduct.Category)); SubCategoryName = (await DataManager.CategoryDataSource.GetSubCategoryNameAsync(currentProduct.SubCategory)); RelatedProducts = products; IsFavorite = FavoritesHelper.IsFavorite(currentProduct.Id); CheckPinnedState(); } } }
public override void OnStart() { base.OnStart(); refresher.Refresh += Refresher_Refresh; adapter.ItemClick += Adapter_ItemClick; ViewModel.Favorites = FavoritesHelper.GetFavorites(Context); if (ViewModel.Items.Count == 0) { ViewModel.LoadItemsCommand.Execute(null); } }
private void Favorite_Click(object sender, EventArgs e) { var threadId = ThreadId.Text; if (IsFavorite) { Favorite.SetImageResource(Resource.Drawable.ic_favorite_border_black_18dp); IsFavorite = false; FavoritesHelper.RemoveFavorite(Context, threadId); } else { Favorite.SetImageResource(Resource.Drawable.ic_favorite_black_18dp); IsFavorite = true; FavoritesHelper.AddFavorite(Context, threadId); } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { //Users user = DataHelper.GetUser(User.UserId); if (User != null) { ListItems = FavoritesHelper.GetFavoritesByUser(User.UserId); } else { if (Request.Cookies["uid"] != null) { string value = Request.Cookies["uid"].Value; ListItems = FavoritesHelper.GetFavoritesByCookies(value); } } } }
public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { var favorites = FavoritesHelper.GetFavorites(Context); ViewModel = new ThreadsViewModel(this.Context, this.Context.ContentResolver, favorites); View view = inflater.Inflate(Resource.Layout.fragment_threads, container, false); var recyclerView = view.FindViewById <RecyclerView>(Resource.Id.recyclerView); recyclerView.HasFixedSize = true; recyclerView.SetAdapter(adapter = new ThreadItemsAdapter(Activity, ViewModel)); refresher = view.FindViewById <SwipeRefreshLayout>(Resource.Id.refresher); refresher.SetColorSchemeColors(Resource.Color.accent); progress = view.FindViewById <ProgressBar>(Resource.Id.progressbar_loading); progress.Visibility = ViewStates.Gone; return(view); }
public override async Task InitializeViewModel(string param) { if (HasInitialized) { //If we have initialized the data already, update the favorites only to reflect any changes made. FavoritesHelper.DefaultFavorites = (await DataManager.DefaultFavoritesDataSource.GetAllAsync()).ToList(); _favorites = (await DataManager.ProductDataSource.GetProductsByProductIdsAsync(FavoritesHelper.GetFavorites())).ToList(); OnPropertyChanged("FavoriteProducts"); return; } //Get list of Favorite Products FavoritesHelper.DefaultFavorites = (await DataManager.DefaultFavoritesDataSource.GetAllAsync()).ToList(); _favorites = (await DataManager.ProductDataSource.GetProductsByProductIdsAsync(FavoritesHelper.GetFavorites())).ToList(); //Get list of Top Level Categories _mainCategories = (await DataManager.CategoryDataSource.GetAllAsync()).ToList(); }
public void ProcessRequest(HttpContext context) { string eventName = string.Empty; string result = string.Empty; string id = string.Empty; string comment = string.Empty; eventName = context.Request["e"]; result = context.Request["r"]; id = context.Request["id"]; comment = context.Request["c"]; ///Add favorites if (eventName == "af") { string userName = context.User.Identity.Name; if (!string.IsNullOrEmpty(userName)) { Users user = DataHelper.GetUserByName(userName); Rentoolo.Model.Favorites favorites = new Rentoolo.Model.Favorites { UserId = user.UserId, AdvertId = Convert.ToInt64(id) }; FavoritesHelper.AddFavorites(favorites); } else { var uid = context.Request.Cookies["uid"]; if (uid != null) { FavoritesByCookies favoritesByCookies = new FavoritesByCookies { UserCookiesId = uid.Value, AdvertId = Convert.ToInt64(id) }; FavoritesHelper.AddFavoritesByCookies(favoritesByCookies); } } } if (eventName == "saveUserParam") { if (id == "Referrer") { Model.Users referal = DataHelper.GetUserByName(context.User.Identity.Name); int publicId; if (!int.TryParse(result, out publicId)) { return; } Model.Users referer = DataHelper.GetUserByPublicId(publicId); if (referer == null) { return; } //сделать проверку что не является рефералом реферера и на уровень выше тоже if (referer.UserId == referal.UserId) { return; } Model.Referrals upperReferal = DataHelper.GetReferral(referer.UserId); if (upperReferal != null && upperReferal.ReferrerUserId == referal.UserId) { return; } if (upperReferal != null) { Model.Referrals upper2Referal = DataHelper.GetReferral(upperReferal.ReferrerUserId); if (upper2Referal != null && upper2Referal.ReferrerUserId == referal.UserId) { return; } } Model.Referrals referralItem = new Model.Referrals { ReferralUserId = referal.UserId, ReferrerUserId = referer.UserId, WhenDate = DateTime.Now }; DataHelper.AddReferral(referralItem); } if (id == "Email") { DataHelper.UpdateUserEmail(context.User.Identity.Name, result); } else { DataHelper.UpdateUserParametr(context.User.Identity.Name, id, result); } } context.Response.ContentType = "text/plain"; context.Response.Write("Ok"); }
void Refresher_Refresh(object sender, EventArgs e) { ViewModel.Favorites = FavoritesHelper.GetFavorites(Context); ViewModel.LoadItemsCommand.Execute(null); refresher.Refreshing = false; }