Exemplo n.º 1
0
        // GET: /Manage/SetInformation
        public async Task <ActionResult> SetInformation()
        {
            var currentUser = await UserManager.FindByIdAsync(User.Identity.GetUserId());

            var relationshipStatus = DbContext.RelationshipStatus.ToList();

            var viewModel = new SetInformationViewModel
            {
                Firstname            = currentUser.Firstname,
                Lastname             = currentUser.Lastname,
                Work                 = currentUser.Work,
                Study                = currentUser.Study,
                BirthDate            = currentUser.BirthDate,
                RelationshipStatus   = relationshipStatus,
                RelationshipStatusId = currentUser.RelationshipStatusId,
                IsHiddenFromSearch   = currentUser.IsHiddenFromSearch
            };

            return(View(viewModel));
        }
Exemplo n.º 2
0
        public async Task <ActionResult> SetInformation(SetInformationViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            var currentUser = await UserManager.FindByIdAsync(User.Identity.GetUserId());

            currentUser.Firstname            = model.Firstname;
            currentUser.Lastname             = model.Lastname;
            currentUser.Work                 = model.Work;
            currentUser.Study                = model.Study;
            currentUser.BirthDate            = model.BirthDate;
            currentUser.RelationshipStatusId = model.RelationshipStatusId;
            currentUser.IsHiddenFromSearch   = model.IsHiddenFromSearch;

            await UserManager.UpdateAsync(currentUser);

            return(RedirectToAction("SetInformation"));
        }