Exemplo n.º 1
0
        public async Task AddFavoriteAsync(long userId, long itemId)
        {
            var user = await this.m_userService.GetUserByIdAsync(userId);

            var item = await this.m_itemService.GetItemById(itemId);

            if (user == null)
            {
                throw new Exception("User not found.");
            }
            if (item == null)
            {
                throw new Exception("Item not found.");
            }

            var exist = await this.m_repository.ExistAsync(i => i.UserId == userId && i.ItemId == itemId);

            if (exist)
            {
                return;
            }

            var favItem = new FavoriteItem {
                User      = user,
                Item      = item,
                UserId    = user.Id,
                ItemId    = item.Id,
                CreatedBy = user.Login,
                Active    = true
            };

            await this.m_repository.CreateAsync(favItem);
        }
Exemplo n.º 2
0
        public void SetData(FavoriteItem item, UINavigationController navigationController)
        {
            this.navigationController = navigationController;
            model = item;
            if (IsNew)
            {
                btnFollow.TouchUpInside += (sender, e) =>
                {
                    Shared.Follower.ToggleFollow(btnFollow, model, model.Id, model.Type);
                };
                imgProfile.UserInteractionEnabled = true;
                imgProfile.AddGestureRecognizer(new UITapGestureRecognizer((obj) => GoToProfile()));
                lblTitle.UserInteractionEnabled = true;
                lblTitle.AddGestureRecognizer(new UITapGestureRecognizer((obj) => GoToProfile()));
                IsNew = false;
            }
            lblTitle.Text      = item.Title;
            lblSubtitle.Text   = item.Subtitle;
            lblSubtitle.Hidden = string.IsNullOrEmpty(item.Subtitle);
            Views.SetFollowed(btnFollow, item.IsFollowing);

            imageTask?.Cancel(item.ProfileUrl);
            if (!string.IsNullOrEmpty(item.ProfileUrl))
            {
                imageTask = new ImageLoaderHelper(item.ProfileUrl, imgProfile, "DefaultProfile", null, new CircleTransformation());
            }
        }
Exemplo n.º 3
0
        private void lstFavorites_MouseDown(object sender, MouseEventArgs e)
        {
            _contextItem = null;
            ListViewItem item = lstFavorites.GetItemAt(e.X, e.Y);

            if (item == null)
            {
                return;
            }

            if (e.Button == MouseButtons.Left)
            {
                if (item is FavoriteItem)
                {
                    _tree.MoveToNode(((FavoriteItem)item).Favorite.Path);
                }
            }
            else if (e.Button == MouseButtons.Right)
            {
                if (item is FavoriteItem)
                {
                    _contextItem = (FavoriteItem)item;
                    mnStripFavorite.Show(this, e.X, e.Y);
                }
            }
        }
Exemplo n.º 4
0
        ///<summary>
        ///向数据库中添加一条记录
        ///</summary>
        ///<param name="model">要添加的实体</param>
        public bool Insert(FavoriteItem model)
        {
            const string sql = @"INSERT INTO [dbo].[FavoriteItem] (num_iid,favorites_id,title,pict_url,small_images,reserve_price,zk_final_price,user_type,provcity,item_url,click_url,volume,tk_rate,zk_final_price_wap,event_start_time,event_end_time) VALUES (@num_iid,@favorites_id,@title,@pict_url,@small_images,@reserve_price,@zk_final_price,@user_type,@provcity,@item_url,@click_url,@volume,@tk_rate,@zk_final_price_wap,@event_start_time,@event_end_time)";
            int          res = SqlHelper.ExecuteNonQuery(sql, new SqlParameter("@num_iid", model.num_iid.ToDBValue()), new SqlParameter("@favorites_id", model.favorites_id.ToDBValue()), new SqlParameter("@title", model.title.ToDBValue()), new SqlParameter("@pict_url", model.pict_url.ToDBValue()), new SqlParameter("@small_images", model.small_images.Replace("\n", "").Replace("\r", "").ToDBValue()), new SqlParameter("@reserve_price", model.reserve_price.ToDBValue()), new SqlParameter("@zk_final_price", model.zk_final_price.ToDBValue()), new SqlParameter("@user_type", model.user_type.ToDBValue()), new SqlParameter("@provcity", model.provcity.ToDBValue()), new SqlParameter("@item_url", model.item_url.ToDBValue()), new SqlParameter("@click_url", model.click_url.ToDBValue()), new SqlParameter("@volume", model.volume.ToDBValue()), new SqlParameter("@tk_rate", model.tk_rate.ToDBValue()), new SqlParameter("@zk_final_price_wap", model.zk_final_price_wap.ToDBValue()), new SqlParameter("@event_start_time", model.event_start_time.ToDBValue()), new SqlParameter("@event_end_time", model.event_end_time.ToDBValue()));

            return(res > 0);
        }
Exemplo n.º 5
0
        /// <summary>
        /// 获取选品库产品淘口令
        /// </summary>
        /// <param name="favoriteItem">参数:选品库产品</param>
        /// <param name="diploma">参数:淘宝API应用证书</param>
        /// <returns>返回:淘口令</returns>
        public string TpwdCreate(FavoriteItem favoriteItem, Diploma diploma)
        {
            try
            {
                TbkTpwdCreateRequest req = new TbkTpwdCreateRequest();
                if (favoriteItem.CouponClickUrl == null)
                {
                    req.Url = favoriteItem.ClickUrl;
                }
                else
                {
                    req.Url = favoriteItem.CouponClickUrl;
                }
                req.Text = favoriteItem.Title;

                req.Logo = favoriteItem.PictUrl;
                req.Ext  = "{}";
                TbkTpwdCreateResponse rsp = DefaultTopClient.Get(diploma.AppUrl, diploma.AppKey, diploma.AppSecret).Execute(req);
                return(rsp.Data.Model);
            }
            catch
            {
                return("未开通淘客佣金");
            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// 根据收藏夹完整路径获取收藏夹
        /// </summary>
        /// <param name="path">收藏夹完整路径</param>
        public static FavoriteFolder GetFavoritesByPath(string path)
        {
            FavoriteFolder folder = new FavoriteFolder();
            folder.Title = Path.GetFileNameWithoutExtension(path);

            List<FavoriteFolder> childFolders = new List<FavoriteFolder>();
            foreach (string dir in Directory.GetDirectories(path))
            {
                FavoriteFolder childFolder = GetFavoritesByPath(dir);
                childFolders.Add(childFolder);
            }

            List<FavoriteItem> items = new List<FavoriteItem>();
            foreach (string file in Directory.GetFiles(path))
            {
                if ((File.GetAttributes(file) & FileAttributes.System) != FileAttributes.Hidden
                    && (File.GetAttributes(file) & FileAttributes.System) != FileAttributes.System)
                {
                    FavoriteItem item = new FavoriteItem();
                    item.Title = Path.GetFileNameWithoutExtension(file);
                    item.URL = GetUrl(file);
                    items.Add(item);
                }
            }

            folder.FavoriteFolders = childFolders;
            folder.FavoritesItems = items;
            return folder;
        }
Exemplo n.º 7
0
        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        public bool Update(FavoriteItem entity)
        {
            HibernateTemplate.Update(entity);
            return(true);

            throw new NotImplementedException();
        }
Exemplo n.º 8
0
        public JsonResult FavoriteSave(string Id, string Name)
        {
            string result = string.Empty;

            try
            {
                FavoriteItem objFs = new FavoriteItem();
                if (string.IsNullOrEmpty(Id))
                {
                    objFs.Name              = Name;
                    objFs.LinkAddress       = FavoriteUrl;
                    objFs.EntityName        = FavoriteUrlEntityName;
                    objFs.LastUpdatedBy     = DateTime.UtcNow;
                    objFs.LastUpdatedByUser = User.Name;
                    db.FavoriteItems.Add(objFs);
                }
                else
                {
                    long objId = Int64.Parse(Id);
                    objFs                 = db.FavoriteItems.Find(objId);
                    objFs.Name            = Name;
                    objFs.EntityName      = FavoriteUrlEntityName;
                    db.Entry(objFs).State = EntityState.Modified;
                }
                db.SaveChanges();
                result = "success";
            }
            catch
            {
                result = "error";
            }
            return(Json(result, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 9
0
 public void updateName(FavoriteItem f, Func1 updateStatus)
 {
     if (f.nameEntry.Text != "")
     {
         updateStatus("Saved");
         userData.changeFavoriteName(f.nameEntry.Text, f.urlEntry.Text);
     }
 }
        public UITableViewCell GetCell(UITableView tableView, NSIndexPath indexPath, FavoriteItem item)
        {
            var cell = tableView.DequeueReusableCell("FavoriteCell", indexPath) as FavoriteCell;

            cell.SetData(item, NavigationController);
            cell.SelectionStyle = UITableViewCellSelectionStyle.None;
            return(cell);
        }
Exemplo n.º 11
0
        public static List <FavoriteItem> RemoveFavoriteItem(FavoriteItem item)
        {
            var list = GetFavoriteList();

            list.Remove(list.FirstOrDefault(a => a.Index == item.Index));

            WriteToFile(list);
            return(list);
        }
Exemplo n.º 12
0
        public ActionResult FavoriteDelete(long Id)
        {
            FavoriteItem objFs = db.FavoriteItems.Find(Id);

            db.Entry(objFs).State = EntityState.Deleted;
            db.FavoriteItems.Remove(objFs);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Exemplo n.º 13
0
        /// 增加删除

        public void AddFavoriteItem(int PoetryId)
        {
            var favoriteItem = new FavoriteItem {
                PoetryId = PoetryId
            };

            _knowledgeContext.FavoriteItems.Add(favoriteItem);
            _knowledgeContext.SaveChanges();
        }
Exemplo n.º 14
0
        public static List <FavoriteItem> AddNewFavoriteItem(FavoriteItem newItem)
        {
            var list = GetFavoriteList();

            newItem.Index = list.Any() ? list.Max(x => x.Index) + 1 : 0;
            list.Add(newItem);

            WriteToFile(list);
            return(list);
        }
Exemplo n.º 15
0
        private void OnFavoriteTap(object sender, System.Windows.Input.GestureEventArgs e)
        {
            FavoriteItem favoriteItem = sender as FavoriteItem;

            _currentSelectedChannelInfo = new ChannelInfo(favoriteItem.Vid, favoriteItem.TitleText, "", favoriteItem.ImageUrl, 0, false, false, false, false, 0, 0, 1, "");
            int    vid  = favoriteItem.Vid;
            string page = String.Format("/DetailPage.xaml?vid={0}&programSource=6", vid);

            NavigationService.Navigate(new Uri(page, UriKind.RelativeOrAbsolute));
        }
Exemplo n.º 16
0
        public async void PageLoad()
        {
            ListLyt   = "#e3f5a6";
            SortLyt   = "Transparent";
            FilterLyt = "Transparent";

            CountFilter = "Filters(0)";
            Loader      = true;

            try
            {
                if (!HttpRequest.CheckConnection())
                {
                    await DependencyService.Get <IToastNotificator>().Notify(ToastNotificationType.Error, "Error", "Device is not connected with Internet. Please check your network connection", TimeSpan.FromSeconds(2));

                    return;
                }



                Items.Clear();
                Items = new ObservableCollection <ProductData>();
                string url = ServiceConfigrations.BaseUrl + ServiceConfigrations.OrderUrl;

                var userinfo = await HttpRequest.GetRequest(url);

                var serviceResult = JsonConvert.DeserializeObject <ProductList>(userinfo.Result);

                if (serviceResult.status)
                {
                    foreach (var item in serviceResult.data)
                    {
                        FavoriteItem objUser  = App.Database.GetProduct(item.id);
                        string       Favorite = "heartblack.png";
                        if (objUser != null)
                        {
                            Favorite = "redheart.png";
                        }



                        Items.Add(new ProductData {
                            favorite = Favorite, category = item.category, description = item.description, id = item.id, image = ServiceConfigrations.BaseImg + item.image, name = item.name, price = item.price, ratecount = item.ratecount, title = item.title,
                        });
                    }
                    TotalItem = serviceResult.data.Count.ToString() + " Products";
                    ItemName  = serviceResult.data.FirstOrDefault().name;
                }
                Loader = false;
            }
            catch (Exception ex)
            {
                Loader = false;
            }
        }
Exemplo n.º 17
0
        public JsonResult FavoriteDeleteUDF(long Id)
        {
            string       result = string.Empty;
            FavoriteItem objFs  = db.FavoriteItems.Find(Id);

            db.Entry(objFs).State = EntityState.Deleted;
            db.FavoriteItems.Remove(objFs);
            db.SaveChanges();
            result = "success";
            return(Json(result, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 18
0
        public FavoriteWindowVM(FavoriteItem existingItem = null)
        {
            if (existingItem == null)
            {
                return;
            }

            Index       = existingItem.Index;
            Description = existingItem.Description;
            Query       = existingItem.Query;
        }
Exemplo n.º 19
0
        public void ClickEvents()
        {
            if (isFavorite == FavoriteItem.FALSE)
            {
                isFavorite = FavoriteItem.TRUE;
            }

            else
            {
                isFavorite = FavoriteItem.FALSE;
            }
        }
 void StartEditing(FavoriteItem favorite, bool stopEditing = false)
 {
     if (stopEditing)
     {
         FavoritesModel.EditedFavorite = null;
     }
     else
     {
         FavoritesModel.EditedFavorite   = favorite;
         favorite.DisplayState.IsEditing = true;
     }
 }
 void StartEditing(FavoriteItem favorite, bool stopEditing = false)
 {
     if (stopEditing)
     {
         FavoritesModel.EditedFavorite = new FavoriteItem();
     }
     else
     {
         FavoritesModel.EditedFavorite   = favorite;
         favorite.DisplayState.IsEditing = true;
         TextFavoriteTitle.Focus();
     }
 }
Exemplo n.º 22
0
 public void Favorite(int type, int id)
 {
     if (type == 1)
     {
         FavoriteItem obj = new FavoriteItem();
         obj.ProductId = id;
         App.Database.SaveProduct(obj);
     }
     else
     {
         App.Database.ClearProduct(id);
     }
 }
Exemplo n.º 23
0
        public static List <FavoriteItem> UpdateFavoriteItem(FavoriteItem item)
        {
            var list     = GetFavoriteList();
            var listItem = list.First(x => x.Index == item.Index);

            listItem.Description = item.Description;
            listItem.Query       = item.Query;
            listItem.Var1        = item.Var1;
            listItem.Var2        = item.Var2;
            listItem.Var3        = item.Var3;

            WriteToFile(list);
            return(list);
        }
Exemplo n.º 24
0
        public override async Task Remove(FavoriteItem <Author> item)
        {
            for (var i = 0; i < Items.Count; i++)
            {
                if (Items[i].Item.Uri == item.Item.Uri)
                {
                    await Items[i].Item.UnFollow();

                    Items.RemoveAt(i);

                    break;
                }
            }
            OnPropertyChanged("Count");
        }
 public Task AddAsync(FavoriteItem model) => Task.Run(() =>
 {
     var item = FavoritesTableEntityDataMapper.Transform(model);
     var con  = Database.GetConnectionInstance();
     lock (con)
     {
         try
         {
             con.BeginTransaction();
             con.Insert(item);
         }
         catch (Exception e) { throw e; }
         finally { con.Commit(); }
     }
 });
        View GetView(FavoriteItem item, int position, View convertView, ViewGroup parent)
        {
            View view = convertView;

            if (view == null)
            {
                view = Activity.LayoutInflater.Inflate(Resource.Layout.FavoriteItem, null);
                view.FindViewById <Button>(Resource.Id.btnFollow).Click += (sender, args) =>
                {
                    var model = adapter.Items[(int)view.Tag];
                    Shared.Follower.FollowToggle(ActivityProgresDialog, sender as Button, model, model.Id, model.Type);
                };

                view.FindViewById <TextView>(Resource.Id.lblTitle).Click += (sender, args) =>
                {
                    var model = adapter.Items[(int)view.Tag];
                    GoToProfile(model);
                };

                view.FindViewById <ImageViewAsync>(Resource.Id.imgProfile).Click += (sender, args) =>
                {
                    var model = adapter.Items[(int)view.Tag];
                    GoToProfile(model);
                };
            }
            view.Tag = position;

            view.FindViewById <TextView>(Resource.Id.lblTitle).Text          = item.Title;
            view.FindViewById <TextView>(Resource.Id.lblSubtitle).Text       = item.Subtitle;
            view.FindViewById <TextView>(Resource.Id.lblSubtitle).Visibility = string.IsNullOrEmpty(item.Subtitle) ? ViewStates.Gone : ViewStates.Visible;

            var profileImageView = view.FindViewById <ImageViewAsync>(Resource.Id.imgProfile);

            profileImageView.Tag?.CancelPendingTask(item.ProfileUrl);
            var task = ImageService.Instance.LoadUrl(item.ProfileUrl)
                       .Retry(3, 300)
                       .LoadingPlaceholder(Resource.Drawable.DefProfPic.ToString(), ImageSource.CompiledResource)
                       .Transform(new CircleTransformation())
                       .Into(profileImageView);

            profileImageView.Tag = new ImageLoaderHelper(task);

            Views.SetFollowed(view.FindViewById <Button>(Resource.Id.btnFollow), item.IsFollowing);

            return(view);
        }
Exemplo n.º 27
0
        /// <summary>
        /// Add a new favorite for user
        /// </summary>
        /// <param name="userID">添加收藏夹项的用户</param>
        /// <param name="productID">添加的商品</param>
        /// <returns>成功收藏返回true,否则返回false</returns>
        public static bool AddNewFavorite(int userID, int productID)
        {
            using (SolemartDBContext context = new SolemartDBContext())
            {
                FavoriteItem favorite = context.FavoriteItems.FirstOrDefault(f => (f.UserID == userID && f.ProductID == productID));
                if (favorite != null)
                {
                    favorite.FavoriteTime = DateTime.Now;
                }
                else
                {
                    context.FavoriteItems.Add(favorite);
                }

                return(context.SaveChanges() > 0);
            }
        }
Exemplo n.º 28
0
        private FavoriteItem PopulateFavoriteItemFromDataReader(SqlDataReader dr)
        {
            var favoriteItem = new FavoriteItem();

            favoriteItem.ListingId        = (int)dr["ListingId"];
            favoriteItem.UserId           = dr["UserId"].ToString();
            favoriteItem.StateId          = dr["StateId"].ToString();
            favoriteItem.BathroomTypeId   = (int)dr["BathroomTypeId"];
            favoriteItem.BathroomTypeName = dr["BathroomTypeName"].ToString();
            favoriteItem.City             = dr["City"].ToString();
            favoriteItem.Rate             = (decimal)dr["Rate"];
            favoriteItem.SquareFootage    = (decimal)dr["SquareFootage"];
            favoriteItem.HasElectric      = (bool)dr["HasElectric"];
            favoriteItem.HasHeat          = (bool)dr["HasHeat"];

            return(favoriteItem);
        }
Exemplo n.º 29
0
        /// <summary>
        /// 查询单个模型实体
        /// </summary>
        /// <param name="id">uuid</param>);
        /// <returns>实体</returns>);
        public FavoriteItem QuerySingleById(long uuid)
        {
            const string sql = "SELECT TOP 1 uuid,num_iid,favorites_id,title,pict_url,small_images,reserve_price,zk_final_price,user_type,provcity,item_url,click_url,volume,tk_rate,zk_final_price_wap,event_start_time,event_end_time from FavoriteItem WHERE [uuid] = @uuid";

            using (var reader = SqlHelper.ExecuteReader(sql, new SqlParameter("@uuid", uuid)))
            {
                if (reader.HasRows)
                {
                    reader.Read();
                    FavoriteItem model = SqlHelper.MapEntity <FavoriteItem>(reader);
                    return(model);
                }
                else
                {
                    return(null);
                }
            }
        }
Exemplo n.º 30
0
        private async Task DownloadWrapper(FavoriteItem fav)
        {
            var videoName = $"{fav.Author.UniqueId} - {fav.Desc}";

            videoName = RemoveForbiddenChars(videoName);
            try
            {
                await DownloadVideoAsync(fav.Video.DownloadAddr.ToString(), videoName);
            }
            catch (Exception ex)
            {
                CatchException(ex, fav.Id, "logsJson.txt");
            }

            semaphore.Wait();
            counter++;
            Progress = $"{counter}/{total}";
            semaphore.Release();
        }
Exemplo n.º 31
0
        private void AddFavButton_Click(object sender, RoutedEventArgs e)
        {
            FavoriteAddDialog dlg = new FavoriteAddDialog();

            if(dlg.ShowDialog(((dynamic)MainWebBrowser.Document).Title, MainWebBrowser.Source.ToString()) == true)
            {
                FavoriteItem item = new FavoriteItem(dlg.FavTitle, dlg.FavURL);
                favoriteColleciton.Add(item);
            }
        }