Beispiel #1
0
        ////public bool Add(int id, string name, string value, string type)
        ////{
        ////    using (var data = new Entities())
        ////    {
        ////        bool rt = false;
        ////        try
        ////        {
        ////            C_ProductProperty it = new C_ProductProperty();
        ////            it.ProductID = id;
        ////            it.Name = name;
        ////            it.Value = value;
        ////            it.Type = type;
        ////            data.C_ProductProperty.Add(it);
        ////            data.SaveChanges();
        ////            rt = true;
        ////        }
        ////        catch (Exception)
        ////        {
        ////            rt = false;
        ////        }
        ////        return rt;
        ////    }
        ////}

        /// <summary>
        /// Edits the specified product Property Object.
        /// </summary>
        /// <param name="propertyObject">product Property Object.</param>
        /// <returns>status edit property</returns>
        public bool Edit(C_ProductProperty propertyObject)
        {
            using (var data = new Entities())
            {
                bool rt = false;
                try
                {
                    var c_gen = data.C_ProductProperty.Where(p => p.ProID == propertyObject.ProID).FirstOrDefault();
                    c_gen.Name      = propertyObject.Name;
                    c_gen.Value     = propertyObject.Value;
                    c_gen.ProductID = propertyObject.ProductID;
                    c_gen.Type      = propertyObject.Type;

                    data.SaveChanges();

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

                return(rt);
            }
        }
Beispiel #2
0
        /// <summary>
        /// Gets the type of the property by.
        /// </summary>
        /// <param name="type">The type.</param>
        /// <returns>the type of the property</returns>
        public List <C_ProductProperty> GetPropertyByType(string type)
        {
            using (var data = new Entities())
            {
                try
                {
                    //// First, check the cache
                    List <C_ProductProperty> c_gen = this.Cache.Get(type) as List <C_ProductProperty>;

                    if (c_gen == null)
                    {
                        c_gen = new List <C_ProductProperty>();
                        var lst = (from pp in data.C_ProductProperty
                                   group pp by new { pp.Type, pp.Value, pp.Name } into gpp
                                   select new { Type = gpp.Key.Type, Name = gpp.Key.Name, Value = gpp.Key.Value }).Where(c => c.Type == type).ToList();

                        if (lst.Count > 0)
                        {
                            foreach (var it in lst)
                            {
                                C_ProductProperty c_p = new C_ProductProperty();
                                c_p.Name      = it.Name;
                                c_p.Value     = it.Value;
                                c_p.Type      = it.Type;
                                c_p.ProID     = 999999;
                                c_p.ProductID = 999999;
                                c_gen.Add(c_p);
                            }
                        }

                        if (c_gen.Any())
                        {
                            //// Put this data into the cache for 10 minutes
                            this.Cache.Set(type, c_gen, int.Parse(Util.GetConfigValue(CommonGlobal.TimeCache, "10")));
                        }
                    }

                    return(c_gen);
                }
                catch (Exception)
                {
                    return(null);
                }
            }
        }
Beispiel #3
0
        /// <summary>
        /// Add the specified object.
        /// </summary>
        /// <param name="productProperty">product property object.</param>
        /// <returns>Add the specified</returns>
        public bool Add(C_ProductProperty productProperty)
        {
            using (var data = new Entities())
            {
                bool rt = false;
                try
                {
                    data.C_ProductProperty.Add(productProperty);
                    data.SaveChanges();

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

                return(rt);
            }
        }