Exemple #1
0
        public override UITableViewCell GetCell(UITableView tableView, NSIndexPath indexPath)
        {
            UITableViewCell cell = tableView.DequeueReusableCell(cellIdentifier);


            if (cell == null)
            {
                cell = new UITableViewCell(UITableViewCellStyle.Subtitle, cellIdentifier);
            }


            OrdersAdmin orders        = Items[indexPath.Row];
            string      personOrdered = orders.PersonOrdered;

            cell.TextLabel.Text = personOrdered;

            return(cell);
        }
Exemple #2
0
        public override void RowSelected(UITableView tableView, NSIndexPath indexPath)
        {
            OrdersAdmin orders = Items[indexPath.Row];

            Debug.WriteLine(orders.Items);

            UIAlertView alert = new UIAlertView();

            string s = "";

            alert.Title = "Order items";

            foreach (string elements in orders.Items)
            {
                s += elements + "\n";
            }

            alert.Message = s.Trim();
            alert.AddButton("OK");
            alert.Show();
        }
Exemple #3
0
        public override async void CommitEditingStyle(UITableView tableView, UITableViewCellEditingStyle editingStyle, NSIndexPath indexPath)
        {
            switch (editingStyle)
            {
            case UITableViewCellEditingStyle.Delete:

                OrdersAdmin orders   = Items[indexPath.Row];
                string      objectID = orders.ObjectId;

                if (!orders.Price.Equals(0))
                {
                    try
                    {
                        var pObj = new ParseObject("Unpaid");
                        pObj["Name"]        = orders.PersonOrdered;
                        pObj["AmountOwing"] = orders.Price;
                        pObj["UserChannel"] = orders.Channel;
                        pObj["Paid"]        = false;
                        await pObj.SaveAsync();
                    }
                    catch (ParseException ex)
                    {
                        Debug.WriteLine(ex.Message);
                    }
                }

                Items.Remove(orders);
                tableView.DeleteRows(new NSIndexPath[] { indexPath }, UITableViewRowAnimation.Fade);

                //updating isOrderDone

                try
                {
                    ParseQuery <ParseObject> queryForUpdate = from ordersTB in ParseObject.GetQuery("Orders")
                                                              where ordersTB.Get <string>("objectId") == objectID
                                                              select ordersTB;

                    ParseObject obj = await queryForUpdate.FirstAsync();

                    obj["IsOrderDone"] = true;
                    await obj.SaveAsync();

                    //send push

                    var push = new ParsePush();
                    push.Channels = new List <string> {
                        orders.Channel
                    };

                    push.Data = new Dictionary <string, object>
                    {
                        { "alert", UpperCaseFirstCharacterName(orders.PersonOrdered) + ", your order is ready!!!" },
                        { "sound", "default" }
                    };

                    await push.SendAsync();

                    Toast.MakeText("Order updated successfuly").Show();
                }
                catch (ParseException e)
                {
                    Debug.WriteLine(e.StackTrace);
                }

                break;

            case UITableViewCellEditingStyle.None:
                Debug.WriteLine("Nothing");
                break;
            }
        }