Example #1
0
        public ActionResult AdminDetails(Guid?userId)
        {
            if (userId == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            AdminDetailsViewModel model = new AdminDetailsViewModel();
            var usr = _userManager.Find(x => x.Id == userId);

            if (usr == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            else
            {
                var roleId   = _roleManager.GetAdminRoleId();
                var userRole = _userRoleManager.Find(x => x.AppUserId == userId && x.AppRoleId == roleId);

                if (userRole == null)
                {
                    return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
                }
                else
                {
                    model.Admin = usr;

                    model.Blogs      = _blogManager.ListQueryable().Where(x => x.AppUserId == userId).ToList();
                    model.Comments   = _commentManager.ListQueryable().Where(x => x.AppUserId == userId).ToList();
                    model.LastVisits = _visitManager.ListQueryable().Where(x => x.AppUserId == userId).ToList();
                    model.Likes      = _likeManager.ListQueryable().Where(x => x.AppUserId == userId).ToList();
                    model.Logs       = _logManager.ListQueryable().Where(x => x.Username == usr.Username).ToList();
                    model.UserRoles  = _userRoleManager.ListQueryable().Where(x => x.AppUserId == userId).ToList();

                    return(View(model));
                }
            }
        }