/// <summary> /// Check PersonTechnology /// </summary> /// <param name="personTechnology"></param> /// <returns></returns> public async Task <bool> CheckPersonTechnologyAsync(PersonTechnology personTechnology) { using (var conn = OpenDBConnection()) { StringBuilder sql = new StringBuilder(); sql.Length = 0; sql.Append("SELECT COUNT(*) "); sql.Append("FROM PersonTechnology AS PT "); sql.Append("INNER JOIN Technology AS TE "); sql.Append("ON PT.TechnologyId = TE.Id "); sql.Append("WHERE PT.PersonId = @PersonId "); sql.Append("AND PT.TechnologyId = @TechnologyId "); sql.Append("AND PT.Status = 1 AND TE.Status = 1 "); var param = new { PersonId = personTechnology.PersonId, TechnologyId = personTechnology.TechnologyId }; var count = await conn.ExecuteScalarAsync <int>(sql.ToString(), param); return(count > 0); } }
/// <summary> /// Get List PersonTechnology /// </summary> /// <param name="skillRequestModel"></param> /// <returns></returns> public async Task <List <PersonTechnology> > GetListPersonTechnology(SkillRequestModel skillRequestModel) { List <PersonTechnology> personTechnologies = new List <PersonTechnology>(); foreach (var item in skillRequestModel.TechnologyId) { Technology modelTechnology = await _technologyRepository.FindAsync(item); if (modelTechnology != null) { PersonTechnology personTechnology = new PersonTechnology { PersonId = skillRequestModel.PersonId, TechnologyId = modelTechnology.Id, CreatedBy = WebAPI.Helpers.HttpContext.CurrentUser, UpdatedBy = WebAPI.Helpers.HttpContext.CurrentUser, CreatedAt = DateTime.Now, UpdatedAt = DateTime.Now }; personTechnologies.Add(personTechnology); } } return(personTechnologies); }