public async Task <IActionResult> UserUpdate()
        {
            var user = await _userManager.GetUserAsync(User);

            ViewBag.isAdmin = User.IsInRole("Admin");

            UserProfileListDto userProfileModel = _accountService.GetUserProfile(user.Id);

            userProfileModel.Cities = _cityService.GetCities();

            return(View(userProfileModel));
        }
Esempio n. 2
0
        public UserProfileListDto GetUserProfile(string id, string profileStatus)
        {
            UserProfileListDto userProfile = _accountDal.GetUserProfile(id).FirstOrDefault();

            //DURUM KONTROLÜ
            if (profileStatus != null)
            {
                userProfile.ProfileStatus = profileStatus;
            }

            return(userProfile);
        }
        public GenericResponseResult <UserProfileListDto> Get(Boolean refreshRoles = true)
        {
            //maybe if the number of profiles gets too big, we should lazy-fetch them, in a way to retrieve less data to the list screen
            var          profiles = SecurityFacade.FetchAllProfiles(true);
            IList <Role> roles    = new List <Role>();

            if (refreshRoles)
            {
                roles = new SWDBHibernateDAO().FindByQuery <Role>("from Role order by name");
            }
            var dto = new UserProfileListDto {
                Profiles = profiles, Roles = roles
            };

            return(new GenericResponseResult <UserProfileListDto>(dto));
        }
        public async Task <IActionResult> Profile(string UserID)
        {
            string profileStatus = string.Empty;

            if (TempData["ProfileStatus"] != null)

            {
                profileStatus = TempData["ProfileStatus"].ToString();
            }



            var user = await _userManager.GetUserAsync(User);

            ViewBag.isAdmin = User.IsInRole("Admin");
            UserProfileListDto userprofile = _accountService.GetUserProfile(user.Id, profileStatus);


            return(View(userprofile));
        }
        public async Task <IActionResult> UserUpdate(UserProfileListDto userProfileListModel)
        {
            if (!ModelState.IsValid)
            {
                return(RedirectToAction("UserUpdate"));
            }

            var user = await _userManager.GetUserAsync(User);

            user.Name        = userProfileListModel.Name;
            user.Lastname    = userProfileListModel.Lastname;
            user.PhoneNumber = userProfileListModel.PhoneNumber;
            user.CityID      = userProfileListModel.CityID;
            user.Gender      = (int)userProfileListModel.Gender;
            user.Address     = userProfileListModel.Address;
            user.BirthDay    = userProfileListModel.BirthDay;

            var result = await _userManager.UpdateAsync(user);

            if (!result.Succeeded)
            {
                foreach (IdentityError error in result.Errors)
                {
                    ModelState.AddModelError(string.Empty, error.Description);
                }

                return(RedirectToAction("UserUpdate"));
            }

            //SUCCEEDED

            await _userManager.UpdateSecurityStampAsync(user);

            await _signInManager.SignOutAsync();

            await _signInManager.SignInAsync(user, true);

            TempData["ProfileStatus"] = "ProfileUpdated";
            return(RedirectToAction("Profile"));
        }