public void DeletePicture(Picture picture)
        {
            var existing = db.pictures.Single(x => x.Id == picture.Id);

            if (existing != null)
            {
                db.pictures.DeleteOnSubmit(existing);
                db.SubmitChanges();
            }
        }
        public void UpdatePicture(Picture picture)
        {
            Picture pictureToUpdate = db.pictures.Where(x => x.Id == picture.Id).First();

            pictureToUpdate.Id = picture.Id;
            pictureToUpdate.PictureData = picture.PictureData;
            pictureToUpdate.PointOfInterest = picture.PointOfInterest;
            pictureToUpdate.Description = picture.Description;

            try
            {
                db.SubmitChanges();
            }
            catch (Exception e)
            {
                Console.WriteLine("Error while trying to save a picture : " + e);
            }
        }
        public void DeletePicture(Picture picture)
        {
            DataServicePicture dsPicture = new DataServicePicture();
            Trip.Pictures.Remove(picture);
            dsPicture.DeletePicture(picture);

            TripCommand.Execute(null);
        }
 public void addPicture(Picture newPicture)
 {
     db.pictures.InsertOnSubmit(newPicture);
     db.SubmitChanges();
 }
        private void Init(int trip, int photo, PointOfInterest poi, Mode mode)
        {
            this.Mode = mode;

            if (this.Mode == ViewModels.Mode.add)
            {
                Picture = new Picture();
                DataServiceTrip dsTrip = new DataServiceTrip();
                Picture.Trip = dsTrip.getTripById(trip);
                Picture.Date = DateTime.Now;
                if (poi != null)
                    POISelected = poi;
            }
            else
            {
                Picture = GetPictureInDB(photo);
            }

            if (Picture.Trip.PointsOfInterests != null)
                PoiList = new List<PointOfInterest>(Picture.Trip.PointsOfInterests);

            EditableObject = new Caretaker<Picture>(this.Picture);
            EditableObject.BeginEdit();

            InitialiseValidator();
        }