protected override async Task OnInitializedAsync() { var result = await MemberDataService.GetAllMembers(); if (result != null && result.Payload != null && result.Payload.Any()) { foreach (var item in result.Payload) { members.Add(new FamilyMember() { avtar = item.Avatar, email = item.Email, firstname = item.FirstName, lastname = item.LastName, role = item.Roles, id = item.Id }); } } var tasks = await TaskDataService.GetAllTasks(); if (tasks != null && tasks.Payload != null && tasks.Payload.Any()) { foreach (var item in tasks.Payload) { allTasks.Add(new TaskModel() { text = item.text, isDone = item.isDone, memberId = item.memberId, id = item.id }); } } leftMenuItem = new MenuItem[members.Count]; leftMenuItem[0] = new MenuItem { label = "All Tasks", referenceId = Guid.Empty, isActive = true }; leftMenuItem[0].ClickCallback += showAllTasks; for (int i = 1; i < members.Count; i++) { leftMenuItem[i] = new MenuItem { iconColor = members[i - 1].avtar, label = members[i - 1].firstname, referenceId = members[i - 1].id, isActive = false }; leftMenuItem[i].ClickCallback += onItemClick; } showAllTasks(null, leftMenuItem[0]); isLoaded = true; SetFocus(); }
protected override async Task OnInitializedAsync() { try { var result = await MemberDataService.GetAllMembers(); if (result != null && result.Payload != null && result.Payload.Any()) { foreach (var item in result.Payload) { members.Add(new FamilyMember() { avtar = item.Avatar, email = item.Email, firstname = item.FirstName, lastname = item.LastName, role = item.Roles, id = item.Id }); selectedMemberId = members?.First()?.id.ToString(); } } var allTasksResult = await TasksDataService.GetAllTasks(); if (allTasksResult != null && allTasksResult.Payload != null && allTasksResult.Payload.Any()) { foreach (var item in allTasksResult.Payload) { allTasks.Add(new TaskModel() { text = item.Subject, isDone = item.IsComplete, member = members.Where(x => x.id == item.AssignedToId).FirstOrDefault(), id = item.Id }); allTasks[allTasks.FindIndex(ind => ind.id == item.Id)].ClickCallback += onTaskItemCompleted; allTasks[allTasks.FindIndex(ind => ind.id == item.Id)].ClickCallbackDelete += onTaskDelete; } } leftMenuItem = new MenuItem[members.Count + 1]; leftMenuItem[0] = new MenuItem { label = "All Tasks", referenceId = Guid.Empty, isActive = true }; leftMenuItem[0].ClickCallback += showAllTasks; for (int i = 1; i < members.Count + 1; i++) { leftMenuItem[i] = new MenuItem { iconColor = members[i - 1].avtar, label = members[i - 1].firstname, referenceId = members[i - 1].id, isActive = false }; leftMenuItem[i].ClickCallback += onItemClick; } showAllTasks(null, leftMenuItem[0]); isLoaded = true; } catch (Exception ex) { throw; } }