//-----------------------CREATE NEW ENTRY METHODS-------------------------------------------- public void CreateNewJobPosting(TodoJobPosting posting) { posting = posting.DefaultToNone(); var coll = db.GetCollection <BsonDocument>("JobPosting"); var doc = posting.PostingToBson(); coll.InsertOne(doc); }
public TodoJobPosting SubmitResumeToJob(TodoJobPosting posting, TodoStudent stu) { TodoJobPosting newPosting = posting.DefaultToNone(); newPosting = newPosting.DefaultToExisting(posting); var oldUserScore = posting.UserAndScore; int oldLen = posting.UserAndScore.Length; string[][] newUserScores = new string[oldLen + 1][]; //transfer over existing submitals and appending the newest one for (int i = 0; i < oldLen; i++) { newUserScores[i] = new string[2]; string[] currComb = oldUserScore[i]; Console.WriteLine(currComb[0]); newUserScores[i][0] = currComb[0].ToString(); try { newUserScores[i][1] = currComb[1].ToString(); } catch (IndexOutOfRangeException e) { newUserScores[i][1] = "0"; } } newUserScores[oldLen] = new string[2]; newUserScores[oldLen][0] = stu.Email; int score = FileReader.ReadandAssignVal(stu.Resume, posting.Keywords); newUserScores[oldLen][1] = score.ToString(); newPosting.UserAndScore = newUserScores; var collection = db.GetCollection <BsonDocument>("JobPosting"); var newDoc = newPosting.PostingToBson(); var search = new BsonDocument("JobTitle", posting.JobTitle); BsonDocument found; try { found = collection.Find(search).First(); } catch (InvalidOperationException e) { found = new BsonDocument { { "JobTitle", "null" }, { "Company", "null" }, { "Location", "null" }, { "JobDescription", "null" }, { "Keywords", new BsonArray("") }, { "UserAndScore", new BsonArray() }, }; } collection.ReplaceOne(found, newDoc); return(newPosting); }