Esempio n. 1
0
        public WorkerViewModel Convert(WorkerBO _worker)
        {
            if (_worker != null)
            {
                var worker = new WorkerViewModel
                {
                    Id         = _worker.Id,
                    Name       = _worker.Name,
                    Surname    = _worker.Surname,
                    MiddleName = _worker.MiddleName,
                    Position   = _worker.Position,
                    Tasks      = null
                };


                if (_worker.Tasks != null)
                {
                    var taskBoToViewConverter = new TaskBOConverter();
                    var tempTasks             = new List <TaskViewModel>();

                    foreach (var task in _worker.Tasks)
                    {
                        var _task = taskBoToViewConverter.Convert(task);
                        _task.Project   = null;
                        _task.Executors = null;
                        tempTasks.Add(_task);
                    }
                    worker.Tasks = tempTasks;
                }

                return(worker);
            }

            return(null);
        }
        public ProjectViewModel Convert(ProjectBO projectBo)
        {
            if (projectBo != null)
            {
                var project = new ProjectViewModel
                {
                    Id           = projectBo.Id,
                    Name         = projectBo.Name,
                    Shortname    = projectBo.Shortname,
                    Description  = projectBo.Description,
                    Status       = projectBo.Status,
                    CreationDate = projectBo.CreationDate,
                    Tasks        = null
                };

                if (projectBo.Tasks != null)
                {
                    var taskBoToViewConverter = new TaskBOConverter();
                    var tempTasks             = new List <TaskViewModel>();

                    foreach (var taskBo in projectBo.Tasks)
                    {
                        var task = taskBoToViewConverter.Convert(taskBo);
                        task.Project   = null;
                        task.Executors = null;
                        tempTasks.Add(task);
                    }
                    project.Tasks = tempTasks;
                }

                return(project);
            }

            return(null);
        }