コード例 #1
0
ファイル: MallManager.cs プロジェクト: 21ki/kuanmai
        /// <summary>
        /// Update mall name or description
        /// </summary>
        /// <param name="mall"></param>
        /// <returns></returns>
        public bool UpdateMall(Mall_Type mall)
        {
            bool      result    = false;
            Mall_Type mall_type = null;

            using (KuanMaiEntities db = new KuanMaiEntities())
            {
                if (mall.Mall_Type_ID > 0)
                {
                    mall_type = this.GetMallDetail(mall.Mall_Type_ID);
                }
                else if (!string.IsNullOrEmpty(mall.Name))
                {
                    mall_type = this.GetMallDetail(mall.Name);
                }

                if (mall_type != null)
                {
                    db.Mall_Type.Attach(mall_type);
                    mall_type.Name        = mall.Name;
                    mall_type.Description = mall.Description;
                    db.SaveChanges();
                    result = true;
                }
            }

            return(result);
        }
コード例 #2
0
ファイル: MallManager.cs プロジェクト: 21ki/kuanmai
        /// <summary>
        /// Get mall object by mall id
        /// </summary>
        /// <param name="mall_type_id"></param>
        /// <returns></returns>
        public Mall_Type GetMallDetail(long mall_type_id)
        {
            Mall_Type mall = null;

            using (KuanMaiEntities db = new KuanMaiEntities())
            {
                var mt = from malltype in db.Mall_Type where malltype.Mall_Type_ID == mall_type_id select malltype;
                if (mt != null)
                {
                    mall = mt.ToList <Mall_Type>()[0];
                }
            }
            return(mall);
        }
コード例 #3
0
ファイル: MallManager.cs プロジェクト: 21ki/kuanmai
        /// <summary>
        /// Get mall object by mall name
        /// </summary>
        /// <param name="name"></param>
        /// <returns></returns>
        public Mall_Type GetMallDetail(string name)
        {
            Mall_Type mall = null;

            using (KuanMaiEntities db = new KuanMaiEntities())
            {
                var mt = from malltype in db.Mall_Type where malltype.Name == name select malltype;
                if (mt != null)
                {
                    mall = mt.ToList <Mall_Type>()[0];
                }
            }
            return(mall);
        }
コード例 #4
0
        protected Mall_Type GetMallType()
        {
            Mall_Type type = null;

            using (KuanMaiEntities db = new KuanMaiEntities())
            {
                var t = from tp in db.Mall_Type where tp.Mall_Type_ID == this.Mall_Type_ID select tp;
                if (t.ToList <Mall_Type>().Count == 1)
                {
                    type = t.ToList <Mall_Type>()[0];
                }
            }

            return(type);
        }
コード例 #5
0
ファイル: MallManager.cs プロジェクト: 21ki/kuanmai
        /// <summary>
        /// Add new mall in local db
        /// </summary>
        /// <param name="mall"></param>
        /// <returns></returns>
        public bool AddNewMall(Mall_Type mall)
        {
            bool result = false;

            if (mall == null)
            {
                return(result);
            }
            if (string.IsNullOrEmpty(mall.Name))
            {
                return(result);
            }
            using (KuanMaiEntities db = new KuanMaiEntities())
            {
                db.Mall_Type.Add(mall);
                db.SaveChanges();
                result = true;
            }
            return(result);
        }