Exemple #1
0
        private void SaveButton_TouchUpInside(object sender, EventArgs e)
        {
            if (!AreFieldsValid())
            {
                return;
            }

            MainTask newTask = new MainTask();

            newTask.Title   = titleTextField.Text;
            newTask.Date    = date;
            newTask.Time    = date;
            newTask.Comment = commentTextView.Text;
            if (img_UploadImage.CurrentImage != null)
            {
                NSData imageData = img_UploadImage.CurrentImage.AsJPEG(0.5f);

                string encodedImage = imageData.GetBase64EncodedData(NSDataBase64EncodingOptions.None).ToString();
                newTask.Image = encodedImage;
            }
            else
            {
                newTask.Image = "";
            }
            if (map != null)
            {
                newTask.Longtitude = map.Annotations[0].Coordinate.Longitude;
                newTask.Latitude   = map.Annotations[0].Coordinate.Latitude;
            }

            Database.saveTask(newTask);
            Console.WriteLine("Count = " + Database.CountTasks());

            Console.WriteLine("All Task");
            List <MainTask> allTasks = Database.GetAllTasks();

            foreach (MainTask t in allTasks)
            {
                Console.WriteLine(t);
            }

            Console.WriteLine("Today Tasks");
            List <MainTask> todays = Database.GetTodayTasks();

            foreach (MainTask t in todays)
            {
                Console.WriteLine(t);
            }

            #region CreateNotification
            var notification = new UILocalNotification();

            notification.FireDate = dateDatePicker.Date;

            notification.AlertAction = newTask.Title;
            notification.AlertBody   = newTask.Comment;

            notification.ApplicationIconBadgeNumber = 1;

            notification.SoundName = UILocalNotification.DefaultSoundName;

            UIApplication.SharedApplication.ScheduleLocalNotification(notification);
            #endregion

            NavigationController.PopViewController(true);
        }