Ejemplo n.º 1
0
        public IActionResult CreateNewStudent(string Name,
                                              string PhoneNumber,
                                              string Email,
                                              string Password,
                                              string UserType,
                                              string[] Resume)
        {
            //Console.WriteLine("Before building student");
            string name        = Name;
            string phoneNumber = PhoneNumber;
            string email       = Email;
            string password    = Password;
            string userType    = UserType;

            string[] res = Resume;        // new string[] { "ect" };// Keywords;
            Console.WriteLine("Before building student");
            var student = new TodoStudent
            {
                Name        = name,
                PhoneNumber = phoneNumber,
                Email       = email,
                Password    = password,
                UserType    = userType,
                Resume      = res
            };
            DatabaseInteraction dbObj = new DatabaseInteraction();

            Console.WriteLine("Before CreatNewCandidate");
            dbObj.CreateNewCandidate(student);
            return(new ObjectResult(student));
        }
Ejemplo n.º 2
0
        public IActionResult GetByEmail(string Email)
        {
            DatabaseInteraction dbObj = new DatabaseInteraction();

            TodoStudent user = dbObj.GetUserByEmail(Email);

            return(new ObjectResult(user));
        }
Ejemplo n.º 3
0
        public void CreateNewCandidate(TodoStudent stu)
        {
            stu.DefaultToNone();
            var collection = db.GetCollection <BsonDocument>("candidate");

            var doc = stu.UserToBson();

            collection.InsertOne(doc);
        }
Ejemplo n.º 4
0
        public IActionResult Create([FromBody] TodoStudent item)
        {
            if (item == null)
            {
                return(BadRequest());
            }

            _context.TodoItems.Add(item);
            _context.SaveChanges();

            return(CreatedAtRoute("GetTodo", new { id = item.Id }, item));
        }
Ejemplo n.º 5
0
        public IActionResult AddResumeToPosting(string Email,
                                                string JobTitle
                                                )
        {
            DatabaseInteraction dbObj = new DatabaseInteraction();

            TodoJobPosting posting = dbObj.GetPostingByName(JobTitle);
            TodoStudent    stu     = dbObj.GetUserByEmail(Email);

            dbObj.SubmitResumeToJob(posting, stu);

            return(new ObjectResult(posting));
        }
Ejemplo n.º 6
0
        //-------------------------------------------UPDATE METHODS-------------------------------------------------------------------

        public TodoStudent UpdateUserInfo(string email, TodoStudent newStu)
        {
            TodoStudent stu = GetUserByEmail(email);

            newStu = newStu.DefaultToExisting(stu);
            var collection = db.GetCollection <BsonDocument>("candidate");
            var doc        = newStu.UserToBson();
            var search     = new BsonDocument("Email", email);

            BsonDocument found;

            found = collection.Find(search).First();
            collection.ReplaceOne(found, doc);
            return(newStu);
        }
Ejemplo n.º 7
0
        public IActionResult Update(long id, [FromBody] TodoStudent item)
        {
            if (item == null || item.Id != id)
            {
                return(BadRequest());
            }

            var todo = _context.TodoItems.FirstOrDefault(t => t.Id == id);

            if (todo == null)
            {
                return(NotFound());
            }

            todo.Name                           = item.Name;
            todo.Address                        = item.Address;
            todo.Email                          = item.Email;
            todo.PhoneNumber                    = item.PhoneNumber;
            todo.BSEducationSchool              = item.BSEducationSchool;
            todo.BSEducationTitle               = item.BSEducationTitle;
            todo.MSEducationSchool              = item.MSEducationSchool;
            todo.MSEducationTitle               = item.MSEducationTitle;
            todo.PHdEducationSchool             = item.PHdEducationSchool;
            todo.PHdEducationTitle              = item.PHdEducationTitle;
            todo.WorkExperienceCompanyNameOne   = item.WorkExperienceCompanyNameOne;
            todo.WorkExperienceTitleOne         = item.WorkExperienceTitleOne;
            todo.WorkExperienceCompanyNameTwo   = item.WorkExperienceCompanyNameTwo;
            todo.WorkExperienceTitleTwo         = item.WorkExperienceTitleTwo;
            todo.WorkExperienceCompanyNameThree = item.WorkExperienceCompanyNameThree;
            todo.WorkExperienceTitleThree       = item.WorkExperienceTitleThree;
            todo.ExtraCurricularActivitiesOne   = item.ExtraCurricularActivitiesOne;
            todo.ExtraCurricularActivitiesTwo   = item.ExtraCurricularActivitiesTwo;

            _context.TodoItems.Update(todo);
            _context.SaveChanges();
            return(new NoContentResult());
        }
Ejemplo n.º 8
0
        // [HttpPost("UpdateUser")]
        public IActionResult Update(string Email,
                                    string newName,
                                    string newPhoneNumber,
                                    string newEmail,
                                    string newPassword,
                                    string newUserType,
                                    string[] newResume)
        {
            //Get the user via email and then update
            DatabaseInteraction dbObj = new DatabaseInteraction();
            var student = new TodoStudent
            {
                Name        = newName,
                PhoneNumber = newPhoneNumber,
                Email       = newEmail,
                Password    = newPassword,
                UserType    = newUserType,
                Resume      = newResume
            };

            dbObj.UpdateUserInfo(Email, student);

            return(new NoContentResult());
        }
Ejemplo n.º 9
0
        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);
        }
Ejemplo n.º 10
0
        public IActionResult createStudentFromResume(string Name, string Address, string Email, string PhoneNumber, string BSEducationSchool, string BSEducationTitle, string MSEducationSchool, string MSEducationTitle, string PHdEducationSchool, string PHdEducationTitle, string WorkExperienceCompanyNameOne, string WorkExperienceTitleOne, string WorkExperienceCompanyNameTwo, string WorkExperienceTitleTwo, string WorkExperienceCompanyNameThree, string WorkExperienceTitleThree, string ExtraCurricularActivitiesOne, string ExtraCurricularActivitiesTwo)
        {
            if (Name == null || Name.Equals(""))
            {
                return(BadRequest());
            }

            if (Address == null || Address.Equals(""))
            {
                return(BadRequest());
            }

            if (Email == null || Email.Equals(""))
            {
                return(BadRequest());
            }

            if (PhoneNumber == null || PhoneNumber.Equals(""))
            {
                return(BadRequest());
            }

            string name                           = Name;
            string address                        = Address;
            string email                          = Email;
            string phoneNumber                    = PhoneNumber;
            string bsEducationSchool              = BSEducationSchool;
            string bsEducationTitle               = BSEducationTitle;
            string msEducationSchool              = MSEducationSchool;
            string msEducationTitle               = MSEducationTitle;
            string phdEducationSchool             = PHdEducationSchool;
            string phdEducationTitle              = PHdEducationTitle;
            string workExperienceCompanyNameOne   = WorkExperienceCompanyNameOne;
            string workExperienceTitleOne         = WorkExperienceTitleOne;
            string workExperienceCompanyNameTwo   = WorkExperienceCompanyNameTwo;
            string workExperienceTitleTwo         = WorkExperienceTitleTwo;
            string workExperienceCompanyNameThree = WorkExperienceCompanyNameThree;
            string workExperienceTitleThree       = WorkExperienceTitleThree;
            string extraCurricularActivitiesOne   = ExtraCurricularActivitiesOne;
            string extraCurricularActivitiesTwo   = ExtraCurricularActivitiesTwo;


            var student = new TodoStudent {
                Name                           = name,
                Address                        = address,
                Email                          = email,
                PhoneNumber                    = phoneNumber,
                BSEducationSchool              = bsEducationSchool,
                BSEducationTitle               = bsEducationTitle,
                MSEducationSchool              = msEducationSchool,
                MSEducationTitle               = msEducationTitle,
                PHdEducationSchool             = phdEducationSchool,
                PHdEducationTitle              = phdEducationTitle,
                WorkExperienceCompanyNameOne   = workExperienceCompanyNameOne,
                WorkExperienceTitleOne         = workExperienceTitleOne,
                WorkExperienceCompanyNameTwo   = workExperienceCompanyNameTwo,
                WorkExperienceTitleTwo         = workExperienceTitleTwo,
                WorkExperienceCompanyNameThree = workExperienceCompanyNameThree,
                WorkExperienceTitleThree       = workExperienceTitleThree,
                ExtraCurricularActivitiesOne   = extraCurricularActivitiesOne,
                ExtraCurricularActivitiesTwo   = extraCurricularActivitiesTwo
            };

            _context.TodoItems.Add(student);
            _context.SaveChanges();

            return(CreatedAtRoute("GetTodo", new { id = student.Id }, student));
        }