Beispiel #1
0
        public async Task <IActionResult> Register(string userName, string password, string name, string lastName)
        {
            var user = new ApplicationUser
            {
                Name     = name,
                Access   = "Customer",
                LastName = lastName,
                UserName = userName,
            };

            var result = await userManager.CreateAsync(user, password);

            if (result.Succeeded)
            {
                user = await userManager.FindByNameAsync(user.UserName);

                await authDbContext.AddRangeAsync();

                await authDbContext.SaveChangesAsync();

                var cusInfo = new cusInfo
                {
                    AppUserID = user.Id,
                };

                await authDbContext.AddAsync(cusInfo);

                await authDbContext.SaveChangesAsync();
            }

            return(RedirectToAction("Index", "Customer", new { area = "" }));
        }
Beispiel #2
0
        public async Task AddManyAsync(IList <TEntity> entities)
        {
            ArgumentGuard.NotNullOrEmpty(entities, nameof(entities));

            await _dbContext.AddRangeAsync(entities);

            await _dbContext.SaveChangesAsync();
        }
        public async Task <IActionResult> Register(string userName, string password, string name, string homeAddress)
        {
            var user = new ApplicationUser
            {
                Name        = name,
                Access      = "Student",
                HomeAddress = homeAddress,
                UserName    = userName,
            };

            var result = await userManager.CreateAsync(user, password);

            if (result.Succeeded)
            {
                user = await userManager.FindByNameAsync(user.UserName);

                var prelim   = InitializeGrades("Prelim");
                var midterm  = InitializeGrades("Midterm");
                var preFinal = InitializeGrades("Prefinal");
                var final    = InitializeGrades("Final");
                await authDbContext.AddRangeAsync(prelim, midterm, preFinal, final);

                await authDbContext.SaveChangesAsync();

                var grade = new Grade
                {
                    AppUserID  = user.Id,
                    PrelimID   = prelim.ID,
                    MidtermID  = midterm.ID,
                    PrefinalID = preFinal.ID,
                    FinalID    = final.ID
                };

                await authDbContext.AddAsync(grade);

                await authDbContext.SaveChangesAsync();
            }

            return(RedirectToAction("Index", "Admin", new { area = "" }));
        }