private async Task <WidgetDialogViewModel> GetWidgetDialogViewModelAsync() { var widgets = await _service.GetWidgetsForAsync(); widgets.ForEach(widget => { widget.GroupName = string.IsNullOrEmpty(widget.GroupName) ? "General" : widget.GroupName; }); var result = new WidgetDialogViewModel { Groups = widgets.Select(y => y.GroupName).Distinct().ToList(), Widgets = new List <Widget>(widgets) }; return(result); }
private async Task <WidgetDialogViewModel> GetWidgetDialogViewModelAsync() { // Get the PlanId for the user (WidgetPlan <-> Plan) // to retrieve specific widgets for a user based on a plan. // Integrate the PlanId into the IdentityUser as an extra property. // var planId = 1 (default is 0). var widgets = await _service.GetWidgetsForAsync(); widgets.ForEach(widget => { widget.GroupName = string.IsNullOrEmpty(widget.GroupName) ? "General" : widget.GroupName; }); var result = new WidgetDialogViewModel { Groups = widgets.Select(y => y.GroupName).Distinct().ToList(), Widgets = new List <Widget>(widgets) }; return(result); }
public IViewComponentResult Invoke(WidgetDialogViewModel dialog) { return(View(dialog)); }