public async Task <UspBaseSaveResult> SaveStudent(StudentRegistrationVM model)
        {
            try
            {
                UspBaseSaveResult result = new UspBaseSaveResult();
                var user = new ApplicationUser
                {
                    UserName = model.Email,
                    Email    = model.Email
                };

                var signUpResult = await _userManager.CreateAsync(user, model.Password);

                if (signUpResult.Succeeded)
                {
                    // Add role to user
                    await _userManager.AddToRoleAsync(user, "User");

                    // for signIn after register
                    await _signInManager.SignInAsync(user, false); // false means lost info after leaving page

                    result.OperationStatus  = "SUCCESS";
                    result.OperationMessage = "Registration successfull!!";
                }

                return(result);
            }
            catch
            {
                throw;
            }
        }
Ejemplo n.º 2
0
        public async Task <JsonResult> LoginStudent(LoginViewModel model)
        {
            try
            {
                UspBaseSaveResult result = new UspBaseSaveResult();
                result = await _trackAboutRepo.LoginStudent(model);

                return(Json(result));
            }
            catch
            {
                return(Json(new UspBaseSaveResult()));
            }
        }
Ejemplo n.º 3
0
        public async Task <JsonResult> SaveStudent(StudentRegistrationVM model)
        {
            try
            {
                UspBaseSaveResult result = new UspBaseSaveResult();
                result = await _trackAboutRepo.SaveStudent(model);

                return(Json(result));
            }
            catch
            {
                return(Json(new UspBaseSaveResult()));
            }
        }
        public async Task <UspBaseSaveResult> LoginStudent(LoginViewModel model)
        {
            try
            {
                UspBaseSaveResult result = new UspBaseSaveResult();
                var signInresult         = await _signInManager.PasswordSignInAsync(model.Email, model.Password, model.RememberMe, false); // logout the user if fail true:false

                if (signInresult.Succeeded)
                {
                    result.OperationStatus = "SUCCESS";
                }
                else
                {
                    result.OperationStatus  = "FAIL";
                    result.OperationMessage = "Invalid Login Attempt";
                }

                return(result);
            }
            catch
            {
                throw;
            }
        }