/// <summary> /// Pasing data to data access layer for inserting risorse retrieved from controller end. /// </summary> /// <param name="risorseDto"></param> /// <returns></returns> public async Task <string> InsertAsync(ClaimsPrincipal User, RisorseDto risorseDto) { try { // Create new domain object from DTO. Risorse risorse = _mapper.Map <RisorseDto, Risorse>(risorseDto); // Set auditable properties. risorse.RisInsUteId = User.Claims.FirstOrDefault(x => x.Type.Equals("http://schemas.xmlsoap.org/ws/2005/05/identity/claims/nameidentifier"))?.Value; risorse.RisInsTimestamp = DateTime.Now; risorse.RisModUteId = User.Claims.FirstOrDefault(x => x.Type.Equals("http://schemas.xmlsoap.org/ws/2005/05/identity/claims/nameidentifier"))?.Value; risorse.RisModTimestamp = DateTime.Now; risorse.RisCliId = User.Claims.FirstOrDefault(x => x.Type.Equals("http://schemas.xmlsoap.org/ws/2005/05/identity/claims/sid"))?.Value; // Execute persistence. _unitOfWork.Risorse.Add(risorse); await _unitOfWork.CompleteAsync(); return(risorse.RisTitolo); } catch (Exception) { throw; } }
public async Task <RisorseCvInfo> GetCvInfoAsync(int risId) { // Fetching data from dal. Risorse risorse = await _unitOfWork.Risorse.FirstOrDefaultAsync(x => x.RisId == risId); // Returning the retrieved data to controller end return(_mapper.Map <Risorse, RisorseCvInfo>(risorse)); }
/// <summary> /// Upload CV file. /// </summary> /// <param name="clientId"></param> /// <param name="risId"></param> /// <param name="file"></param> /// <returns></returns> public async Task <string> UploadCvAsync(string clientId, int risId, IFormFile file) { Risorse risorse = await _unitOfWork.Risorse .FirstOrDefaultAsync(x => x.RisId == risId && x.RisCliId == clientId); if (risorse == null) { return("Failed"); } var extension = System.IO.Path.GetExtension(file.FileName); var fileName = Guid.NewGuid().ToString() + extension; risorse.RisCvNomeFile = fileName; risorse.RisCvDimInKb = file.Length / 1024; risorse.RisCvDataInserimento = DateTime.Now; using (var stream = new MemoryStream()) { await file.CopyToAsync(stream); risorse.RisCvAllegato = stream.ToArray(); } var extLower = extension.ToLower(); string cvTextContent = ""; if (extLower == ".doc" || extLower == ".docx") { cvTextContent = DocStreamByteToText(risorse.RisCvAllegato); } else if (extLower == ".pdf") { cvTextContent = PdfStreamByteToText(risorse.RisCvAllegato); } if (!string.IsNullOrEmpty(cvTextContent)) { risorse.RisCvTesto = cvTextContent; } await _unitOfWork.CompleteAsync(); return(risorse.RisTitolo); }
/// <summary> /// To store the soft skill survey ws data to db. /// </summary> /// <param name="surveryorEmail">email of the surveyor who attent the survey</param> /// <param name="softSkillTestId">1 for ws getProfile() and 2 for ws GetSkillProfile</param> /// <param name="softSkillTestQuiz">S for ws getProfile() and N for ws GetSkillProfile</param> /// <returns></returns> public async Task <int> InsertSoftSkillTestWSResultAsync(GetWSResultDto getWSResultDto) { try { SoftskillsTestWsResult sstwr = new SoftskillsTestWsResult(); sstwr.SsktestresTestId = getWSResultDto.SoftSkillTestId; sstwr.SsktestresPlayField1 = (decimal)getWSResultDto.P; sstwr.SsktestresPlayField2 = (decimal)getWSResultDto.L; sstwr.SsktestresPlayField3 = (decimal)getWSResultDto.A; sstwr.SsktestresPlayField4 = (decimal)getWSResultDto.Y; sstwr.SsktestresProfilo = getWSResultDto.ProfileIdProp; sstwr.SsktestresTipoTestQuiz = getWSResultDto.SoftSkillTestQuiz; sstwr.SsktestresRisDataRisposta = DateTime.Now; sstwr.SsktestresInsTimestamp = DateTime.Now; sstwr.SsktestresModTimestamp = DateTime.Now; if (getWSResultDto.RichId != null) { sstwr.SsktestresRichId = getWSResultDto.RichId; } if (sstwr.SsktestresRichId == null) { Risorse risorse = await _unitOfWork.Risorse .FirstOrDefaultAsync(c => c.RisEmail.Contains(getWSResultDto.SurveyorEmail)); sstwr.SsktestresRisId = risorse?.RisId; } _unitOfWork.SoftskillsTestWsResult.Add(sstwr); await _unitOfWork.CompleteAsync(); return(sstwr.SsktestresId); } catch (Exception e) { throw; } }
/// <summary> /// Extract cv content from database cv saved as byte[] /// </summary> /// <param name="clientId"></param> /// <param name="risId"></param> /// <returns>string</returns> public async Task <string> ScanCVAsync(string clientId, int risId) { Risorse risorse = await _unitOfWork.Risorse .FirstOrDefaultAsync(x => x.RisId == risId && x.RisCliId == clientId); if (risorse == null) { return(""); } if (risorse.RisCvAllegato == null || risorse.RisCvAllegato.Length == 0) { return(""); } var extension = System.IO.Path.GetExtension(risorse.RisCvNomeFile); var extLower = extension.ToLower(); string cvTextContent = ""; if (extLower == ".doc" || extLower == ".docx") { cvTextContent = DocStreamByteToText(risorse.RisCvAllegato); } else if (extLower == ".pdf") { cvTextContent = PdfStreamByteToText(risorse.RisCvAllegato); } if (!string.IsNullOrEmpty(cvTextContent)) { risorse.RisCvTesto = cvTextContent; await _unitOfWork.CompleteAsync(); } return(cvTextContent); }
/// <summary> /// Pasing data to data access layer for updating risorse retrieved from controller end. /// </summary> /// <param name="richiesteDto"></param> /// <returns></returns> public async Task <string> UpdateAsync(ClaimsPrincipal User, RisorseDto risorseDto) { try { //map dto dto to table risorse Risorse risorse = await _unitOfWork.Risorse .FirstOrDefaultAsync(x => x.RisId == risorseDto.RisId && x.RisCliId == risorseDto.RisCliId); _mapper.Map(risorseDto, risorse); risorse.RisModUteId = User.Claims.FirstOrDefault(x => x.Type.Equals("http://schemas.xmlsoap.org/ws/2005/05/identity/claims/nameidentifier"))?.Value; risorse.RisModTimestamp = DateTime.Now; await _unitOfWork.CompleteAsync(); return(risorse.RisTitolo); } catch (Exception ex) { throw; } }