예제 #1
0
        public void SaveExpense(Trip trip, Expense expense)
        {
            if (trip.Expenses.FirstOrDefault((x) => x.Id == expense.Id) != null)
                trip.Expenses.Remove(expense);
            trip.Expenses.Add(expense);
            SaveTrip(trip);

        }
예제 #2
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            SetContentView(Resource.Layout.EditExpense);

            var tripId = Intent.GetStringExtra("SelectedTripId");

            _trip = new TripManager().GetTrip(new Guid(tripId));
            var expenseId = Intent.GetStringExtra("SelectedExpenseId");

            if (!string.IsNullOrEmpty(expenseId))
                _expense = _trip.Expenses.FirstOrDefault((x) => x.Id == new Guid(expenseId));
            else
            {
                _expense = new Expense() {Date = DateTime.Now};
            }

            FindViewById<Button>(Resource.Id.editExpenseButtonSave).Click += (s, e) =>
            {
                UpdateExpense();
                new TripManager().SaveExpense(_trip, _expense);

                var intent = new Intent(this, typeof(ViewTripDetailScreen));
                intent.PutExtra("SelectedTripId", _trip.Id.ToString());

                base.StartActivity(intent);
            };

            FindViewById<Button>(Resource.Id.editExpenseButtonDelete).Click += (s, e) =>
            {
                
                new TripManager().RemoveExpense(_trip, _expense);

                var intent = new Intent(this, typeof(ViewTripDetailScreen));
                intent.PutExtra("SelectedTripId", _trip.Id.ToString());
                base.StartActivity(intent);
            };

            UpdateUI();
        }
예제 #3
0
 public void RemoveExpense(Trip trip, Expense expense)
 {
     trip.Expenses.Remove(expense);
     SaveTrip(trip);
 }
예제 #4
0
 public void RemoveExpense(Trip trip, Expense expense)
 {
     _tripRepository.RemoveExpense(trip, expense);
 }
예제 #5
0
 public void SaveExpense(Trip trip, Expense expense)
 {
     _tripRepository.SaveExpense(trip, expense);
 }