Esempio n. 1
0
        void IPhotoRepository.AddOrUpdatePhoto(Photo photo)
        {
            var original = _db.Photos.SingleOrDefault(p => p.PhotoID == photo.PhotoID);

            if (original == null)
                _db.Photos.Add(photo);
            else
                _db.Entry(original).CurrentValues.SetValues(photo);
        }
Esempio n. 2
0
 void IPhotoRepository.DeletePhoto(int id)
 {
     var p = new Photo { PhotoID = id };
     _db.Photos.Attach(p);
     _db.Entry(p).State = System.Data.EntityState.Deleted;
 }