public WorkerBO Convert(WorkerViewModel worker) { if (worker != null) { var workerBo = new WorkerBO { Id = worker.Id, Name = worker.Name, Surname = worker.Surname, MiddleName = worker.MiddleName, Position = worker.Position, Tasks = null }; if (worker.Tasks != null) { var tempTasks = new List <TaskBO>(); foreach (var taskView in worker.Tasks) { var taskViewToBoConverter = new TaskViewConverter(); var task = taskViewToBoConverter.Convert(taskView); task.Workers = null; task.Project = null; tempTasks.Add(task); } workerBo.Tasks = tempTasks; } return(workerBo); } return(null); }
public ProjectBO Convert(ProjectViewModel _project) { if (_project != null) { var project = new ProjectBO { Id = _project.Id, Name = _project.Name, Shortname = _project.Shortname, Description = _project.Description, Status = _project.Status, CreationDate = _project.CreationDate, Tasks = null }; if (_project.Tasks != null) { var taskViewToBoConverter = new TaskViewConverter(); var tempTasks = new List <TaskBO>(); foreach (var task in _project.Tasks) { var _task = taskViewToBoConverter.Convert(task); _task.Project = null; _task.Workers = null; tempTasks.Add(_task); } project.Tasks = tempTasks; } return(project); } return(null); }