Пример #1
0
        //
        // GET: /Manage/Index
        public async Task <ActionResult> Index(ManageMessageId?message)
        {
            ViewBag.StatusMessage =
                message == ManageMessageId.ChangePasswordSuccess ? "Your password has been changed."
                : message == ManageMessageId.SetPasswordSuccess ? "Your password has been set."
                : message == ManageMessageId.SetTwoFactorSuccess ? "Your two-factor authentication provider has been set."
                : message == ManageMessageId.Error ? "An error has occurred."
                : message == ManageMessageId.AddPhoneSuccess ? "Your phone number was added."
                : message == ManageMessageId.RemovePhoneSuccess ? "Your phone number was removed."
                : "";

            var userId = User.Identity.GetUserId();
            var model  = new IndexViewModel
            {
                HasPassword       = HasPassword(),
                PhoneNumber       = await UserManager.GetPhoneNumberAsync(userId),
                TwoFactor         = await UserManager.GetTwoFactorEnabledAsync(userId),
                Logins            = await UserManager.GetLoginsAsync(userId),
                BrowserRemembered = await AuthenticationManager.TwoFactorBrowserRememberedAsync(userId)
            };
            var key = userId;

            var profilePic = S3Helper.GetFileObject(key);

            ViewBag.ProfilePicUrl     = !string.IsNullOrEmpty(profilePic) ? profilePic: "~/Content/img/user.png";    //imgProf;//"~/Content/img/user.jpg";
            ViewData["ProfilePicUrl"] = profilePic;
            return(View(model));
        }
        public string GetPhotos()
        {
            var userId   = User.Identity.GetUserId();
            var fileName = HttpContext.Server.MapPath(@"~/content/images/noprofile.png");

            if (userId != null)
            {
                if (User.Identity.IsAuthenticated)
                {
                    var bdUsers = HttpContext.GetOwinContext().Get <ApplicationDbContext>();
                    var user    = bdUsers.Users.Where(x => x.Id == userId).FirstOrDefault();

                    if (user != null && AppConfig.S3Enable)
                    {
                        var key = S3Helper.GetFileObject(user.ProfileKey);
                        return(key);
                    }
                }
            }
            return(fileName);
        }