public int SaveResume(Resumes resume) { try { // add/update indent var count = this.Resumes.Count(a => a.CandidateID.Equals(resume.CandidateID)); if (count == 0) { Resumes.Add(resume); } else { Resumes u = this.Resumes.Where(s => s.CandidateID == resume.CandidateID).FirstOrDefault <Resumes>(); // change contact in disconnected mode (out of DBContext scope) if (u != null) { u.CandidateID = resume.CandidateID; u.CandidatePhoto = resume.CandidatePhoto; u.FileType = resume.FileType; u.ResumePath = resume.ResumePath; } this.Entry(u).State = EntityState.Modified; } this.SaveChanges(); return(resume.CandidateID); } catch { throw; } }
private async void Open_Import(object sender, RoutedEventArgs e) { FileOpenPicker openPicker = new FileOpenPicker() { ViewMode = PickerViewMode.Thumbnail, SuggestedStartLocation = PickerLocationId.DocumentsLibrary }; openPicker.FileTypeFilter.Add(".cv"); var ImportCV = await openPicker.PickSingleFileAsync(); if (ImportCV != null) { StorageFolder folder = await FileManagement.GetLocalResumeFolder(); await ImportCV.CopyAsync(folder, ImportCV.Name, NameCollisionOption.ReplaceExisting); var cv = await FileManagement.Read_file(Path.GetFileNameWithoutExtension(ImportCV.Name), folder); bool exist = false; foreach (Resume.Resume r in Resumes) { if (r.Name == cv.Name) { Resumes.Remove(r); Resumes.Insert(0, cv); exist = true; break; } } if (!exist) { Resumes.Add(cv); } } Window.Current.Content = new StartPage(); }