public WorktaskViewModel GetWorkTaskViewModel(String worktaskID, String projectID, String timecardID) { if (!String.IsNullOrEmpty(worktaskID)) { //wenn es bereits ein WorkTaskViewMOdel gibt und dies auch noch dem entspricht, was gefordert ist, dann wird auch nur dies zurückgeliefert (Werte sind noch die alten) if (workTaskViewModel != null) { if (workTaskViewModel.WorktaskID == worktaskID) { return(workTaskViewModel); } } WorkTask newWorkTask = (WorkTask)getDBObjectForID(DBObjects.Worktask, worktaskID); if (newWorkTask == null) { if (timecardViewModel != null) { newWorkTask = new WorkTask() { WorkTaskID = worktaskID, DayDate = timecardViewModel.TimecardStartDate, Ident_WorkTask = HelperClass.GetIdentForWorktask(timecardViewModel.TimecardStartDate, ""), TimecardID = timecardViewModel.TimecardID, Timecard = (Timecard)getDBObjectForID(DBObjects.Timecard, timecardViewModel.TimecardID) } } ; else { Timecard tmpTimecard = getTimecardForDate(DateTime.Now); if (tmpTimecard != null) { timecardViewModel = new TimecardViewModel(tmpTimecard); } else { return(null); } newWorkTask = new WorkTask() { WorkTaskID = worktaskID, DayDate = DateTime.Now, Ident_WorkTask = HelperClass.GetIdentForWorktask(DateTime.Now, ""), Timecard = tmpTimecard, TimecardID = timecardViewModel.TimecardID }; } if (!String.IsNullOrEmpty(projectID)) { var projectFromColl = from Project project in ProjectCollection where project.ProjectID == projectID select project; if (projectFromColl.Count() == 1) { newWorkTask.Project = projectFromColl.Single(); } } } workTaskViewModel = new WorktaskViewModel(newWorkTask); } return(workTaskViewModel); }
public TimecardViewModel GetTimecardViewModel(String timecardID) { if (timecardViewModel != null) { if (timecardViewModel.TimecardID == timecardID) { return(timecardViewModel); } } Timecard newTimecard = (Timecard)getDBObjectForID(DBObjects.Timecard, timecardID); timecardViewModel = new TimecardViewModel(newTimecard); return(timecardViewModel); }
public void DiscardTimecardViewModel() { timecardViewModel = null; }