public string CreateEmployer(ReqEmployerVM req) { if (req is null) { ExceptionBase.ThrowException(404, "Employer Req is empty , make sure of providing Requird Data!", "Employer Req is empty , make sure of providing Requird Data!"); } var IsEmployerAdded = unitOfWork.GetRepository <Tbl_Employer>().GetSingle(e => e.EmployerName.Equals(req.EmployerName)); if (!(IsEmployerAdded is null)) { return(IsEmployerAdded.Code.ToString()); } var NewEmployer = new Tbl_Employer() { EmployerName = req.EmployerName }; if (NewEmployer is null) { ExceptionBase.ThrowException(500, "Cannot Parse req object to Tbl_Employer", "Cannot Parse req object to Tbl_Employer"); } unitOfWork.GetRepository <Tbl_Employer>().Add(NewEmployer); unitOfWork.SaveChanges(); return(NewEmployer.Code.ToString()); }
public string CreateSkill(ReqSkillVM req) { if (req is null) { ExceptionBase.ThrowException(404, "Skill Req is empty , make sure of providing Requird Data!", "Skill Req is empty , make sure of providing Requird Data!"); } var IsSkillAdded = unitOfWork.GetRepository <Tbl_Skills>().GetSingle(e => e.SkillName.Equals(req.SkillName)); if (!(IsSkillAdded is null)) { return(IsSkillAdded.Code.ToString()); } var NewSkill = new Tbl_Skills() { SkillName = req.SkillName, Rate = req.Rate }; if (NewSkill is null) { ExceptionBase.ThrowException(500, "Cannot Parse req object to Tbl_Skills", "Cannot Parse req object to Tbl_Skills"); } unitOfWork.GetRepository <Tbl_Skills>().Add(NewSkill); unitOfWork.SaveChanges(); return(NewSkill.Code.ToString()); }
public List <ResCandidateVM> GetEmployerCandidates(string EmployerId) { if (EmployerId == default || string.IsNullOrWhiteSpace(EmployerId)) { ExceptionBase.ThrowException(404, "Employer ID is null or Empty. ", "Employer ID is null or Empty. "); } var IsFoundedEmployer = unitOfWork.GetRepository <Tbl_Employer>().GetSingle(e => e.Code.ToString().Equals(EmployerId)); if (IsFoundedEmployer is null) { ExceptionBase.ThrowException(404, "that is not a Employer ID .", "that Employer is not found. "); } var EmpCandidates = unitOfWork.GetRepository <Tbl_CandidateEmployer>().GetAllIncluding(e => e.CurrentEmployerId.Equals(IsFoundedEmployer.Id) || e.PreviousEmployerId.Equals(IsFoundedEmployer.Id)); if (EmpCandidates == default || EmpCandidates.Count <= 0) { ExceptionBase.ThrowException(404, "this Employer has no registered Candidates.", "this Employer has no registered Candidates."); } List <ResCandidateVM> candidateVMs = new List <ResCandidateVM>(); foreach (var item in EmpCandidates) { candidateVMs.Add(mapper.Map <ResCandidateVM>(unitOfWork.GetRepository <Tbl_Candidate>().GetSingle(x => x.Id.Equals(item.CandidateId)))); } return(candidateVMs); }
public List <ResSkillVM> GetCandidateSkills(string CandidateId) { if (CandidateId == default || string.IsNullOrWhiteSpace(CandidateId)) { ExceptionBase.ThrowException(404, "Candidate ID is null or Empty. ", "Candidate ID is null or Empty. "); } var IsFoundedCandidate = unitOfWork.GetRepository <Tbl_Candidate>().GetSingle(e => e.Code.ToString().Equals(CandidateId)); if (IsFoundedCandidate is null) { ExceptionBase.ThrowException(404, "that is not a candidate ID .", "that candidate is not found. "); } var CandidateSkills = unitOfWork.GetRepository <Tbl_CandidateSkills>().GetAllIncluding(e => e.CandidateId.Equals(IsFoundedCandidate.Id)); if (CandidateSkills == default || CandidateSkills.Count <= 0) { ExceptionBase.ThrowException(404, "this candidate has no registed skills.", "this candidate has no registed skills."); } List <Tbl_Skills> skills = new List <Tbl_Skills>(); foreach (var item in CandidateSkills) { skills.Add(unitOfWork.GetRepository <Tbl_Skills>().GetSingle(e => e.Id.Equals(item.SkillId))); } return(mapper.Map <List <ResSkillVM> >(skills)); }
public List <ResEmployerVM> GetCandidateEmployers(string CandidateId) { if (CandidateId == default || string.IsNullOrWhiteSpace(CandidateId)) { ExceptionBase.ThrowException(404, "Candidate ID is null or Empty. ", "Candidate ID is null or Empty. "); } var IsFoundedCandidate = unitOfWork.GetRepository <Tbl_Candidate>().GetSingle(e => e.Code.ToString().Equals(CandidateId)); if (IsFoundedCandidate is null) { ExceptionBase.ThrowException(404, "that is not a candidate ID .", "that candidate is not found. "); } var CandEmployers = unitOfWork.GetRepository <Tbl_CandidateEmployer>().GetSingle(e => e.CandidateId.Equals(IsFoundedCandidate.Id)); if (CandEmployers is null) { ExceptionBase.ThrowException(404, "Candidate has no previous or current employers. ", "Candidate has no previous or current employers. "); } var PrevEmp = unitOfWork.GetRepository <Tbl_Employer>().GetSingle(e => e.Id.Equals(CandEmployers.PreviousEmployerId)); var CurrEmp = unitOfWork.GetRepository <Tbl_Employer>().GetSingle(e => e.Id.Equals(CandEmployers.CurrentEmployerId)); List <ResEmployerVM> employerVMs = new List <ResEmployerVM>(); employerVMs.Add(mapper.Map <ResEmployerVM>(PrevEmp)); employerVMs.Add(mapper.Map <ResEmployerVM>(CurrEmp)); return(employerVMs); }
public string GetConnectionId(string userId) { var tblToken = unitOfWork.GetRepository <Tbl_Token>().GetSingle(e => e.UserId.Equals(userId)); if (tblToken == null) { throw ExceptionBase.ThrowException(400, "You Don't have token", "You Don't have token"); } return(tblToken.ConnectionId); }
public string UpdateCandidateProfile(ReqCandidateVM req, string CandidateId) { if (req is null) { ExceptionBase.ThrowException(404, "Candidate Req is empty , make sure of providing Requird Data!", "Candidate Req is empty , make sure of providing Requird Data!"); } if (CandidateId == default || string.IsNullOrWhiteSpace(CandidateId)) { ExceptionBase.ThrowException(404, "Candidate ID is null or Empty. ", "Candidate ID is null or Empty. "); } var IsFoundedCandidate = unitOfWork.GetRepository <Tbl_Candidate>().GetSingle(e => e.Code.ToString().Equals(CandidateId)); if (IsFoundedCandidate is null) { ExceptionBase.ThrowException(404, "that is not a candidate ID .", "that candidate is not found. "); } var UpdatedCandidate = mapper.Map <Tbl_Candidate>(req); unitOfWork.GetRepository <Tbl_Candidate>().Update(UpdatedCandidate); if (!(req.ReqSkills is null) && req.ReqSkills.Count > 0) { List <Tbl_CandidateSkills> candidateSkills = new List <Tbl_CandidateSkills>(); foreach (var item in req.ReqSkills) { candidateSkills.Add(new Tbl_CandidateSkills() { CandidateId = IsFoundedCandidate.Id, SkillId = unitOfWork.GetRepository <Tbl_Skills>().GetSingle(e => e.SkillName.Equals(item.SkillName)).Id }); } unitOfWork.GetRepository <Tbl_CandidateSkills>().UpdateRing(candidateSkills.ToArray()); } if (!(req.ReqEmployers is null) && req.ReqEmployers.Count > 0) { var PrevEmployer = req.ReqEmployers.Where(x => x.ReqEmployerType.Equals(ReqEmployerTypeVM.PreviousEmployer)).FirstOrDefault(); var CurrentEmployer = req.ReqEmployers.Where(x => x.ReqEmployerType.Equals(ReqEmployerTypeVM.CurrentEmployer)).FirstOrDefault(); var CandidateEmployer = new Tbl_CandidateEmployer(); if (PrevEmployer != null) { var PrevEmp = unitOfWork.GetRepository <Tbl_Employer>().GetSingle(e => e.EmployerName.Equals(PrevEmployer.EmployerName)); CandidateEmployer.CandidateId = IsFoundedCandidate.Id; CandidateEmployer.PreviousEmployerId = PrevEmp.Id; } if (CurrentEmployer != null) { var CurrEmp = unitOfWork.GetRepository <Tbl_Employer>().GetSingle(e => e.EmployerName.Equals(CurrentEmployer.EmployerName)); CandidateEmployer.CurrentEmployerId = CurrEmp.Id; } unitOfWork.GetRepository <Tbl_CandidateEmployer>().Update(CandidateEmployer); } unitOfWork.SaveChanges(); return("Success"); }
public ResEmployerVM GetEmployer(string EmployerId) { if (EmployerId == default || string.IsNullOrWhiteSpace(EmployerId)) { ExceptionBase.ThrowException(404, "Employer ID is null or Empty. ", "Employer ID is null or Empty. "); } var IsFoundedEmployer = unitOfWork.GetRepository <Tbl_Employer>().GetSingle(e => e.Code.ToString().Equals(EmployerId)); if (IsFoundedEmployer is null) { ExceptionBase.ThrowException(404, "that is not a Employer ID .", "that Employer is not found. "); } return(mapper.Map <ResEmployerVM>(IsFoundedEmployer)); }
public ResSkillVM GetSkill(string SkillId) { if (SkillId == default || string.IsNullOrWhiteSpace(SkillId)) { ExceptionBase.ThrowException(404, "Skill ID is null or Empty.", "Skill ID is null or Empty."); } var IsFoundedSkill = unitOfWork.GetRepository <Tbl_Skills>().GetSingle(e => e.Code.ToString().Equals(SkillId)); if (IsFoundedSkill is null) { ExceptionBase.ThrowException(404, "that is not a Skill ID .", "that Skill is not found."); } return(mapper.Map <ResSkillVM>(IsFoundedSkill)); }
public bool UpdateConnectionId(string userId, string ConnectionId) { var tblToken = unitOfWork.GetRepository <Tbl_Token>().GetSingle(e => e.UserId.Equals(userId)); if (tblToken == null) { throw ExceptionBase.ThrowException(400, "You Don't have token", "You Don't have token"); } tblToken.ConnectionId = ConnectionId; unitOfWork.GetRepository <Tbl_Token>().Update(tblToken); unitOfWork.SaveChanges(); return(true); }
public string DeleteSkill(string SkillId) { if (SkillId == default || string.IsNullOrWhiteSpace(SkillId)) { ExceptionBase.ThrowException(404, "Skill ID is null or Empty. ", "Skill ID is null or Empty. "); } var IsFoundedSkill = unitOfWork.GetRepository <Tbl_Skills>().GetSingle(e => e.Code.ToString().Equals(SkillId)); if (IsFoundedSkill is null) { ExceptionBase.ThrowException(404, "that Skill is not found.", "that Skill is not found. "); } unitOfWork.GetRepository <Tbl_Skills>().SoftDelete(IsFoundedSkill); unitOfWork.SaveChanges(); return("Success"); }
public string DeleteCandidate(string CandidateId) { if (CandidateId == default || string.IsNullOrWhiteSpace(CandidateId)) { ExceptionBase.ThrowException(404, "Candidate ID is null or Empty. ", "Candidate ID is null or Empty. "); } var IsFoundedCandidate = unitOfWork.GetRepository <Tbl_Candidate>().GetSingle(e => e.Code.ToString().Equals(CandidateId)); if (IsFoundedCandidate is null) { ExceptionBase.ThrowException(404, "that is not a candidate ID .", "that candidate is not found. "); } unitOfWork.GetRepository <Tbl_Candidate>().SoftDelete(IsFoundedCandidate); unitOfWork.SaveChanges(); return("Success"); }
public string DeleteEmployer(string EmployerId) { if (EmployerId == default || string.IsNullOrWhiteSpace(EmployerId)) { ExceptionBase.ThrowException(404, "Employer ID is null or Empty. ", "Employer ID is null or Empty. "); } var IsFoundedEmployer = unitOfWork.GetRepository <Tbl_Employer>().GetSingle(e => e.Code.ToString().Equals(EmployerId)); if (IsFoundedEmployer is null) { ExceptionBase.ThrowException(404, "that is not a Employer ID .", "that Employer is not found. "); } unitOfWork.GetRepository <Tbl_Employer>().SoftDelete(IsFoundedEmployer); unitOfWork.SaveChanges(); return("Success"); }
public ResCandidateVM GetCandidate(string CandidateId) { if (CandidateId == default || string.IsNullOrWhiteSpace(CandidateId)) { ExceptionBase.ThrowException(404, "Candidate ID is null or Empty. ", "Candidate ID is null or Empty. "); } var IsFoundedCandidate = unitOfWork.GetRepository <Tbl_Candidate>().GetSingle(e => e.Code.ToString().Equals(CandidateId)); if (IsFoundedCandidate is null) { ExceptionBase.ThrowException(404, "that is not a candidate ID .", "that candidate is not found. "); } var FoundedCandidate = mapper.Map <ResCandidateVM>(IsFoundedCandidate); FoundedCandidate.ResEmployers = GetCandidateEmployers(IsFoundedCandidate.Code.ToString()); FoundedCandidate.ResSkills = GetCandidateSkills(IsFoundedCandidate.Code.ToString()); return(FoundedCandidate); }
public List <ResCandidateVM> GetCandidatesCommonSkills(string SkillId) { if (SkillId == default || string.IsNullOrWhiteSpace(SkillId)) { ExceptionBase.ThrowException(404, "Skill ID is null or Empty. ", "Skill ID is null or Empty. "); } var CandidateSkills = unitOfWork.GetRepository <Tbl_CandidateSkills>().GetAllIncluding(e => e.SkillId.ToString().Equals(SkillId)); if (CandidateSkills == default || CandidateSkills.Count <= 0) { ExceptionBase.ThrowException(404, "this Skill has no registered Candidates.", "this Skill has no registered Candidates."); } List <ResCandidateVM> resCandidateVMs = new List <ResCandidateVM>(); foreach (var item in CandidateSkills) { resCandidateVMs.Add(mapper.Map <ResCandidateVM>(unitOfWork.GetRepository <Tbl_Candidate>().GetSingle(x => x.Id.Equals(item.CandidateId)))); } return(resCandidateVMs); }
public string UpdateEmployerProfile(ReqEmployerVM req, string EmployerId) { if (req is null) { ExceptionBase.ThrowException(404, "Employer Req is empty , make sure of providing Requird Data!", "Employer Req is empty , make sure of providing Requird Data!"); } if (EmployerId == default || string.IsNullOrWhiteSpace(EmployerId)) { ExceptionBase.ThrowException(404, "Employer ID is null or Empty. ", "Employer ID is null or Empty. "); } var IsFoundedEmployer = unitOfWork.GetRepository <Tbl_Employer>().GetSingle(e => e.Code.ToString().Equals(EmployerId)); if (IsFoundedEmployer is null) { ExceptionBase.ThrowException(404, "that is not a Employer ID .", "that Employer is not found. "); } var UpdatedEmployer = mapper.Map <Tbl_Employer>(req); IsFoundedEmployer.EmployerName = UpdatedEmployer.EmployerName; unitOfWork.GetRepository <Tbl_Employer>().Update(IsFoundedEmployer); unitOfWork.SaveChanges(); return("Success"); }
public string UpdateSkillRecord(ReqSkillVM req, string SkillId) { if (req is null) { ExceptionBase.ThrowException(404, "Skill Req is empty , make sure of providing Requird Data!", "Skill Req is empty , make sure of providing Requird Data!"); } if (SkillId == default || string.IsNullOrWhiteSpace(SkillId)) { ExceptionBase.ThrowException(404, "Skill ID is null or Empty. ", "Skill ID is null or Empty. "); } var IsFoundedSkill = unitOfWork.GetRepository <Tbl_Skills>().GetSingle(e => e.Code.ToString().Equals(SkillId)); if (IsFoundedSkill is null) { ExceptionBase.ThrowException(404, "that is not a Skill ID .", "that Skill is not found. "); } var UpdatedSkill = mapper.Map <Tbl_Skills>(req); IsFoundedSkill.SkillName = UpdatedSkill.SkillName; IsFoundedSkill.Rate = UpdatedSkill.Rate; unitOfWork.GetRepository <Tbl_Skills>().Update(IsFoundedSkill); unitOfWork.SaveChanges(); return("Success"); }
public string CreateCandidate(ReqCandidateVM req) { if (req is null) { ExceptionBase.ThrowException(404, "Candidate Req is empty , make sure of providing Requird Data!", "Candidate Req is empty , make sure of providing Requird Data!"); } var IsCandidateAdded = unitOfWork.GetRepository <Tbl_Candidate>().GetSingle(e => e.FullName.Equals(req.FullName) && e.Email.Equals(req.Email)); if (!(IsCandidateAdded is null)) { return(IsCandidateAdded.Code.ToString()); } var NewCandidate = new Tbl_Candidate() { YearsofExperience = req.YearsofExperience, Email = req.Email, FullName = req.FullName, Title = req.Title, Address = req.Address, Age = req.Age, IsDeleted = false, DateOfCreate = DateTime.Now }; if (NewCandidate is null) { ExceptionBase.ThrowException(500, "Cannot Parse req object to Tbl_Candidate", "Cannot Parse req object to Tbl_Candidate"); } unitOfWork.GetRepository <Tbl_Candidate>().Add(NewCandidate); unitOfWork.SaveChanges(); if (!(req.ReqSkills is null) && req.ReqSkills.Count > 0) { List <Tbl_CandidateSkills> candidateSkills = new List <Tbl_CandidateSkills>(); foreach (var item in req.ReqSkills) { candidateSkills.Add(new Tbl_CandidateSkills() { SkillId = unitOfWork.GetRepository <Tbl_Skills>().GetSingle(e => e.Code.ToString().Equals(item.Code)).Id, CandidateId = NewCandidate.Id }); } unitOfWork.GetRepository <Tbl_CandidateSkills>().AddRing(candidateSkills.ToArray()); unitOfWork.SaveChanges(); } if (!(req.ReqEmployers is null) && req.ReqEmployers.Count > 0) { var PrevEmployer = req.ReqEmployers.Where(x => x.ReqEmployerType.Equals(ReqEmployerTypeVM.PreviousEmployer)).FirstOrDefault(); var CurrentEmployer = req.ReqEmployers.Where(x => x.ReqEmployerType.Equals(ReqEmployerTypeVM.CurrentEmployer)).FirstOrDefault(); var CandidateEmployer = new Tbl_CandidateEmployer(); if (PrevEmployer != null) { var PrevEmp = unitOfWork.GetRepository <Tbl_Employer>().GetSingle(e => e.Code.ToString().Equals(PrevEmployer.Code)); CandidateEmployer.CandidateId = IsCandidateAdded.Id; CandidateEmployer.PreviousEmployerId = PrevEmp.Id; } if (CurrentEmployer != null) { var CurrEmp = unitOfWork.GetRepository <Tbl_Employer>().GetSingle(e => e.Code.ToString().Equals(CurrentEmployer.Code)); CandidateEmployer.CurrentEmployerId = CurrEmp.Id; } unitOfWork.GetRepository <Tbl_CandidateEmployer>().Add(CandidateEmployer); unitOfWork.SaveChanges(); } return(NewCandidate.Code.ToString()); }