public ActionResult SubCategoryStep(
            TaskSubCategory taskSubCategory,
            string taskCategory)
        {
            var subCategories = this.GetTasks()
                                .First(x => x.Title == taskCategory)
                                .SubCategories;

            var tasks = subCategories
                        .First(x => x.Title == taskSubCategory.Title)
                        .Tasks;

            return(PartialView("TaskStep", new TaskViewModel()
            {
                Tasks = tasks,
                TaskCategory = taskCategory,
                TaskSubCategory = taskSubCategory.Title
            }));
        }
Ejemplo n.º 2
0
        public static IList <TaskCategory> CreateRepairTasks(string pathToTasks)
        {
            var extendedTasks = GetRepairTasks(pathToTasks);

            var categories = extendedTasks.Select(x => x.Category).Distinct();

            var fullList = new List <TaskCategory>();

            // Category level
            foreach (var category in categories)
            {
                var taskCategory = new TaskCategory
                {
                    Title = category,
                    Notes = extendedTasks.FirstOrDefault(x => x.Category == category)?.CategoryTip
                };

                fullList.Add(taskCategory);

                var tasksForCategory = extendedTasks.Where(x => x.Category == category).ToList();
                var repairAreas      = tasksForCategory.Select(x => x.RepairArea).Distinct();

                // SubCategory level
                foreach (var repairArea in repairAreas)
                {
                    var taskSubCat = new TaskSubCategory
                    {
                        Title = repairArea,
                        Notes = extendedTasks.FirstOrDefault(x => x.RepairArea == repairArea)?.RepairAreaTip
                    };
                    taskCategory.SubCategories.Add(taskSubCat);

                    var webTasksForSubCategory = tasksForCategory.Where(x => x.RepairArea == repairArea).ToList();

                    var tasks = webTasksForSubCategory.Select(x => x.Item).Distinct();

                    // Item level
                    foreach (var task in tasks)
                    {
                        var webTasks = webTasksForSubCategory.Where(x => x.Item == task);

                        foreach (var webTask in webTasks)
                        {
                            var config   = new ConfigurationOptions();
                            var taskTask = new Task
                            {
                                TaskDescription = task,
                                TaskCode        = webTask.Code,
                                StanhopeMapping = webTask.StanhopePFI,
                                HelpTip         = webTask.ItemTip
                            };
                            config.GeneralNeeds    = webTask.TenureRented;
                            config.Shared          = webTask.TenureSharedOwner;
                            config.Sheltered       = webTask.TenureSupported;
                            config.IsCommunal      = webTask.Communal;
                            config.IsUnit          = webTask.Unit;
                            config.Priority        = webTask.Priority.Trim();
                            taskTask.Configuration = config;
                            taskSubCat.Tasks.Add(taskTask);
                        }
                    }
                }
            }

            return(fullList);
        }