예제 #1
0
        public async Task <IActionResult> DeleteConfirmed(int id)
        {
            var country = await _context.Countries.SingleOrDefaultAsync(m => m.Id == id);

            _context.Countries.Remove(country);

            UserFile.DeleteOldImage(_environment.WebRootPath, Properties.Resources.CountryFlagFolder, country.Flag);

            await _context.SaveChangesAsync();

            return(RedirectToAction("Index"));
        }
예제 #2
0
        public async Task <IActionResult> DeleteConfirmed(int id)
        {
            var badge = await _context.Badges.SingleOrDefaultAsync(m => m.Id == id);

            _context.Badges.Remove(badge);

            UserFile.DeleteOldImage(_environment.WebRootPath, Properties.Resources.BadgeLogoFolder, badge.BadgeLogo);

            await _context.SaveChangesAsync();

            return(RedirectToAction("Index"));
        }
예제 #3
0
        public async Task <IActionResult> DeleteConfirmed(int id)
        {
            var publication = await _context.Publications.SingleOrDefaultAsync(m => m.Id == id && m.ApplicationUserId == _userManager.GetUserId(User));

            _context.Publications.Remove(publication);

            UserFile.DeleteOldImage(_environment.WebRootPath, Properties.Resources.PublicationFiles, publication.FileLink);

            await _context.SaveChangesAsync();

            return(RedirectToAction(nameof(Index)));
        }
예제 #4
0
        public async Task <IActionResult> DeleteConfirmed(int id)
        {
            var academicActivity = await _context.AcademicActivities.SingleOrDefaultAsync(m => m.Id == id && m.ApplicationUserId == _userManager.GetUserId(User));

            _context.AcademicActivities.Remove(academicActivity);

            UserFile.DeleteOldImage(_environment.WebRootPath, Properties.Resources.ActivityPhotos, academicActivity.Photo);

            await _context.SaveChangesAsync();

            return(RedirectToAction(nameof(Index)));
        }
예제 #5
0
        public async Task <IActionResult> RemoveLogin(RemoveLoginViewModel model)
        {
            var user = await _userManager.GetUserAsync(User);

            if (user == null)
            {
                throw new ApplicationException($"Unable to load user with ID '{_userManager.GetUserId(User)}'.");
            }

            var result = await _userManager.RemoveLoginAsync(user, model.LoginProvider, model.ProviderKey);

            if (!result.Succeeded)
            {
                throw new ApplicationException($"Unexpected error occurred removing external login for user with ID '{user.Id}'.");
            }

            await _signInManager.SignInAsync(user, isPersistent : false);

            UserFile.DeleteOldImage(_environment.WebRootPath, Properties.Resources.ProfileImageFolder, user.ProfileImage);

            StatusMessage = "The external login was removed.";
            return(RedirectToAction(nameof(ExternalLogins)));
        }