Example #1
0
        public async Task <IActionResult> DeleteAccount(string id)//Confirmation
        {
            var user = await _userManager.FindByIdAsync(id);

            if (user == null)
            {
                ViewBag.ErrorMessage = $"user with Id = {id} cannot be found";
                return(View("PageNotFound"));
            }
            else
            {
                var items  = _achievementRepo.ReadAll(_userInfoRepo.Read(id).UserInformationId);
                var result = await _userManager.DeleteAsync(user);

                if (result.Succeeded)
                {
                    FileProcessing.DeleteAvatarImage(user.UserName, _config, _webHostEnvironment);

                    foreach (var item in items)
                    {
                        FileProcessing.DeleteAllGalleryImages(user.UserName, item, _config, _webHostEnvironment);
                    }

                    await _signInManager.SignOutAsync();

                    return(RedirectToAction("Index", "Home"));
                }

                foreach (var error in result.Errors)
                {
                    ModelState.AddModelError("", error.Description);
                }

                return(RedirectToAction("Index", "Home"));
            }
        }
Example #2
0
        public IActionResult UserResume(string id)
        {
            var userInfo = _userInfoRepo.Read(id);

            if (userInfo == null)
            {
                Response.StatusCode  = 404;
                ViewBag.ErrorTitle   = "Can't find User";
                ViewBag.ErrorMessage = "The id did not match with any users in our data base";
                return(View("PageNotFound"));
            }

            var userID       = _userManager.GetUserId(User);
            var allUserItems = _achievementRepo.ReadAll(userInfo.UserInformationId);

            var model = new UserResumeViewModel
            {
                AppUserId         = userID,
                UserInfo          = userInfo,
                Achievements      = allUserItems,
                NewSkillViewModel = new SkillViewModel()
            };

            if (userID == id)
            {
                model.EnableOwnerOptions = true;
            }
            else
            {
                model.EnableOwnerOptions = false;
            }

            model.DefaultAvatarImage  = _config.GetValue <string>("FileUploadSettings:DefaultAvatarImgFilePath");
            model.DefaultGalleryImage = _config.GetValue <string>("FileUploadSettings:DefaultGalleryImgFilePath");

            return(View(model));
        }