/// <summary> /// Parsed einen REST-Response in ein Job-Task-Model. /// </summary> /// <param name="jobTask">Der JobTask, der die Werte der Anfrage beinhaltet.</param> /// <returns>Ein JobTask-Objekt.</returns> public static JobTask Parse(JobTaskResponse jobTask) { var task = new JobTask { StartTime = jobTask.StartTime, EndTime = jobTask.EndTime, Creator = jobTask.Creator }; foreach (var component in jobTask.Components) { JobComponent com = null; switch (component.Type) { case ComponentType.TaskComponentText: com = new JobComponentText { TaskComponentId = component.Id ,Value = ((JobComponentResponseText)component).Value }; break; case ComponentType.TaskComponentInteger: com = new JobComponentInteger { TaskComponentId = component.Id, Value = ((JobComponentResponseInteger)component).Value }; break; case ComponentType.TaskComponentFloat: com = new JobComponentFloat { TaskComponentId = component.Id, Value = ((JobComponentResponseFloat)component).Value }; break; case ComponentType.TaskComponentDate: com = new JobComponentDate{ TaskComponentId = component.Id, Value = ((JobComponentResponseDate)component).Value }; break; } task.Components.Add(com); } return task; }
/// <summary> /// Erstellt und Füllt ein ViewModel mit den Werten des Job. /// </summary> /// <param name="component">Die TaskComponent, von der das ViewModel erstellt werden soll.</param> /// <param name="jobTask">Jobtask, das die Werte eines Jobs beinhaltet.</param> /// <returns>Das ViewModel für die übergebene TaskComponent.</returns> public static ComponentViewModelBase CreateAndFill(TaskComponent component, JobTask jobTask) { ComponentViewModelBase resultViewModel = CreateViewModel(component); if (jobTask != null) { var jobValue = jobTask.Components.Find(j => j.TaskComponentId == component.Id); if (jobValue != null) { resultViewModel.SetValues(jobValue); } } return resultViewModel; }