Example #1
0
        public JsonResult CreateParent(Parent item)
        {
            ParentModule module   = new ParentModule(_context);
            int          parentID = module.CreateParent(item);

            return(Json(new { Succeeded = true, statusCode = 200, parentID = parentID }));
        }
Example #2
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));
        }
Example #3
0
        public int RegisterParent(string userid, string firstname, string lastname)
        {
            ParentModule parentMod = new ParentModule(_context);

            Parent parentItem = new Parent {
                UserId = userid
            };

            int parentID = parentMod.CreateParent(parentItem);                   //save parent info

            Users user = new Users {
                Id = userid, FirstName = firstname, LastName = lastname
            };
            UserModule module = new UserModule(_context, _userManager, _signInManager);

            module.GetUpdateUserInfo(user);

            return(parentID);
        }