Example #1
0
        private void _startActivityButton_Click(object sender, EventArgs e)
        {
            // Get the base starting time and start the timer
            _currentOutsideActivity = new OutsideActivity(true);
            ResetChronometer();
            _currentOutsideActivity.StartTime = DateTime.Now;
            _currentOutsideActivity.Name      = "outsideActivity-" + _currentOutsideActivity.StartTime.ToString("yyyyMMddHHmmssff", CultureInfo.CurrentCulture);

            _currentOutsideActivity.UserId = _currentUser.UserId;

            _dataService.CreateOutsideActivity(_currentOutsideActivity);

            SetActivityTimingView();
        }
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            Xamarin.Essentials.Platform.Init(this, savedInstanceState);
            SetContentView(Resource.Layout.edit_outside_activity);

            _dataService.Initialize();

            try
            {
                var selectedOutsideActivityId = Intent.Extras.GetInt("selectedOutsideActivityId");

                outsideActivities = _dataService.GetOutsideActivity();
                outsideActivity   = outsideActivities[selectedOutsideActivityId];
                //outsideActivity = _dataService.GetOutsideActivity(selectedOutsideActivityId);
            }
            catch (System.NullReferenceException)
            {
                _updateOutsideActivityButtonLabel = "Add Activity";
                _deleteOutsideActivityButtonLabel = "Discard Activity";
                outsideActivity           = new OutsideActivity();
                outsideActivity.StartTime = DateTime.Now.AddHours(-2);
                _dataService.CreateOutsideActivity(outsideActivity);
            }
            catch (System.ArgumentOutOfRangeException)
            {
                _updateOutsideActivityButtonLabel = "Add Activity";
                _deleteOutsideActivityButtonLabel = "Discard Activity";
                outsideActivity           = new OutsideActivity();
                outsideActivity.StartTime = DateTime.Now.AddHours(-2);
                _dataService.CreateOutsideActivity(outsideActivity);
            }

            FindViews();
            LinkEventHandlers();
        }
Example #3
0
        private void _addHoursButton_Click(object sender, EventArgs e)
        {
            // Get the base starting time and start the timer
            _newOutsideActivity.Done       = true;
            _newOutsideActivity.IsTracking = false;

            _newOutsideActivity.StartTime            = _dateOfActivityDatePicker.DateTime;
            _newOutsideActivity.DurationMilliseconds = _hoursToAddNumberPicker.Value * 3600000;
            _newOutsideActivity.Name = "outsideActivity-" + _newOutsideActivity.StartTime.ToString("yyyyMMddHHmmssff", CultureInfo.CurrentCulture);

            _newOutsideActivity.EndTime = _newOutsideActivity.StartTime.AddMilliseconds(_newOutsideActivity.DurationMilliseconds);

            _dataService.CreateOutsideActivity(_newOutsideActivity);
            //base.OnBackPressed();
            string toastMessage = String.Format(CultureInfo.CurrentCulture, "Inserted {0} activity", _newOutsideActivity.Name);

            Toast.MakeText(Application.Context, toastMessage, ToastLength.Short).Show();
            Finish();
        }