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); }
void IPhotoRepository.DeletePhoto(int id) { var p = new Photo { PhotoID = id }; _db.Photos.Attach(p); _db.Entry(p).State = System.Data.EntityState.Deleted; }