Example #1
0
        // POST api/<controller>
        public Hashtable Post([FromBody] int id_group, [FromBody] int id_in_area)
        {
            Hashtable ht    = new Hashtable();
            GroupInfo ai    = new GroupInfo();
            int       admin = UserInfo.GetUserIdFromCookie(HttpContext.Current);

            if (ai.HasGroup(id_in_area, admin))
            {
                ht.Add("state", false);
                ht.Add("reason", "小组号已存在");
            }
            else
            {
                try
                {
                    ht.Add("state", ai.ChangeGroupid(id_group, id_in_area));
                }
                catch (Exception e)
                {
                    ht.Add("state", false);
                    ht.Add("reason", e.Message);
                }
            }
            return(ht);
        }
        public Hashtable Put(int id, int group_name, string name, string user_number)
        {
            int       admin = UserInfo.GetUserIdFromCookie(HttpContext.Current);
            Hashtable ht    = new Hashtable();
            Hashtable data  = new Hashtable();
            AdminInfo ai    = new AdminInfo();
            GroupInfo ari   = new GroupInfo();

            /*if (ai.HasAreaUserName(name))
             * {
             *  ht.Add("code", 40000);
             *  data.Add("message", "管理员已存在");
             * }
             * else if (ari.HasGroup(group_name, admin))
             * {
             *  ht.Add("code", 40000);
             *  data.Add("message", "小组号已存在");
             * }
             * else
             * {*/
            try
            {
                if (ari.ChangeGroupid(id, group_name) &&
                    ai.ChangeGroupAdmin(id, name, null, user_number, admin))
                {
                    ht.Add("code", 20000);
                    data.Add("status", "success");
                }
                else
                {
                    ht.Add("code", 40000);
                    data.Add("message", "failed");
                }
            }
            catch (Exception e)
            {
                ht.Add("code", 40000);
                data.Add("message", e.Message);
            }

            //}
            ht.Add("data", data);
            return(ht);
        }