Пример #1
0
        public async Task <IActionResult> RegisterAsync(VoterRegistrationViewModel model)
        {
            if (ModelState.IsValid)
            {
                string userId = _UserManager.GetUserId(User);
                VoterRegistrationDataModel registration = await _Context.Registration.FindAsync(userId);

                if (registration == null)
                {
                    registration = new VoterRegistrationDataModel(userId, model);

                    _Context.Registration.Add(registration);
                }
                else
                {
                    registration.Update(model);

                    _Context.Registration.Update(registration);
                }

                await _Context.SaveChangesAsync();

                return(RedirectToAction(nameof(Dashboard)));
            }

            return(View("Register", model));
        }
Пример #2
0
        public IActionResult Register()
        {
            VoterRegistrationDataModel data  = _Context.Registration.Find(_UserManager.GetUserId(User));
            VoterRegistrationViewModel model = new VoterRegistrationViewModel(data);

            return(View(model));
        }
Пример #3
0
 public void Update(VoterRegistrationViewModel model)
 {
     FirstName      = model.FirstName;
     LastName       = model.LastName;
     DOB            = model.DOB;
     Identification = model.Identification;
     SSNumber       = model.SSNumber;
 }
Пример #4
0
 public VoterRegistrationDataModel(string userId, VoterRegistrationViewModel model)
 {
     UserId         = userId;
     FirstName      = model.FirstName;
     LastName       = model.LastName;
     DOB            = model.DOB;
     Identification = model.Identification;
     SSNumber       = model.SSNumber;
 }