Exemplo n.º 1
0
        public JsonResult GetInfo(int id)
        {
            StudentParentModule module = new StudentParentModule(_context);
            var item = module.GetInfo(id);

            return(Json(item));
        }
Exemplo n.º 2
0
        public JsonResult Get()
        {
            StudentParentModule module = new StudentParentModule(_context);
            var resultVal = module.GetList();

            return(Json(resultVal));
        }
Exemplo n.º 3
0
        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));
        }