public EventForm(int id, ProfileEvent profileEvent) { InitializeComponent(); InitializeForm(FormMode.Edit); ProfileIdInput.Text = id.ToString(); ProfileEventIdInput.Text = profileEvent.Id.ToString(); TitleInput.Text = profileEvent.Title; DateInput.Text = profileEvent.Date; DescriptionInput.Text = profileEvent.Description; this.Title = "Edit Event"; }
// Update profile event public void UpdateProfileEvent(ProfileEvent profileEvent) { int index = currentProfile.ProfileEvents.FindLastIndex(p => p.Id == profileEvent.Id); if (index != -1) { currentProfile.ProfileEvents[index] = profileEvent; UpdateProfile(currentProfile); } RefreshProfileListing(); SetProfile(currentProfile); }
// Add profile event public void AddEvent(int Id, ProfileEvent profileEvent) { int index = ProfileList.FindLastIndex(p => p.Id == Id); if (index != -1) { profileEvent.Id = GetNextProfileEventId(); if (ProfileList[index].ProfileEvents == null) { ProfileList[index].ProfileEvents = new List <ProfileEvent>(); } ProfileList[index].ProfileEvents.Add(profileEvent); } UpdateProfile(ProfileList[index]); SetProfile(ProfileList[index]); }
private void ClickCreateButton(object sender, RoutedEventArgs e) { if (ValidateNewProfileEventForm()) { MainWindow main = (MainWindow)Application.Current.MainWindow; ProfileEvent profileEvent = new ProfileEvent(); profileEvent.Title = TitleInput.Text; profileEvent.Date = DateInput.Text; profileEvent.Description = DescriptionInput.Text; if (currentMode == FormMode.New) { main.AddEvent(int.Parse(ProfileIdInput.Text), profileEvent); } else { profileEvent.Id = int.Parse(ProfileEventIdInput.Text); main.UpdateProfileEvent(profileEvent); } this.Close(); } }