public IViewComponentResult Invoke(int userId) { int workspaceId = Convert.ToInt32(HttpContext.Session.GetString("WorkspaceId")); HomeModel model = new HomeModel(); model.Workspaces = _workspaceService.GetAll(userId); model.Workspace = _workspaceService.Get(workspaceId); return(View(model)); }
public IActionResult CreateCategory(string categoryName) { var userId = GetUserID(); int workspaceId = Convert.ToInt32(HttpContext.Session.GetString("WorkspaceId")); var workspace = _workspaceService.GetAll(userId).FirstOrDefault(x => x.Id == workspaceId); if (workspace != null) { Category category = new Category(); category.Name = categoryName; category.WorkspaceId = workspace.Id; category.UserId = userId; _categoryService.Add(category); } //return RedirectToAction("Index", "Home", new { id = workspace.Id }); return(Json(Url.Action("Index", "Home", new { id = workspace.Id }))); }