public List <Opportunity> GetAllOpportunities()
        {
            try
            {
                List <Opportunity> listOpportunities = new List <Opportunity>();
                Opportunity        opportunity       = null;

                var read = _repositoryConnection.SearchCommand("GetAllOpportunities", parameters);

                DataTable dataTable = JsonConvert.DeserializeObject <DataTable>(read);

                foreach (DataRow row in dataTable.Rows)
                {
                    opportunity = new Opportunity();

                    opportunity.OpportunityId           = Convert.ToInt32(row["OpportunityId"]);
                    opportunity.OpportunityName         = row["OpportunityName"].ToString();
                    opportunity.OpportunityRequirements = row["OpportunityRequirements"].ToString();
                    opportunity.DesirableRequirements   = row["DesirableRequirements"].ToString();
                    opportunity.DateRegister            = Convert.ToDateTime(row["DateRegister"]);
                    opportunity.ClosingDate             = Convert.ToDateTime(row["ClosingDate"]);
                    opportunity.CancellationDate        = Convert.ToDateTime(row["CancellationDate"]);
                    opportunity.OpportunityStatus       = Convert.ToBoolean(row["OpportunityStatus"]);

                    opportunity.Career          = new Career();
                    opportunity.Career.CareerId = Convert.ToInt32(row["CareerId"]);
                    opportunity.Career          = _careerRepository.GetCareerById(opportunity.Career.CareerId);

                    opportunity.Service           = new Service();
                    opportunity.Service.ServiceId = Convert.ToInt32(row["ServiceId"]);
                    opportunity.Service           = _serviceRepository.GetServiceById(opportunity.Service.ServiceId);

                    opportunity.ProfessionalLevel = new ProfessionalLevel();
                    opportunity.ProfessionalLevel.ProfessionalLevelId = Convert.ToInt32(row["ProfessionalLevelId"]);
                    opportunity.ProfessionalLevel = _professionalLevelRepository.GetProfessionalLevelById(opportunity.ProfessionalLevel.ProfessionalLevelId);

                    opportunity.OpportunityType = new OpportunityType();
                    opportunity.OpportunityType.OpportunityTypeId = Convert.ToInt32(row["OpportunityTypeId"]);
                    opportunity.OpportunityType = _opportunityTypeRepository.GetOpportunityTypeById(opportunity.OpportunityType.OpportunityTypeId);

                    listOpportunities.Add(opportunity);
                }
                return(listOpportunities);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Beispiel #2
0
        public List <VacationOpportunity> GetAllVacationOpportunities()
        {
            try
            {
                List <VacationOpportunity> listVacationOpportunities = new List <VacationOpportunity>();
                VacationOpportunity        vacationOpportunity       = null;

                var read = _repositoryConnection.SearchCommand("GetAllVacationOpportunities", parameters);

                DataTable dataTable = JsonConvert.DeserializeObject <DataTable>(read);

                foreach (DataRow row in dataTable.Rows)
                {
                    vacationOpportunity = new VacationOpportunity();

                    vacationOpportunity.VacationOpportunityId     = Convert.ToInt32(row["VacationOpportunityId"]);
                    vacationOpportunity.VacationOpeningNumber     = row["VacationOpeningNumber"].ToString();
                    vacationOpportunity.VacationOpeningDate       = Convert.ToDateTime(row["VacationOpeningDate"]);
                    vacationOpportunity.VacationOfferLetterDate   = Convert.ToDateTime(row["VacationOfferLetterDate"]);
                    vacationOpportunity.VacationLeader            = row["VacationLeader"].ToString();
                    vacationOpportunity.VacationCancellationDate  = Convert.ToDateTime(row["VacationCancellationDate"]);
                    vacationOpportunity.VacationOpportunityStatus = Convert.ToBoolean(row["VacationOpportunityStatus"]);

                    vacationOpportunity.Career          = new Career();
                    vacationOpportunity.Career.CareerId = Convert.ToInt32(row["CareerId"]);
                    vacationOpportunity.Career          = _careerRepository.GetCareerById(vacationOpportunity.Career.CareerId);

                    vacationOpportunity.ProfessionalLevel = new ProfessionalLevel();
                    vacationOpportunity.ProfessionalLevel.ProfessionalLevelId = Convert.ToInt32(row["ProfessionalLevelId"]);
                    vacationOpportunity.ProfessionalLevel = _professionalLevelRepository.GetProfessionalLevelById(vacationOpportunity.ProfessionalLevel.ProfessionalLevelId);

                    vacationOpportunity.OpportunityType = new OpportunityType();
                    vacationOpportunity.OpportunityType.OpportunityTypeId = Convert.ToInt32(row["OpportunityTypeId"]);
                    vacationOpportunity.OpportunityType = _opportunityTypeRepository.GetOpportunityTypeById(vacationOpportunity.OpportunityType.OpportunityTypeId);

                    listVacationOpportunities.Add(vacationOpportunity);
                }
                return(listVacationOpportunities);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }