public void BtnAddVismaEntry() { // First it adds a new Vismaentry Viewmodel (and thereby its view) to the list where it contains what to show on the page. VismaEntries.Add(new VismaEntryViewModel(new VismaEntry(), this, TsConfirmationViewModel)); // Then it adds the the specific vismaentry to the list of vismaentries it contains on the timesheetentry instance itself. Tsentry.vismaEntries.Add(VismaEntries.Last().Entry); // And finally it adds a reference to the timesheetEntry the vismaEntry is on to the vismaEntry. VismaEntries.Last().Entry.TimesheetEntryID = Tsentry.Id; }
public TimesheetEntryConfirmationViewModel(TimesheetEntry entry, TimesheetConfirmationViewModel TsConfirmationViewModel) { this.TsConfirmationViewModel = TsConfirmationViewModel; TypeText = "Type: " + entry.SelectedTypeComboBoxItem; ProjectIdText = "Projekt-ID: " + entry.ProjectID; // To prevent the start and end times to contain seconds we restrict the substring to 5 symbols (2 for hours, 1 for the dot, and 2 for the minutes) StartTimeText = "Start: " + entry.StartTime.TimeOfDay.ToString().Substring(0, 5); EndTimeText = "S**t: " + entry.EndTime.TimeOfDay.ToString().Substring(0, 5); DrivingText = "Arbejdsplads: " + entry.SelectedRouteComboBoxItem; Tsentry = entry; foreach (VismaEntry visma in entry.vismaEntries) { VismaEntries.Add(new VismaEntryViewModel(visma, this, TsConfirmationViewModel)); } }
// This method is for the visma entries to call, so that they can remove themselves from the TimesheetEntry. public void RemoveEntry(VismaEntryViewModel entry) { VismaEntries.Remove(entry); }