Exemple #1
0
        partial void AddButton_TouchUpInside(UIButton sender)
        {
            Utils.Task task = new Utils.Task();

            task.Id          = Guid.NewGuid().ToString();
            task.description = taskInputText.Text;
            task.createdDate = DateTime.Now.ToString();

            NSString text  = new NSString(task.description);
            var      child = dbReference.GetChild(task.Id);

            child.SetValue <NSString>(text);

            var iconattrs = new Dictionary <string, string>
            {
                { "Id", task.Id },
                { "Description", task.description },
                { "CreatedDate", task.createdDate }
            };

            var myResult = NSDictionary.FromObjectsAndKeys(iconattrs.Values.ToArray()
                                                           , iconattrs.Keys.ToArray());

            child.SetValue <NSDictionary>(myResult);
        }
Exemple #2
0
        void HandleDatabaseQueryUpdateHandler(DataSnapshot snapshot)
        {
            tasks = new List <Utils.Task>();
            if (snapshot == null)
            {
                ToastIOS.Toast.MakeText("An Error occured reading data").Show();
                return;
            }

            try
            {
                var values = snapshot.GetValue <NSDictionary <NSString, NSString> >();

                foreach (var taskDict in values)
                {
                    var key      = taskDict.Key;
                    var keyValue = taskDict.Value;


                    var dictValue = (NSDictionary)keyValue;

                    var task = new Utils.Task();
                    task.Id          = dictValue["Id"].ToString();
                    task.description = dictValue["Description"].ToString();
                    task.createdDate = dictValue["CreatedDate"].ToString();
                    tasks.Add(task);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error: ", ex.Message);
            }
            tasksTableView.Source = new TaskTableSource(tasks);
        }