Esempio n. 1
0
        private JsonResult GetTaskSchedule(List <int> userIds, int taskId)
        {
            var resourceList = new List <JsonEmployeeTask>();
            var taskList     = new List <JsonEmployeeTask>();

            foreach (var userId in userIds)
            {
                var userSearchmodel = new UserSearchModel {
                    Id = userId, TaskId = taskId, PageSize = 10, SortColumn = "Id"
                };
                userSearchmodel = _employeeFacadeApiClient.GetUsersWithTasks(userSearchmodel).Result;
                var tasks     = userSearchmodel.UserSearchResult.SelectMany(x => x.Tasks).ToList();
                var resources = (from contact in userSearchmodel.UserSearchResult
                                 select new JsonEmployeeTask
                {
                    id = contact.Id,
                    title = contact.Name,
                    className = contact.Tasks.FirstOrDefault()?.TaskTypeId != 5 ? contact.Tasks.FirstOrDefault()?.TaskType.CssClass : contact.Tasks.FirstOrDefault()?.Task?.TaskCss?.ToLower()
                }).ToList();
                resourceList.AddRange(resources);
                var userTasks = tasks.Select(task => new JsonEmployeeTask
                {
                    id         = task.Id,
                    resourceId = task.UserId,
                    start      = task.ScheduleStartTime.ToString("s"),
                    end        = task.ScheduleEndTime.ToString("s"),
                    title      = task.TaskTypeId != 5 ? task.TaskType.Name : task.Description,
                    name       = task.TaskTypeId != 5 ? task.TaskType.Name : task.Task.Name,
                    styleName  = task.TaskTypeId != 5 ? task.TaskType.CssStyle : task.Task?.TaskStyle,
                    className  = task.TaskTypeId != 5 ? task.TaskType.CssClass : task.Task?.TaskCss.ToString().ToLower()
                })
                                .ToList();

                taskList.AddRange(userTasks);
            }
            return(Json(new { contacts = resourceList, tasks = taskList }));
        }