コード例 #1
0
ファイル: HomeController.cs プロジェクト: cnrsahin/recipes
        public async Task <IActionResult> Index()
        {
            int waitConfirmRecipeCount = await _recipeRepository.CountAsync(r => !r.IsConfirmed && !r.IsDeleted);

            int waitConfirmFoodCategoryCount = await _foodCategoryRepository.CountAsync(f => !f.IsConfirmed && !f.IsDeleted);

            int waitConfirmCommentCount = await _commentRepository.CountAsync(c => !c.IsConfirmed && !c.IsDeleted);

            int notConfirmedAndDeletedRecipeCount = await _recipeRepository.CountAsync(r => r.IsDeleted && !r.IsConfirmed);

            int notConfirmedAndDeletedFoodCategoryCount = await _foodCategoryRepository.CountAsync(f => f.IsDeleted && !f.IsConfirmed);

            int notConfirmedAndDeletedCommentCount = await _commentRepository.CountAsync(c => c.IsDeleted && !c.IsConfirmed);

            var model = new HomeIndexViewModel
            {
                WaitConfirmRecipeCount       = waitConfirmRecipeCount,
                WaitConfirmFoodCategoryCount = waitConfirmFoodCategoryCount,
                WaitConfirmCommentCount      = waitConfirmCommentCount,

                NotConfirmedAndDeletedRecipeCount       = notConfirmedAndDeletedRecipeCount,
                NotConfirmedAndDeletedFoodCategoryCount = notConfirmedAndDeletedFoodCategoryCount,
                NotConfirmedAndDeletedCommentCount      = notConfirmedAndDeletedCommentCount
            };

            return(View(model));
        }
コード例 #2
0
        public async Task <IViewComponentResult> InvokeAsync()
        {
            var user = await _userManager.GetUserAsync(HttpContext.User);

            var roles = await _userManager.GetRolesAsync(user);

            if (user == null || roles == null)
            {
                return(Content("Kullanıcı veya Yetki Hatası"));
            }

            int deletedRecipeCount = await _recipeRepository.CountAsync(x => x.IsDeleted && x.IsConfirmed);

            int deletedFoodCategoryCount = await _foodCategoryRepository.CountAsync(x => x.IsDeleted && x.IsConfirmed);

            int deletedCommentCount = await _commentRepository.CountAsync(x => x.IsDeleted && x.IsConfirmed);

            int recipeCount = await _recipeRepository.CountAsync(c => !c.IsDeleted && c.IsConfirmed);

            int foodCategoryCount = await _foodCategoryRepository.CountAsync(c => !c.IsDeleted && c.IsConfirmed);

            int commentCount = await _commentRepository.CountAsync(c => !c.IsDeleted && c.IsConfirmed);

            int userCount = _userManager.Users.Count();
            int roleCount = _roleManager.Roles.Count();

            return(View(new RightSideBarViewModel
            {
                Roles = roles,
                User = user,
                RecipeDeletedCount = deletedRecipeCount,
                FoodCategoryDeletedCount = deletedFoodCategoryCount,
                CommentDeletedCount = deletedCommentCount,

                RecipeCount = recipeCount,
                FoodCategoryCount = foodCategoryCount,
                CommentCount = commentCount,

                UserCount = userCount,
                RoleCount = roleCount
            }));
        }