public void AddPhotoItem(PhotoItem photo) { if (!checkIfPhotoExists(photo)) { photoList.Add(photo); OnPropertyChanged(); } }
private bool checkIfPhotoExists(PhotoItem photo) { bool found = false; foreach (PhotoItem listItem in photoList) { string listItemPath = (listItem.FilePath + "//" + listItem.FileName + listItem.FileExt).ToLower(); string photoPath = (photo.FilePath + "//" + listItem.FileName + listItem.FileExt).ToLower(); if (listItemPath.Equals(photoPath) == true) { found = true; //throw new Exception("exists"); break; } } return(found); }