private User SetUserData(User user, UserInfoDB userInfo) { user.FinancialResponsible = new FinancialResponsibleInfo() { Address = new Address( userInfo.Endereco, userInfo.Numero, userInfo.Cidade, userInfo.Estado, userInfo.Pais, userInfo.CEP, userInfo.Bairro ), Email = userInfo.Email, FullName = userInfo.NomeCompleto, MobilePhone = userInfo.Celular, Name = userInfo.Nome, Phone = userInfo.Telefone, Surname = userInfo.Sobrenome }; if (!CellIsEmpty(userInfo.Matricula) && String.IsNullOrEmpty(user.RegistrationId)) { user.RegistrationId = userInfo.Matricula; } if (!CellIsEmpty(userInfo.Linkedin) && String.IsNullOrEmpty(user.LinkedIn)) { user.LinkedIn = userInfo.Linkedin; } if (!CellIsEmpty(userInfo.NomeCompletoAluno) && String.IsNullOrEmpty(user.Name)) { user.Name = userInfo.NomeCompletoAluno; } if (!CellIsEmpty(userInfo.EmailAluno) && String.IsNullOrEmpty(user.Email)) { user.Email = userInfo.EmailAluno; } if (user.Address == null || String.IsNullOrEmpty(user.Address.Street)) { user.Address = new Address( userInfo.EnderecoAluno, userInfo.ComplementoAluno, userInfo.CidadeAluno, userInfo.EstadoAluno, "Brasil", "", userInfo.BairroAluno ); } if (!CellIsEmpty(userInfo.Telefone1Aluno) && String.IsNullOrEmpty(user.Phone)) { user.Phone = userInfo.Telefone1Aluno; } if (!CellIsEmpty(userInfo.Telefone2Aluno) && String.IsNullOrEmpty(user.Phone2)) { user.Phone2 = userInfo.Telefone2Aluno; } if (!CellIsEmpty(userInfo.DataNascimentoAluno)) { user.BirthDate = GetParsedDate(userInfo.DataNascimentoAluno); } if (!CellIsEmpty(userInfo.TipoDocAluno) && user.Document == null) { user.Document = (DocumentType)Int32.Parse(userInfo.TipoDocAluno); } if (!CellIsEmpty(userInfo.NumDocAluno) && String.IsNullOrEmpty(user.DocumentNumber)) { user.DocumentNumber = userInfo.NumDocAluno; } if (!CellIsEmpty(userInfo.OrgaoDocAluno) && String.IsNullOrEmpty(user.DocumentEmitter)) { user.DocumentEmitter = userInfo.OrgaoDocAluno; } if (!CellIsEmpty(userInfo.DataEmissaoDocAluno)) { user.EmitDate = GetParsedDate(userInfo.DataEmissaoDocAluno); } if (!CellIsEmpty(userInfo.ValidadeDocAluno)) { user.ExpirationDate = GetParsedDate(userInfo.ValidadeDocAluno); } if ( !CellIsEmpty(userInfo.PerfilProseek) || !CellIsEmpty(userInfo.Vies1) || !CellIsEmpty(userInfo.Vies2) ) { user.Profile = new UserProfile() { Title = userInfo.PerfilProseek, BiasOne = userInfo.Vies1, BiasTwo = userInfo.Vies2 }; } return(user); }
private async Task SetUserCareerInfo(User user, UserInfoDB userInfo, CancellationToken token) { bool createNew = false; var userCareer = await _db.UserCareerCollection.AsQueryable() .Where(uc => uc.CreatedBy == user.Id) .FirstOrDefaultAsync(); if (userCareer == null) { userCareer = UserCareer.Create(user.Id).Data; createNew = true; } if ( !CellIsEmpty(userInfo.GrauCurso1) || !CellIsEmpty(userInfo.NomeCurso1) || !CellIsEmpty(userInfo.Instituicao1) || !CellIsEmpty(userInfo.AnoInicio1) || !CellIsEmpty(userInfo.AnoConclusao1) || !CellIsEmpty(userInfo.PeriodoAnoConclusao1) || !CellIsEmpty(userInfo.CRAcumulado1) || !CellIsEmpty(userInfo.SituacaoCurso1) || !CellIsEmpty(userInfo.Campus1) ) { var college = new College() { AcademicDegree = userInfo.GrauCurso1, Name = userInfo.NomeCurso1, Title = userInfo.Instituicao1, Campus = userInfo.Campus1, CR = userInfo.CRAcumulado1, Status = userInfo.SituacaoCurso1 }; if (!CellIsEmpty(userInfo.PeriodoAnoConclusao1)) { college.CompletePeriod = Int32.Parse(userInfo.PeriodoAnoConclusao1); } if (!CellIsEmpty(userInfo.AnoInicio1)) { int year = Int32.Parse(userInfo.AnoInicio1); college.StartDate = new DateTime(year, 1, 1); } if (!CellIsEmpty(userInfo.AnoConclusao1)) { int year = Int32.Parse(userInfo.AnoConclusao1); college.EndDate = new DateTime(year, 1, 1); } if (userCareer.Colleges == null) { userCareer.Colleges = new List <College>(); } userCareer.Colleges.Add(college); } if (!CellIsEmpty(userInfo.Ingles)) { var language = new PerkLanguage() { Names = "Inglês", Level = userInfo.Ingles }; if (userCareer.Languages == null) { userCareer.Languages = new List <PerkLanguage>(); } userCareer.Languages.Add(language); } if (!CellIsEmpty(userInfo.Excel)) { var excel = new Perk() { Name = "Excel", Level = userInfo.Excel }; if (userCareer.Abilities == null) { userCareer.Abilities = new List <Perk>(); } userCareer.Abilities.Add(excel); } if (!CellIsEmpty(userInfo.VBA)) { var vba = new Perk() { Name = "VBA", Level = userInfo.VBA }; if (userCareer.Abilities == null) { userCareer.Abilities = new List <Perk>(); } userCareer.Abilities.Add(vba); } if ( !CellIsEmpty(userInfo.Empresa1) || !CellIsEmpty(userInfo.CargoEmpresa1) || !CellIsEmpty(userInfo.DescricaoEmpresa1) ) { var experience = new ProfessionalExperience() { Title = userInfo.Empresa1, Role = userInfo.CargoEmpresa1, Description = userInfo.DescricaoEmpresa1 }; if (userCareer.ProfessionalExperiences == null) { userCareer.ProfessionalExperiences = new List <ProfessionalExperience>(); } userCareer.ProfessionalExperiences.Add(experience); } if (!CellIsEmpty(userInfo.ObjetivoProfissionalCurto) && String.IsNullOrEmpty(userCareer.ShortDateObjectives)) { userCareer.ShortDateObjectives = userInfo.ObjetivoProfissionalCurto; } if (!CellIsEmpty(userInfo.ObjetivoProfissionalLongo) && String.IsNullOrEmpty(userCareer.LongDateObjectives)) { userCareer.LongDateObjectives = userInfo.ObjetivoProfissionalLongo; } if (createNew) { await _db.UserCareerCollection.InsertOneAsync( userCareer, cancellationToken : token ); } else { await _db.UserCareerCollection.ReplaceOneAsync( u => u.CreatedBy == user.Id, userCareer, cancellationToken : token ); } }
private async Task <User> UpdateUserInfo(List <Track> tracks, User currentUser, UserInfoDB userInfo, CancellationToken token) { if (currentUser == null) { currentUser = Student.CreateUser( userInfo.NomeCompletoAluno, userInfo.EmailAluno.Trim(), userInfo.EmailAluno.Trim(), userInfo.Matricula, userInfo.CPFAluno, "", "", "", userInfo.Telefone1Aluno, "", "Student" ).Data; currentUser.FirstAccess = false; currentUser = SetUserData(currentUser, userInfo); currentUser = await SetUserTrack(tracks, currentUser, userInfo, token); var result = await _userManager.CreateAsync(currentUser, "Proseek2018!"); if (!result.Succeeded) { await _db.ErrorLogCollection.InsertOneAsync( ErrorLog.Create( ErrorLogTypeEnum.DatabaseImport, "CreateNewUser", result.Errors.ToJson() ).Data, cancellationToken : token ); } } else { currentUser = SetUserData(currentUser, userInfo); currentUser = await SetUserTrack(tracks, currentUser, userInfo, token); await _db.UserCollection.ReplaceOneAsync( u => u.Id == currentUser.Id, currentUser, cancellationToken : token ); } if (currentUser.TracksInfo != null && currentUser.TracksInfo.Count > 0) { var tracksProgress = new List <UserTrackProgress>(); foreach (var track in currentUser.TracksInfo) { tracksProgress.Add( new UserTrackProgress(track.Id, currentUser.Id, 0, 0) ); } await _db.UserTrackProgressCollection.InsertManyAsync( tracksProgress, cancellationToken : token ); } return(currentUser); }