示例#1
0
 public UserMeta(UserMeta userMeta)
 {
     username = userMeta.username;
     uid      = userMeta.uid;
     nickname = userMeta.nickname;
     role     = userMeta.role;
 }
示例#2
0
        //user
        public async Task updateProfile(string nickname, string password, Action <ResponseError, UserMeta, string> cb)
        {
            if (!this.role)
            {
                cb(null, null, "没有权限的操作");
                return;
            }
            ;

            var body = new Dictionary <string, string> {
                { "uid", uid }
            };

            if (nickname != null)
            {
                body["nickname"] = nickname;
            }
            if (password != null)
            {
                body["password"] = password;
            }
            string info   = JsonConvert.SerializeObject(body, Formatting.Indented);
            string result = "";
            ServerResponse <UserMeta> res = null;

            try
            {
                result = await Server.getInstance().put("api/user/update", info);
            }
            catch (Exception e)
            {
                cb(new ResponseError("NETWORK_ERROR", "无法连接服务器"), null, "无法连接服务器");
                return;
            }
            try
            {
                res = JsonConvert.DeserializeObject <ServerResponse <UserMeta> >(result);
            }
            catch (Exception e)
            {
                cb(new ResponseError("BAD_DATA", "无法解析服务器返回的信息"), null, "无法解析服务器返回的信息: " + result);
                return;
            }
            if (res.isSuccess())
            {
                UserMeta data = res.getData();
                cb(null, data, res.getMessage());
            }
            else
            {
                cb(res.getError(), null, res.getMessage());
            }
            return;
        }
示例#3
0
 public User(UserMeta userMeta, string Email) : base(userMeta)
 {
     email = Email;
 }
示例#4
0
 public User(UserMeta userMeta, string Email, string Password) : base(userMeta)
 {
     email    = Email;
     password = Password;
 }