Exemple #1
0
        /// <summary>
        /// Get all.
        /// </summary>
        /// <returns>List all product tag</returns>
        public List <C_ProductTag> GetAll()
        {
            using (var data = new Entities())
            {
                try
                {
                    List <C_ProductTag> lst = new List <C_ProductTag>();
                    var c_gen = (from t in data.C_ProductTag
                                 group t by new { t.Tag, t.Link } into g
                                 select new { Tag = g.Key.Tag, Link = g.Key.Link }).ToList();
                    if (c_gen.Count > 0)
                    {
                        foreach (var it in c_gen)
                        {
                            C_ProductTag tag = new C_ProductTag();
                            tag.Tag          = it.Tag;
                            tag.Link         = it.Link;
                            tag.ProductTagID = 99999999;
                            tag.ProductID    = 99999999;
                            lst.Add(tag);
                        }
                    }

                    return(lst);
                }
                catch (Exception)
                {
                    return(null);
                }
            }
        }
Exemple #2
0
        /// <summary>
        /// Gets the tag by link.
        /// </summary>
        /// <param name="link">The link.</param>
        /// <returns>the tag</returns>
        public C_ProductTag GetTagByLink(string link)
        {
            List <C_ProductTag> lstTag = this.GetAll().FindAll(delegate(C_ProductTag tag)
            {
                return(tag.Link.Contains(link));
            });

            if (lstTag.Count > 0)
            {
                C_ProductTag tagreturn = lstTag[0];

                return(tagreturn);
            }
            else
            {
                return(new C_ProductTag());
            }
        }
Exemple #3
0
        /// <summary>
        /// Add the tag.
        /// </summary>
        /// <param name="tag">tag object.</param>
        /// <returns>status add</returns>
        public bool Add_Tag(C_ProductTag tag)
        {
            using (var data = new Entities())
            {
                bool rt;
                try
                {
                    data.C_ProductTag.Add(tag);
                    data.SaveChanges();

                    rt = true;
                }
                catch (Exception)
                {
                    rt = false;
                }

                return(rt);
            }
        }
Exemple #4
0
        /// <summary>
        /// Edit the tag.
        /// </summary>
        /// <param name="tag">tag object.</param>
        /// <returns>status edit tag</returns>
        public bool Edit_Tag(C_ProductTag tag)
        {
            using (var data = new Entities())
            {
                bool rt;
                try
                {
                    var c_gen = data.C_ProductTag.Where(p => p.ProductTagID == tag.ProductTagID).FirstOrDefault();
                    c_gen.ProductID = tag.ProductID;
                    c_gen.Tag       = tag.Tag;
                    c_gen.Link      = tag.Link;

                    data.SaveChanges();

                    rt = true;
                }
                catch (Exception)
                {
                    rt = false;
                }

                return(rt);
            }
        }