Beispiel #1
0
        public async Task <IActionResult> ChangeEducationalInformation()
        {
            var user = await GetCurrentUserAsync();

            if (user == null)
            {
                return(View("Error"));
            }

            var model = new ChangeEducationalInformationViewModel
            {
                StudentNumber  = user.StudentNumber.ToString(),
                StartdateStudy = user.StartdateStudy,
                StudyType      = user.StudyType
            };

            return(View(model));
        }
Beispiel #2
0
        public async Task <IActionResult> ChangeEducationalInformation(ChangeEducationalInformationViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }
            var user = await GetCurrentUserAsync();

            if (user != null)
            {
                // Overwrites values in currently logged in user to match the new data
                user.StartdateStudy = model.StartdateStudy;
                user.StudyType      = model.StudyType;

                // Saves changes
                _context.Update(user);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index), new { Message = ManageMessageId.ChangeEducationalInformationSuccess }));
            }
            return(RedirectToAction(nameof(Index), new { Message = ManageMessageId.Error }));
        }