Пример #1
0
        /// <summary>
        /// int employeeID, int employerID, string text, string sender, string title
        /// </summary>
        public object sendMessage()
        {
            try
            {
                var headers = Request.Headers;

                int    employeeID = (headers.Contains("employeeID")) ? Int32.Parse(headers.GetValues("employeeID").First()) : -1;
                int    employerID = (headers.Contains("employerID")) ? Int32.Parse(headers.GetValues("employerID").First()) : -1;
                int    vacancyID  = (headers.Contains("vacancyID")) ? Int32.Parse(headers.GetValues("vacancyID").First()) : -1;
                string text       = (headers.Contains("text")) ? headers.GetValues("text").First() : null;
                string sender     = (headers.Contains("sender")) ? headers.GetValues("sender").First() : null;
                string title      = (headers.Contains("title")) ? headers.GetValues("title").First() : null;

                WorQitEntities wqdb = new WorQitEntities();
                wqdb.Configuration.ProxyCreationEnabled = false;
                Message msg = new Message()
                {
                    employeeID = employeeID,
                    employerID = employerID,
                    sender     = sender,
                    text       = text,
                    title      = title,
                    date       = DateTime.Now,
                    vacancyID  = vacancyID,
                    read       = false
                };
                wqdb.Messages.Add(msg);
                wqdb.SaveChanges();
                return(Json(new { Result = "successful" }));
            }
            catch (Exception ex)
            {
                return(Json(new { Result = "failed", Error = ex }));
            }
        }
        /// <summary>
        /// gets all vacancyemployee objects that have been liked
        /// </summary>
        /// <param name="ID">employer id</param>
        /// <returns></returns>
        public List <VacancyEmployee> getAllLikes(int ID)
        {
            try
            {
                List <Vacancy> valist = getVacancies(ID);
                WorQitEntities wqdb   = new WorQitEntities();
                wqdb.Configuration.ProxyCreationEnabled = false;
                List <VacancyEmployee> vaemps = new List <VacancyEmployee>();
                foreach (Vacancy va in valist)
                {
                    var lists = new List <VacancyEmployee>(from VacancyEmployee in wqdb.VacancyEmployees
                                                           where VacancyEmployee.vacancyID == va.ID && VacancyEmployee.rating == 1
                                                           select VacancyEmployee).ToList();
                    foreach (VacancyEmployee ls in lists)
                    {
                        vaemps.Add(ls);
                    }
                }



                return(vaemps);
            }
            catch (Exception ex)
            {
                return(null);
            }
        }
        /// <summary>
        /// sets rating of vacancyemployee (like / dislike)
        /// </summary>
        /// <returns></returns>
        public object setRating()
        {
            try
            {
                var headers    = Request.Headers;
                int employeeID = (headers.Contains("employeeID")) ? Int32.Parse(headers.GetValues("employeeID").First()) : -1;
                int vacancyID  = (headers.Contains("vacancyID")) ? Int32.Parse(headers.GetValues("vacancyID").First()) : -1;
                int rating     = (headers.Contains("rating")) ? Int32.Parse(headers.GetValues("rating").First()) : -99;


                WorQitEntities wqdb = new WorQitEntities();
                wqdb.Configuration.ProxyCreationEnabled = false;
                VacancyEmployee vac = (from VacancyEmployee in wqdb.VacancyEmployees
                                       where VacancyEmployee.employeeID == employeeID && VacancyEmployee.vacancyID == vacancyID
                                       select VacancyEmployee).First();
                vac.rating = rating;

                wqdb.SaveChanges();
                return(Json(new { Result = "successful" }));
            }
            catch (Exception ex)
            {
                return(Json(new { Result = "failed", Error = ex }));
            }
        }
Пример #4
0
        /// <summary>
        /// Log in method for websie
        /// </summary>
        /// <param name="userName"></param>

        /// <returns>employee object</returns>
        public object logInWebsite()
        {
            try
            {
                var    headers  = Request.Headers;
                string userName = (headers.Contains("userName")) ? headers.GetValues("userName").First() : null;

                WorQitEntities wqdb = new WorQitEntities();
                wqdb.Configuration.ProxyCreationEnabled = false;
                var values = from Employer in wqdb.Employers
                             where Employer.username == userName
                             select Employer;
                var valuelist = values.ToList <Employer>();
                if (valuelist.Exists(x => x.username == userName))
                {
                    return(Json(new { Result = "successful", User = valuelist }));
                }
                else
                {
                    return(Json(new { Result = "failed", Error = "Deze username bestaat niet" }));
                }
            }
            catch (System.Exception ex)
            {
                return(Json(new { Result = "failed", Error = ex }));
            }
        }
        /// <summary>
        /// Get all results from VacancyEmployees
        /// </summary>
        /// <returns>vacancyEmployees list</returns>
        public List <VacancyEmployee> getAllVacancyEmployees()
        {
            WorQitEntities wqdb = new WorQitEntities();

            wqdb.Configuration.ProxyCreationEnabled = false;
            return(wqdb.VacancyEmployees.ToList());
        }
        public object getVacanciesByScore(int ID, int salary = 0, int hours = 0)
        {
            try
            {
                WorQitEntities wqdb = new WorQitEntities();
                wqdb.Configuration.ProxyCreationEnabled = false;

                var vacancies = new List <Vacancy>(from VacancyEmployee in wqdb.VacancyEmployees
                                                   where VacancyEmployee.employeeID == ID && VacancyEmployee.rating == 0
                                                   orderby VacancyEmployee.matchingValue descending
                                                   select VacancyEmployee.Vacancy).ToList();


                if (salary != 0)
                {
                    vacancies = vacancies.Where(v => v.salary >= salary).ToList();
                }
                if (hours != 0)
                {
                    vacancies = vacancies.Where(v => v.hours >= hours).ToList();
                }



                return(Json(new { Result = "successful", Vacancys = vacancies }));
            }
            catch (Exception ex)
            {
                return(Json(new { Result = "failed", Error = ex }));
            }
        }
Пример #7
0
 /// <summary>
 /// get last messages exchanged between employer and employee
 /// </summary>
 /// <param name="employerID">employer ID</param>
 /// <param name="employeeID">employee ID</param>
 /// <param name="count">number of messages (count == -1 => returns all messages)</param>
 /// <returns></returns>
 public object getLast(int employerID, int employeeID, int count)
 {
     try
     {
         WorQitEntities wqdb = new WorQitEntities();
         wqdb.Configuration.ProxyCreationEnabled = false;
         if (count > 0)
         {
             List <Message> msg = (from Message in wqdb.Messages
                                   where Message.employerID == employerID && Message.employeeID == employeeID
                                   select Message).OrderByDescending(x => x.date).Take <Message>(count).ToList <Message>();
             return(Json(new { Result = "successful", Messages = msg }));
         }
         else if (count == -1)
         {
             List <Message> msg = (from Message in wqdb.Messages
                                   where Message.employerID == employerID && Message.employeeID == employeeID
                                   select Message).OrderByDescending(x => x.date).ToList <Message>();
             return(Json(new { Result = "successful", Messages = msg }));
         }
         else
         {
             return(Json(new { Result = "failed", Error = "Wrong count number" }));
         }
     }
     catch (Exception ex)
     {
         return(Json(new { Result = "failed", Error = ex }));
     }
 }
Пример #8
0
        /// <summary>
        /// adds employer. Headers: username, email, password
        /// </summary>
        /// <returns></returns>
        public object addEmployer()
        {
            try
            {
                var headers = Request.Headers;

                string         username = HttpUtility.UrlDecode((headers.Contains("username")) ? headers.GetValues("username").First() : null);
                string         email    = HttpUtility.UrlDecode((headers.Contains("email")) ? headers.GetValues("email").First() : null);
                string         password = HttpUtility.UrlDecode((headers.Contains("password")) ? headers.GetValues("password").First() : null);
                WorQitEntities wqdb     = new WorQitEntities();
                wqdb.Configuration.ProxyCreationEnabled = false;
                Employer usernameCheck = null;
                Employer emailCheck    = null;
                try
                {
                    usernameCheck = wqdb.Employers.First(x => x.username == username);
                    emailCheck    = wqdb.Employers.First(x => x.email == email);
                }
                catch (Exception ex)
                {
                }
                if (usernameCheck == null && emailCheck == null)
                {
                    Employer employer = new Employer()
                    {
                        username = username,
                        email    = email,
                        password = password
                    };
                    wqdb.Employers.Add(employer);
                    wqdb.SaveChanges();
                    return(Json(new { Result = "successful", employer = employer }));
                }
                else
                {
                    string errorString = "";
                    if (usernameCheck != null)
                    {
                        errorString += "De gebruikersnaam bestaat al";
                    }
                    if (emailCheck != null)
                    {
                        errorString += "dit email adres wordt al gebruikt";
                    }
                    return(Json(new { Result = "failed", Error = errorString }));
                }
            }
            catch (System.Exception ex)
            {
                Console.WriteLine(ex);
                return(Json(new { Result = "failed", Error = ex }));
            }
        }
Пример #9
0
        /// <summary>
        /// edit employer
        /// </summary>
        /// <returns></returns>
        public object editEmployer()
        {
            try
            {
                var    headers       = Request.Headers;
                int    ID            = (headers.Contains("ID")) ? Int32.Parse(headers.GetValues("ID").First()) : -1;
                string name          = (headers.Contains("name")) ? headers.GetValues("name").First() : null;
                string description   = (headers.Contains("description")) ? headers.GetValues("description").First() : null;
                int    employeeCount = (headers.Contains("employeeCount")) ? Int32.Parse(headers.GetValues("employeeCount").First()) : -1;

                string location = (headers.Contains("location")) ? headers.GetValues("location").First() : null;

                string password    = (headers.Contains("password")) ? headers.GetValues("password").First() : null;
                string oldPassword = (headers.Contains("oldPassword")) ? headers.GetValues("oldPassword").First() : null;
                string email       = (headers.Contains("email")) ? headers.GetValues("email").First() : null;

                WorQitEntities wqdb = new WorQitEntities();
                wqdb.Configuration.ProxyCreationEnabled = false;

                Employer emp = wqdb.Employers.First(x => x.ID == ID);


                emp.name          = (name != null) ? name : emp.name;
                emp.description   = (description != null) ? description : emp.description;
                emp.employeeCount = (employeeCount != -1) ? employeeCount : emp.employeeCount;


                emp.location = (location != null) ? location : emp.location;


                if (password != null && emp.password == oldPassword)
                {
                    emp.password = password;
                }
                else if (emp.password != oldPassword)
                {
                    return(Json(new { Result = "failed", Error = "Verkeerd oud wachtwoord wachtwoord ingevoerd, uw wijzigingen zijn niet opgeslagen" }));
                }
                emp.email = (email != null) ? email : emp.email;


                wqdb.SaveChanges();
                return(Json(new { Result = "successful" }));
            }
            catch (System.Exception ex)
            {
                return(Json(new { Result = "failed", Error = ex }));
            }
        }
 /// <summary>
 /// deletes vacancy
 /// </summary>
 /// <param name="ID">vacancy id</param>
 /// <returns></returns>
 public object deleteVacancy(int ID)
 {
     try
     {
         WorQitEntities wqdb = new WorQitEntities();
         wqdb.Configuration.ProxyCreationEnabled = false;
         wqdb.Vacancies.Remove(wqdb.Vacancies.First(x => x.ID == ID));
         wqdb.SaveChanges();
         return(Json(new { Result = "successful" }));
     }
     catch (System.Exception ex)
     {
         return(Json(new { Result = "failed", Error = ex }));
     }
 }
        /// <summary>
        /// Get vacancies from employer
        /// </summary>
        /// <param name="ID"></param>
        /// <returns>vacancy list</returns>
        public List <Vacancy> getVacancies(int ID)
        {
            WorQitEntities wqdb = new WorQitEntities();

            wqdb.Configuration.ProxyCreationEnabled = false;
            List <Vacancy> list = new List <Vacancy>();

            foreach (var item in wqdb.Vacancies)
            {
                if (item.employerID == ID)
                {
                    list.Add(item);
                }
            }
            return(list);
        }
Пример #12
0
 /// <summary>
 /// gets overview of employee messages
 /// </summary>
 /// <param name="ID"> employee id</param>
 /// <returns></returns>
 public object getOverviewEmployee(int ID)
 {
     try
     {
         WorQitEntities wqdb = new WorQitEntities();
         wqdb.Configuration.ProxyCreationEnabled = false;
         List <Message> msg = (from Message in wqdb.Messages
                               where Message.employeeID == ID
                               orderby Message.date descending
                               select Message).ToList <Message>();
         return(Json(new { Result = "successful", Messages = msg }));
     }
     catch (Exception ex)
     {
         return(Json(new { Result = "failed", Error = ex }));
     }
 }
Пример #13
0
        /// <summary>
        /// gets message by message ID
        /// </summary>
        /// <param name="ID">message ID</param>
        /// <returns></returns>
        public object getMessage(int ID)
        {
            try
            {
                WorQitEntities wqdb = new WorQitEntities();
                wqdb.Configuration.ProxyCreationEnabled = false;

                Message msg = (from Message in wqdb.Messages
                               where Message.ID == ID
                               select Message).First();
                return(Json(new { Result = "successful", Messages = msg }));
            }
            catch (Exception ex)
            {
                return(Json(new { Result = "failed", Error = ex }));
            }
        }
        /// <summary>
        /// Get all candidates on a vacancy
        /// </summary>
        /// <param>vacancyID</param>
        /// <returns>vacancy list</returns>
        public object getCandidates(int ID)
        {
            try
            {
                WorQitEntities wqdb = new WorQitEntities();
                wqdb.Configuration.ProxyCreationEnabled = false;

                var vaEmps = new List <Employee>(from VacancyEmployee in wqdb.VacancyEmployees
                                                 where VacancyEmployee.vacancyID == ID && VacancyEmployee.rating == 1
                                                 select VacancyEmployee.Employee).ToList();


                return(Json(new { Result = "successful", Users = vaEmps }));
            }
            catch (Exception ex)
            {
                return(Json(new { Result = "failed", Error = ex }));
            }
        }
        /// <summary>
        /// update seen to true, the like on the vacancy has been seen by the employer
        /// </summary>
        /// <param name="ID">matchID</param>
        public object reactionSeen(int ID)
        {
            try
            {
                WorQitEntities wqdb = new WorQitEntities();
                wqdb.Configuration.ProxyCreationEnabled = false;
                VacancyEmployee vaemp = (from VacancyEmployee in wqdb.VacancyEmployees
                                         where VacancyEmployee.matchID == ID
                                         select VacancyEmployee).First();
                vaemp.seen = true;

                wqdb.SaveChanges();
                return(Json(new { Result = "successful" }));
            }
            catch (Exception ex)
            {
                return(Json(new { Result = "failed", Error = ex }));
            }
        }
Пример #16
0
 /// <summary>
 /// deletes employer
 /// </summary>
 /// <returns></returns>
 public object deleteEmployer()
 {
     try
     {
         var            headers  = Request.Headers;
         int            ID       = (headers.Contains("ID")) ? Int32.Parse(headers.GetValues("ID").First()) : -1;
         string         password = (headers.Contains("password")) ? headers.GetValues("password").First() : null;
         WorQitEntities wqdb     = new WorQitEntities();
         wqdb.Configuration.ProxyCreationEnabled = false;
         Employer passwordCheck = null;
         try
         {
             passwordCheck = wqdb.Employers.First(x => x.ID == ID);
         }
         catch (Exception ex) { }
         if (passwordCheck != null)
         {
             if (passwordCheck.password == password)
             {
                 wqdb.Employers.Remove(wqdb.Employers.First(x => x.ID == ID));
                 wqdb.SaveChanges();
                 return(Json(new { Result = "successful" }));
             }
             else
             {
                 return(Json(new { Result = "failed", Error = "Verkeerd wachtwoord" }));
             }
         }
         else
         {
             return(Json(new { Result = "failed", Error = "Deze user bestaat niet" }));
         }
     }
     catch (System.Exception ex)
     {
         return(Json(new { Result = "failed", Error = ex }));
     }
 }
 /// <summary>
 /// Create new Vacancy
 /// </summary>
 /// <param name="employerID"></param>
 /// <param name="function"></param>
 /// <param name="description"></param>
 /// <param name="salary"></param>
 /// <param name="hours"></param>
 /// <param name="requirements"></param>
 /// <returns>json sucessfull or failed with error</returns>
 public object addVacancy(int employerID, string function, string description, int salary, int hours, string requirements)
 {
     try
     {
         WorQitEntities wqdb = new WorQitEntities();
         wqdb.Configuration.ProxyCreationEnabled = false;
         Vacancy vacancy = new Vacancy()
         {
             employerID   = employerID,
             jobfunction  = function,
             description  = description,
             salary       = salary,
             hours        = hours,
             requirements = requirements
         };
         wqdb.Vacancies.Add(vacancy);
         wqdb.SaveChanges();
         return(Json(new { Result = "successful" }));
     }
     catch (System.Exception ex)
     {
         return(Json(new { Result = "failed", Error = ex }));
     }
 }
        /// <summary>
        /// matching algorythm
        /// </summary>
        /// <param name="employeeID"></param>
        /// <param name="vacancyID"></param>
        private void setMatchScore(int employeeID, int vacancyID)
        {
            int            bedrijfsScore = 0;
            WorQitEntities wqdb          = new WorQitEntities();

            wqdb.Configuration.ProxyCreationEnabled = false;
            Vacancy        vacancy   = wqdb.Vacancies.Where(x => x.ID == vacancyID).First();
            Employee       employee  = wqdb.Employees.Where(x => x.ID == employeeID).First();
            List <Vacancy> vacancies = wqdb.Vacancies.Where(x => x.employerID == vacancy.employerID).ToList();

            foreach (Vacancy v in vacancies)
            {
                List <VacancyEmployee> vList = wqdb.VacancyEmployees.Where(x => x.vacancyID == v.ID).ToList();
                foreach (VacancyEmployee ve in vList)
                {
                    bedrijfsScore = ve.rating ?? default(int);
                }

                if (bedrijfsScore > -5)
                {
                    int matchScore = 0;
                    if (employee.industry != null)
                    {
                        if (v.branche.Contains(employee.industry))
                        {
                            matchScore = matchScore + 10;
                        }
                    }
                    if (employee.positions != null)
                    {
                        if (v.jobfunction.Contains(employee.positions))
                        {
                            matchScore = matchScore + 5;
                        }
                    }
                    if (employee.skills != null)
                    {
                        if (v.requirements.Contains(employee.skills))
                        {
                            matchScore = matchScore + 7;
                        }
                    }
                    if (employee.educations != null)
                    {
                        if (v.educations.Contains(employee.educations))
                        {
                            matchScore = matchScore + 9;
                        }
                    }


                    var ve = wqdb.VacancyEmployees.Where(x => x.employeeID == employee.ID).Where(x => x.vacancyID == v.ID).FirstOrDefault();
                    if (ve == null)
                    {
                        VacancyEmployee newVE = new VacancyEmployee()
                        {
                            employeeID = employee.ID, vacancyID = v.ID, matchingValue = matchScore, rating = 0
                        };
                        wqdb.VacancyEmployees.Add(newVE);
                        wqdb.SaveChanges();
                    }
                    else
                    {
                        ve.matchingValue = matchScore;
                    }
                }
            }
        }
        /// <summary>
        /// edits employee
        /// </summary>
        /// <returns></returns>
        public object editEmployee()
        {
            try
            {
                var headers = Request.Headers;
                int ID      = (headers.Contains("ID")) ? Int32.Parse(headers.GetValues("ID").First()) : -1;

                WorQitEntities wqdb = new WorQitEntities();
                wqdb.Configuration.ProxyCreationEnabled = false;
                Employee emp = wqdb.Employees.First(x => x.ID == ID);


                string firstName = (headers.Contains("firstName")) ? headers.GetValues("firstName").First() : null;
                string lastName  = (headers.Contains("lastName")) ? headers.GetValues("lastName").First() : null;
                string industry  = (headers.Contains("industry")) ? headers.GetValues("industry").First() : null;

                string positions  = (headers.Contains("positions")) ? headers.GetValues("positions").First() : null;
                string interests  = (headers.Contains("interests")) ? headers.GetValues("interests").First() : null;
                string languages  = (headers.Contains("languages")) ? headers.GetValues("languages").First() : null;
                string skills     = (headers.Contains("skills")) ? headers.GetValues("skills").First() : null;
                string educations = (headers.Contains("educations")) ? headers.GetValues("educations").First() : null;
                string experience = (headers.Contains("experience")) ? headers.GetValues("experience").First() : null; // werkervaring


                if (headers.Contains("dob") && headers.GetValues("dob").First() != null)
                {
                    DateTime?dob = DateTime.Parse(headers.GetValues("dob").First().ToString());
                    //return Json(new { Result = "lolz dob", troep = dob });
                    emp.dob = (dob != null) ? dob : emp.dob;
                }
                string location = (headers.Contains("city")) ? headers.GetValues("city").First() : null;
                if (headers.Contains("hours"))
                {
                    int?hours = int.Parse(headers.GetValues("hours").First());
                    emp.hours = (hours != null) ? hours : emp.hours;
                }
                string password    = (headers.Contains("password")) ? headers.GetValues("password").First() : null;
                string oldPassword = (headers.Contains("oldPassword")) ? headers.GetValues("oldPassword").First() : null;
                string email       = (headers.Contains("email")) ? headers.GetValues("email").First() : null;



                emp.firstName = (firstName != null) ? firstName : emp.firstName;
                emp.lastName  = (lastName != null) ? lastName : emp.lastName;
                emp.industry  = (industry != null) ? industry : emp.industry;

                emp.positions  = (positions != null) ? positions : emp.positions;
                emp.interests  = (interests != null) ? interests : emp.interests;
                emp.languages  = (languages != null) ? languages : emp.languages;
                emp.skills     = (skills != null) ? skills : emp.skills;
                emp.educations = (educations != null) ? educations : emp.educations;

                emp.experience = (experience != null) ? experience : emp.experience;
                emp.location   = (location != null) ? location : emp.location;

                emp.educations = (educations != null) ? educations : emp.educations;


                if (password != null && emp.password == oldPassword)
                {
                    emp.password = password;
                }
                else if (emp.password != oldPassword)
                {
                    return(Json(new { Result = "failed", Error = "Verkeerd oud wachtwoord wachtwoord ingevoerd, uw wijzigingen zijn niet opgeslagen" }));
                }
                emp.email = (email != null) ? email : emp.email;


                wqdb.SaveChanges();
                return(Json(new { Result = "successful", User = emp }));
            }
            catch (System.Exception ex)
            {
                return(Json(new { Result = "failed", Error = ex }));
            }
        }