// Add new place to trip
        public static int AddNewPlaceToTrip(PlaceModel place, int tripID)
        {
            int currrentPlaceNumber = 0;

            using (var cnn = new SQLiteConnection(LoadConnectionString()))
            {
                currrentPlaceNumber = cnn.QueryFirst <int>($"SELECT IFNULL(MAX(NUMBER),0) FROM PLACE WHERE TRIPID = {tripID}");
                cnn.Execute($"INSERT INTO PLACE VALUES ({tripID},{currrentPlaceNumber + 1}, @Name, @Information,@DateStart,@DateFinish)", place);
            }
            return(currrentPlaceNumber + 1);
        }
Beispiel #2
0
        public void AddPlace(PlaceModel place)  // pass model with name,information,datestart,datefinish
        {
            int        newNum           = DatabaseAccess.AddNewPlaceToTrip(place, this.ID);
            PlaceModel toAddToTripModel = new PlaceModel
            {
                TripID      = this.ID,
                Number      = newNum,
                Name        = place.Name,
                Information = place.Information,
                DateStart   = place.DateStart,
                DateFinish  = place.DateFinish
            };

            this.placeList.Add(toAddToTripModel);

            Console.WriteLine($"Added place num: {newNum}");
        }