Пример #1
0
        /// <summary>
        /// This constructor is used when the goal is to edit an existing travel.
        /// </summary>
        /// <param name="travel">The travel wanted to be edited.</param>
        public AddTravelData(Travel travel)
        {
            InitializeComponent();

            this.IsNewTravel            = false;
            this.travel.ID              = travel.ID;
            this.travel.CarLicensePlate = travel.CarLicensePlate;

            TravelDate.Date  = new DateTime(travel.TravelDate.Year, travel.TravelDate.Month, travel.TravelDate.Day);
            StartPoint.Text  = travel.StartPoint;
            Destination.Text = travel.Destination;
            Distance.Text    = travel.Distance.ToString();

            Title = "Utazás szerkesztése: " + travel.CarLicensePlate;
        }
Пример #2
0
        /// <summary>
        /// Removes the given item from database and if it succeeded, removes it from the given collection
        /// </summary>
        /// <param name="list"></param>
        /// <param name="item"></param>
        void RemoveFromDatabaseAndList(ObservableCollection <Travel> list, Travel item)
        {
            bool success = false;

            try
            {
                database.Delete <Travel>(item.ID);
                success = true;
            }
            catch (SQLiteException ex)
            {
                throw ex;
            }
            finally
            {
                if (success)
                {
                    list.Remove(item);
                }
            }
        }
Пример #3
0
 /// <summary>
 /// Updates an existing travel's data in database based on its ID property.
 /// </summary>
 /// <param name="travel">Travel to be changed in database.</param>
 private void UpdateTravel(Travel travel)
 {
     database.CreateTable <Travel>();
     database.Update(travel);
     MessagingCenter.Send(this, "DatabaseOperationSucceeded", travel);
 }