Example #1
0
        public async Task <IActionResult> SetInfo(SetInfoViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            var user = await _userManager.GetUserAsync(User);

            if (user == null)
            {
                model.StatusMessage = "Failed to set: User instance not found!";
                return(View(model));
            }

            if (model.Description.Length < 1000)
            {
                user.description = model.Description;
            }
            else
            {
                model.StatusMessage = "Error: The entered description is over 1000 characters!";
                return(View(model));
            }

            await _userManager.UpdateAsync(user);

            return(RedirectToAction(nameof(SetInfo)));
        }
Example #2
0
        public async Task <IActionResult> SetInfo()
        {
            User webuser = await _userManager.GetUserAsync(User);

            if (webuser == null)
            {
                return(RedirectToAction(nameof(Info)));
            }

            SetInfoViewModel model = new SetInfoViewModel()
            {
                Description = webuser.description,
                userManager = _userManager
            };

            return(View(model));
        }