Beispiel #1
0
 /// <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;
 }
Beispiel #2
0
        /// <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;
        }