private int Register(RegisterAddModel model, int role) { //If the user didn't select a role, then they are logging in - return -1 if (role == 0) { return(-1); } //Create base account int accountId = _service.CreateBaseAccount(model); AssignRoles arModel = new AssignRoles(); arModel.AccountId = accountId; //Assign the selected student or mentor role arModel.RoleId = role; _roleService.Insert(arModel); //Assign the blogger role arModel.RoleId = 3; _roleService.Insert(arModel); //Return the id of the new account return(accountId); }
//Function - Takes a RegisterAddModel and creates a base account in the database // - returns the Id of the new account public int CreateBaseAccount(RegisterAddModel model) { //Generates a random string for the password model.Password = _cryptoService.GenerateRandomString(12); //Sets the email confirmed to true because their email is confirmed through the third party model.EmailConfirmed = true; model.ModifiedBy = model.Email; //Calls the InsertNewUser from the user service to create the base account int accountId = _userService.InsertNewUser(model); return(accountId); }