Ejemplo n.º 1
0
        public void TestAddToList()
        {
            ParseObject obj = new ParseObject("Corgi");

            obj.AddToList("emptyList", "gogo");
            obj["existingList"] = new List <string>()
            {
                "rich"
            };

            Assert.True(obj.ContainsKey("emptyList"));
            Assert.AreEqual(1, obj.Get <List <object> >("emptyList").Count);

            obj.AddToList("existingList", "gogo");
            Assert.True(obj.ContainsKey("existingList"));
            Assert.AreEqual(2, obj.Get <List <object> >("existingList").Count);

            obj.AddToList("existingList", 1);
            Assert.AreEqual(3, obj.Get <List <object> >("existingList").Count);

            obj.AddRangeToList("newRange", new List <string>()
            {
                "anti", "mage"
            });
            Assert.AreEqual(2, obj.Get <List <object> >("newRange").Count);
        }
Ejemplo n.º 2
0
    private ParseObject CreateInstallationObject(string token, string deviceType)
    {
        var obj = new ParseObject("_Installation");

        obj["deviceToken"]   = token;
        obj["appIdentifier"] = "com.example.parsenotifications"; //replace with yours
        obj["deviceType"]    = deviceType;
        obj["timeZone"]      = "UTC";
        obj["appName"]       = "SUPER AWESOME GAME 4"; //replace with yours
        obj.AddToList("channels", "chanel1");
        obj.AddToList("channels", "chanel2");
        UpdateObject(obj);
        return(obj);
    }
Ejemplo n.º 3
0
    public static void AddCorrectInRow(int count)
    {
        GameSessionObj.AddToList("correctInRow", count);
        GameSessionObj.SaveAsync().ContinueWith(secondTask => {
            if (secondTask.IsFaulted || secondTask.IsCanceled)
            {
                IEnumerable <Exception> exceptions = secondTask.Exception.InnerExceptions;

                foreach (var exception in exceptions)
                {
                    Debug.Log("correctInRow add error : " + exception.Message);
                }
            }
            else
            {
                Debug.Log("correctInRow added successfully");
            }
        });
    }
Ejemplo n.º 4
0
        public async Task <ActionResult> Add()
        {
            String             bType       = Request.Form["TypeSelect"];
            String             bTimeStr    = Request.Form["dateInput"];
            float              bAmount     = float.Parse(Request.Form["AmountInput"], CultureInfo.InvariantCulture.NumberFormat);
            DateTime           bTime       = Convert.ToDateTime(bTimeStr);
            HttpPostedFileBase currentFile = Request.Files[0];

            string fileName = currentFile.FileName;

            MemoryStream target = new MemoryStream();

            currentFile.InputStream.CopyTo(target);
            byte[] data = target.ToArray();

            ParseFile file = new ParseFile(fileName, data);
            await file.SaveAsync();

            ParseObject bill = new ParseObject("Bills");

            bill["Type"]    = bType;
            bill["Price"]   = bAmount;
            bill["Date"]    = bTime;
            bill["Receipt"] = file;
            await bill.SaveAsync();

            ParseObject userBuilding = ParseUser.CurrentUser.Get <ParseObject>("Building");
            await userBuilding.FetchAsync();

            await bill.FetchAsync();

            userBuilding.AddToList("BillsList", bill.ObjectId);
            await userBuilding.SaveAsync();


            return(RedirectToAction("Index", "AdminNavigation"));
        }