public IViewComponentResult Invoke(int userId)
        {
            HomeModel model       = new HomeModel();
            int       workspaceId = Convert.ToInt32(HttpContext.Session.GetString("WorkspaceId"));

            if (workspaceId != 0)
            {
                model.Categories = _workspaceService.GetAllCategory(workspaceId, userId);
                model.Notes      = _workspaceService.GetAllNote(model.Categories);
                model.Workspace  = _workspaceService.Get(workspaceId);
                return(View(model));
            }
            else
            {
                return(View(model));
            }
        }
Пример #2
0
        public IActionResult RemoveWorkspace(int workspaceId)
        {
            int userId    = GetUserID();
            var workspace = _workspaceService.GetAllDeleted(userId).FirstOrDefault(x => x.Id == workspaceId);

            if (workspace.IsDeleted == true)
            {
                var categories = _workspaceService.GetAllCategory(workspace.Id, userId);
                var notes      = _workspaceService.GetAllNote(categories);
                foreach (var item in notes)
                {
                    _noteService.Remove(item.Id);
                }
                foreach (var x in categories)
                {
                    _categoryService.Remove(x.Id);
                }
                bool isOK = _workspaceService.Remove(workspace.Id);
            }
            return(Json(Url.Action("DeletedWorkspaces", "Home")));
        }