Example #1
0
        public async Task <IActionResult> ConfirmEmail(string userId, string code)
        {
            if (userId == null || code == null)
            {
                return(RedirectToAction(nameof(HomeController.Index), "Home"));
            }
            var user = await _userManager.FindByIdAsync(userId);

            if (user == null)
            {
                throw new ApplicationException($"Unable to load user with ID '{userId}'.");
            }
            var result = await _userManager.ConfirmEmailAsync(user, code);

            if (result.Succeeded)
            {
                await dbNavant.NavchRobs.AddAsync(new NavchRob { User = userId, PIB = user.PIB });

                await dbNavant.NaukRobs.AddAsync(new NaukRob { User = userId, PIB = user.PIB });

                await dbNavant.MetodRobs.AddAsync(new MetodRob { User = userId, PIB = user.PIB });

                await dbNavant.OrgRobs.AddAsync(new OrgRob { User = userId, PIB = user.PIB });

                await dbNavant.NormatKilkistBalivOrgRobs.AddAsync(new NormatKilkistBalivOrgRob { User = userId, PIB = user.PIB });

                dbNavant.SaveChanges();
                var RegCode = dbRegist.RegisterBufs.Where(buf => buf.PIB == user.PIB);
                dbRegist.RegisterBufs.RemoveRange(RegCode);
                dbRegist.SaveChanges();
            }
            return(View(result.Succeeded ? "ConfirmEmail" : "Error"));
        }
Example #2
0
        public async Task <IActionResult> Registration(RegistrationViewModel model)
        {
            if (ModelState.IsValid)
            {
                string guid = Guid.NewGuid().ToString("D");
                await dbRegist.RegisterBufs.AddAsync(new RegisterBuf { PIB = model.PIB, RegCode = guid });

                dbRegist.SaveChanges();
            }
            return(RedirectToAction("RegCode"));
        }