public JsonResult RegisterByDeskTop(Register model) { UserModule module = new UserModule(_context, _userManager, _signInManager); ParentModule parentMod = new ParentModule(_context); StudentModule studentMod = new StudentModule(_context); StudentParentModule stuParMod = new StudentParentModule(_context); StudentClassroomModule stuClassMod = new StudentClassroomModule(_context); //=========== checking validation for credencials key ===============// var credInfo = GetCredentialsInfo(model.Student.Key); // if ( GetCredentialsInfo(model.Student.Key) == null ) if (credInfo == null) { return(Json(new { Succeeded = false, statusCode = 501 })); } var resultVal = module.CreateUserByDeskTop(model.Users); if (resultVal.Result.StatusCode == 200) // success Users table { if (module.GetUserInfo(model.Users) != null) { Users user = new Users { UserName = model.Users.Email, PasswordHash = model.Users.PasswordHash }; string oauthResult = CreateOAuthUser(user); // need validation check. if result is success return success value else delete MPXUser data and return error. if (model.Parent == null) { model.Parent = new Parent(); } model.Parent.UserId = module.GetUserInfo(model.Users).Id; //select userID int parentID = parentMod.CreateParent(model.Parent); //save parent info model.Student.ParentID = parentID; int studentID = studentMod.CreateStudent(model.Student); //save student info StudentParent stuParModel = new StudentParent { ParentID = parentID, StudentID = studentID }; stuParMod.CreateStudentParent(stuParModel); //save StudentParent info StudentClassroom stuClassModel = new StudentClassroom { StudentID = studentID, IsActive = true, ClassroomID = credInfo.Teacher.ClassroomID }; stuClassMod.CreateStuClassroom(stuClassModel); //save studentclassroom // var roleresult = _userManager.AddToRoleAsync(model.Users, "Superusers"); } } return(Json(resultVal.Result)); }
/// <summary> /// 处理好友状态变化 /// </summary> /// <param name="pollData"></param> /// <returns></returns> public QQNotifyEvent ProcessBuddyStatusChange(JObject pollData) { try { var uin = pollData["uin"].ToObject <long>(); var buddy = Context.Store.GetBuddyByUin(uin); if (buddy == null) { buddy = new QQBuddy() { Uin = uin }; Context.Store.AddBuddy(buddy); UserModule userModule = Context.GetModule <UserModule>(QQModuleType.USER); userModule.GetUserInfo(buddy, null); } var status = pollData["status"].ToString(); var clientType = pollData["client_type"].ToObject <int>(); buddy.Status = QQStatus.ValueOfRaw(status); buddy.ClientType = QQClientType.ValueOfRaw(clientType); return(new QQNotifyEvent(QQNotifyEventType.BUDDY_STATUS_CHANGE, buddy)); } catch (Exception ex) { return(new QQNotifyEvent(QQNotifyEventType.NET_ERROR, ex)); } }
public async Task <IActionResult> AppLogin(LoginViewModel model) { ParentModule module = new ParentModule(_context); if (ModelState.IsValid) { // This doesn't count login failures towards account lockout // To enable password failures to trigger account lockout, set lockoutOnFailure: true var result = await _signInManager.PasswordSignInAsync(model.Email, model.Password, model.RememberMe, lockoutOnFailure : false); if (result.Succeeded) { _logger.LogInformation(1, "User logged in."); UserModule module1 = new UserModule(_context, _userManager, _signInManager); Users user = new Users { Email = model.Email }; string userid = module1.GetUserInfo(user).Id; //select userID if (userid.Length == 0) { return(NotFound()); } List <Parent> item = module.GetParentInfo2(userid); var resultToken = GetToken(model); return(CreatedAtAction("Get", new { Successed = true, statusCode = 200, tokenResult = resultToken, item })); //return Json(item); } } // If we got this far, something failed, redisplay form return(BadRequest()); }
public Users GetUserInfo(Users users) { UserModule module = new UserModule(_context, _userManager, _signInManager); var item = module.GetUserInfo(users); if (item == null) { return(null); } return(item); }
public bool CheckMember(RegisterViewModel model) { UserModule module = new UserModule(_context, _userManager, _signInManager); if (module.GetUserInfo(new Users { Email = model.Email }) != null) { return(true); } return(false); }
public async Task <string> CreateUser(RegisterViewModel model) { UserModule module = new UserModule(_context, _userManager, _signInManager); if (module.GetUserInfo(new Users { Email = model.Email }) == null) { var result = await module.CreateUser(model); Users user = new Users { Email = model.Email }; module.GetUserInfo(user); //select userID user.UserName = model.Email; user.PasswordHash = model.Password; string oauthResult = CreateOAuthUser(user); // need validation check. if result is success return success value else delete MPXUser data and return error. return(module.GetUserInfo(user).Id); } return(null); }
public async Task <Users> GetUserInfoAsync(string email, string password) { UserModule module = new UserModule(_context, _userManager, _signInManager); var flag = await module.GetUserValidationAsync(email, password); Users user = new Users { Email = email }; if (flag) { var item = module.GetUserInfo(user); return(item); } return(null); }
public async Task <IActionResult> Login(LoginViewModel model, string returnUrl = null) { UserModule module = new UserModule(_dbContext, _userManager, _signInManager); ViewData["ReturnUrl"] = returnUrl; if (ModelState.IsValid) { // This doesn't count login failures towards account lockout // To enable password failures to trigger account lockout, set lockoutOnFailure: true var result = await _signInManager.PasswordSignInAsync(model.Email, model.Password, model.RememberMe, lockoutOnFailure : false); if (result.Succeeded) { _logger.LogInformation(1, "User logged in."); Users user = module.GetUserInfo(new Users { Email = model.Email }); bool roleType = await _userManager.IsInRoleAsync(user, "Parent"); if (roleType) { return(RedirectToAction(nameof(SchoolActivityController.ApplicationList), "SchoolActivity")); } else { return(RedirectToAction(nameof(SchoolActivityController.Index), "SchoolActivity")); } } if (result.IsLockedOut) { _logger.LogWarning(2, "User account locked out."); return(View("Lockout")); } else { ModelState.AddModelError(string.Empty, "Invalid login attempt."); return(View(model)); } } // If we got this far, something failed, redisplay form return(View(model)); }