Beispiel #1
0
        public ArrayList UpdateCommunity(string userKey, Dictionary <string, object>[] paramDicts)
        {
            Exception erro    = null;
            object    data    = null;
            string    message = null;

            try
            {
                Models.Data.base_community_baseinfo community = paramDicts[0]["community"].ToString().JsonToModel <Models.Data.base_community_baseinfo>();
                using (var context = new Data.CbooEntities())
                {
                    context.base_community_baseinfo.Attach(community);
                    context.ObjectStateManager.ChangeObjectState(community, System.Data.EntityState.Modified);
                    int a = context.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                erro    = ex;
                message = ex.Message;
            }

            ArrayList revList = new ArrayList();

            revList.Add(new Models.ServerResult()
            {
                succeed = erro == null, data = data, message = message
            });
            return(revList);
        }
Beispiel #2
0
        public ArrayList DeleteCommunityList(string userKey, Dictionary <string, object>[] paramDicts)
        {
            Exception erro    = null;
            object    data    = null;
            string    message = null;

            try
            {
                List <string> communityList = paramDicts[0]["communityList"].ToString().JsonToModel <List <string> >();
                using (var context = new Data.CbooEntities())
                {
                    context.ExecuteStoreCommand(string.Format(_deleteCommunityList, communityList.GetSelectIn()));
                    int a = context.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                erro    = ex;
                message = ex.Message;
            }

            ArrayList revList = new ArrayList();

            revList.Add(new Models.ServerResult()
            {
                succeed = erro == null, data = data, message = message
            });
            return(revList);
        }
        /// <summary>
        /// add building info
        /// </summary>
        /// <param name="userKey"></param>
        /// <param name="paramDicts"></param>
        /// <returns></returns>
        public ArrayList AddBuilding(string userKey, Dictionary <string, object>[] paramDicts)
        {
            Exception erro    = null;
            object    data    = null;
            string    message = null;

            try
            {
                Models.Data.base_community_buildinginfo model = paramDicts[0]["building"].ToString().JsonToModel <Models.Data.base_community_buildinginfo>();
                model.building_id = Guid.NewGuid();
                model.status      = 1;
                using (var context = new Data.CbooEntities())
                {
                    context.base_community_buildinginfo.AddObject(model);
                    data = context.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                erro    = ex;
                message = ex.Message;
            }
            ArrayList revList = new ArrayList();

            revList.Add(new Models.ServerResult()
            {
                succeed = erro == null, data = data, message = message
            });
            return(revList);
        }
Beispiel #4
0
 public static int AddModel <TEntity>(TEntity model) where TEntity : class
 {
     using (var context = new Data.CbooEntities())
     {
         context.CreateObjectSet <TEntity>().AddObject(model);
         return(context.SaveChanges());
     }
 }
Beispiel #5
0
 public static int UpdateModel <TEntity>(TEntity model) where TEntity : class
 {
     using (var context = new Data.CbooEntities())
     {
         context.CreateObjectSet <TEntity>().Attach(model);
         context.ObjectStateManager.ChangeObjectState(model, System.Data.EntityState.Modified);
         return(context.SaveChanges());
     }
 }
Beispiel #6
0
        /// <summary>
        /// update TEntity set dr=1 where Primarykey = id
        /// </summary>
        /// <typeparam name="TEntity"></typeparam>
        /// <param name="id">Primary key</param>
        /// <returns></returns>
        public static int DeleteModel <TEntity>(string id) where TEntity : class
        {
            string tableName = typeof(TEntity).Name;

            using (var context = new Data.CbooEntities())
            {
                context.ExecuteStoreCommand(string.Format(_deleteModel, tableName, GetKey(tableName), id));
                return(context.SaveChanges());
            }
        }
        public ArrayList AddDict(string userKey, Dictionary <string, object>[] paramDicts)
        {
            Exception erro    = null;
            object    data    = null;
            string    message = null;

            try
            {
                Models.Data.base_datadic_tree model = paramDicts[0]["dict"].ToString().JsonToModel <Models.Data.base_datadic_tree>();
                model.item_id = Guid.NewGuid();
                model.leaf    = true;
                using (var context = new Data.CbooEntities())
                {
                    string max = (from dict in context.base_datadic_tree
                                  where dict.parent_id == model.parent_id
                                  select dict.item_key).Max();
                    if (max == null)
                    {
                        model.item_key = (from dict in context.base_datadic_tree
                                          where dict.item_id == model.parent_id
                                          select dict.item_key).First() + "01";
                    }
                    else
                    {
                        model.item_key = (long.Parse(max, System.Globalization.NumberStyles.HexNumber) + 1).ToString("X");
                    }

                    context.base_datadic_tree.AddObject(model);
                    (from parent in context.base_datadic_tree
                     where parent.item_id == model.parent_id
                     select parent).First().leaf = false;

                    data = context.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                erro    = ex;
                message = ex.Message;
            }
            ArrayList revList = new ArrayList();

            revList.Add(new Models.ServerResult()
            {
                succeed = erro == null, data = data, message = message
            });
            return(revList);
        }
Beispiel #8
0
        public ArrayList Register(string userKey, Dictionary <string, object>[] paramDicts)
        {
            //Models.User model = paramDicts[0]["user"].ToString().JsonToModel<Models.User>();
            {
                Models.Data.sys_user_baseinfo user = new Models.Data.sys_user_baseinfo();
                user.user_id   = Guid.NewGuid();
                user.city_name = "北京";
                using (var context = new Data.CbooEntities())
                {
                    context.sys_user_baseinfo.AddObject(user);
                    context.SaveChanges();
                }
            }
            ArrayList revList = new ArrayList();

            {
                //check user
            }
            revList.Add(new Models.ServerResult()
            {
                succeed = true, data = null, message = "message f!!!!!!"
            });
            return(revList);
        }