public static bool PostJob(PostedJobs postJob) { if (postJob.CategoriesID_FK == 0 || postJob.CategoryName != null) { postJob.CategoriesID_FK = GetCategoryID(postJob.CategoryName); } bool isSuccessful = false; var connectionString = ConfigurationManager.ConnectionStrings["RozgaarConnectionString"].ConnectionString; var query = "INSERT INTO " + "[dbo].[PostedJobs] (Description,Deadline,MaxCVs,NoOfPostions,EmployeeIDFK,CategoriesID_FK,Location,PostDate) " + "VALUES ('" + postJob.Description + "','" + postJob.Deadline + "'," + postJob.MaxCVs + "," + postJob.NoOfPositions + "," + postJob.EmployeeIDFK + "," + postJob.CategoriesID_FK + ",'" + postJob.Location + "','" + DateTime.Now.Date + "')"; SqlConnection connection = new SqlConnection(connectionString); SqlCommand command = null; try { connection.Open(); command = new SqlCommand(query, connection); command.ExecuteNonQuery(); isSuccessful = true; } catch (Exception e) { isSuccessful = false; } finally { command.Dispose(); connection.Close(); } if (isSuccessful) { using (System.IO.StreamWriter file = new System.IO.StreamWriter(@"D:\RozgaarRecords\PostedJobRecords.txt", true)) { file.WriteLine("EmployerID: " + postJob.EmployeeIDFK + " posted new Job. \tAt :" + DateTime.Now + "."); } } return(isSuccessful); }
public static bool PostJob(PostedJobs postjob) { return(AdminRepository.PostJob(postjob)); }
public bool PostJob(PostedJobs postjob) { return(AdminProcessor.PostJob(postjob)); }