Exemple #1
0
        public ActionResult Index(string templateGuid)
        {
            var template     = m_dbAdapter.Template.GetTemplate(templateGuid);
            var templateTask = m_dbAdapter.Template.GetTemplateTasks(template.TemplateId);

            var viewModel = new EditTemplateTaskViewModel();

            viewModel.TemplateGuid  = templateGuid;
            viewModel.TemplateName  = template.TemplateName;
            viewModel.TemplateTasks = new List <TaskTemplateViewModel>();

            Dictionary <int, int> idMap = new Dictionary <int, int>();

            for (int i = 0; i < templateTask.Count; i++)
            {
                var task     = templateTask[i];
                var taskView = Toolkit.ConvertTemplateTask(task);
                taskView.RowSequence       = i + 1;
                idMap[task.TemplateTaskId] = taskView.RowSequence;
                viewModel.TemplateTasks.Add(taskView);
            }

            if (viewModel.TemplateTasks != null)
            {
                foreach (var task in viewModel.TemplateTasks)
                {
                    task.PrevTaskNames = Toolkit.ToString(CommUtils.Join(
                                                              task.PrevTaskIds.ConvertAll(x => idMap[x].ToString())));
                }
            }

            var templateTimes = m_dbAdapter.Template.GetTemplateTimeLists(templateGuid);

            viewModel.TemplateTimes = templateTimes.ConvertAll(Toolkit.ConvertTemplateTime);

            return(View("../DesignTemplate/EditTemplateTask", viewModel));
        }