Example #1
0
        public NCMBObject Save()
        {
            NCMBRequest r        = new NCMBRequest(_ncmb);
            var         response = _fields.ContainsKey("objectId") ?
                                   r.Put(Name, (string)_fields.GetValue("objectId"), GetData()) :
                                   r.Post(Name, GetData());

            Sets(response);
            return(this);
        }
Example #2
0
        private NCMBRequest GetLoginRequest()
        {
            NCMBRequest r = new NCMBRequest();

            r.Name    = Name;
            r.Queries = GetData();
            r.Method  = "GET";
            r.Path    = "login";
            return(r);
        }
Example #3
0
        public async Task <bool> Delete()
        {
            NCMBRequest r = new NCMBRequest();

            r.Method   = "DELETE";
            r.Name     = Name;
            r.ObjectId = ObjectId();
            var response = await r.Exec();

            return(response.Count == 0);
        }
Example #4
0
        public async Task <bool> Fetch()
        {
            NCMBRequest r = new NCMBRequest();

            r.Method   = "GET";
            r.Name     = Name;
            r.ObjectId = ObjectId();
            var response = await r.Exec();

            Sets(response);
            return(true);
        }
Example #5
0
        new async public Task <bool> Save()
        {
            NCMBRequest r = new NCMBRequest();

            r.Name     = Name;
            r.Method   = "POST";
            r.Data     = data;
            r.Fields   = GetData();
            r.MimeType = MimeType;
            r.ObjectId = GetString("fileName");
            var response = await r.Exec();

            Sets(response);
            return(true);
        }
Example #6
0
        public NCMBRequest GetRequest()
        {
            NCMBRequest r = new NCMBRequest();

            r.Name   = Name;
            r.Fields = GetData();
            // Console.WriteLine(_fields);
            if (_fields.ContainsKey("objectId"))
            {
                r.Method   = "PUT";
                r.ObjectId = ObjectId();
            }
            else
            {
                r.Method = "POST";
            }
            return(r);
        }
Example #7
0
        public NCMBObject[] Find()
        {
            var queries = new JObject();

            if (where.Count > 0)
            {
                queries.Add("where", where);
            }
            var r       = new NCMBRequest(_ncmb);
            var results = r.Get(Name, queries);
            var ary     = (JArray)results.GetValue("results");
            var count   = ary.Count;
            var objs    = new NCMBObject[count];
            var i       = 0;

            foreach (var row in ary)
            {
                var obj = _ncmb.Object(Name);
                obj.Sets((JObject)row);
                objs[i] = obj;
                i++;
            }
            return(objs);
        }
Example #8
0
        private NCMBRequest GetClient()
        {
            var queries = new JObject();

            if (where.Count > 0)
            {
                queries.Add("where", where);
            }
            if (_limit > 0)
            {
                queries.Add("limit", _limit);
            }
            if (!(_order is null))
            {
                queries.Add("order", _order);
            }
            if (!(_include is null))
            {
                queries.Add("include", _include);
            }
            if (_skip > 0)
            {
                queries.Add("skip", _skip);
            }
            if (_count)
            {
                queries.Add("count", 1);
            }

            var r = new NCMBRequest();

            r.Name    = Name;
            r.Queries = queries;
            r.Method  = "GET";
            return(r);
        }
Example #9
0
        public bool Delete()
        {
            NCMBRequest r = new NCMBRequest(_ncmb);

            return(r.Delete(Name, (string)_fields.GetValue("objectId")));
        }