예제 #1
0
        public bool GetCommand(int jobId, Guid sessionId, string commentText)
        {
            ConnectionString cnString = new ConnectionString();
            IDbConnection    cn       = new OleDbConnection(cnString.GetConnString());

            IDbCommand cmd = new OleDbCommand("sp_add_comment", (OleDbConnection)cn);

            cmd.CommandType = CommandType.StoredProcedure;

            try
            {
                cn.Open();

                //Get user id
                FindUser find   = new FindUser();
                int      userId = int.Parse(find.GetUserIDBySessionId(sessionId).ToString());

                cmd.Parameters.Add(new OleDbParameter("@user_id", userId));
                cmd.Parameters.Add(new OleDbParameter("@job_id", jobId));
                cmd.Parameters.Add(new OleDbParameter("@comText", commentText));

                cmd.ExecuteNonQuery();
                return(true);
            }
            catch (OleDbException e)
            {
                Console.WriteLine(e.Message);
            }
            finally
            {
                cn.Close();
            }

            return(false);
        }
예제 #2
0
        public List <DbRecommendation> Execute(Guid sessionID)
        {
            DbRecommendation rec  = new DbRecommendation();
            FindUser         find = new FindUser();
            int userId            = int.Parse(find.GetUserIDBySessionId(sessionID).ToString());

            string          qry = "SELECT FDMUSER.firstname ||' '|| FDMUSER.lastname AS Name FROM FDMUSER JOIN RECOMMENDATIONS ON RECOMMENDATIONS.recomender_id = FDMUSER.user_id WHERE RECOMMENDATIONS.recomender_id = " + userId;
            IReadOneCommand cmd = new ReadOneCommand();

            rec.Recommender = cmd.Execute(qry);

            string                  qry2      = "SELECT FDMUSER.firstname ||' '|| FDMUSER.lastname AS Name, JOBPOST.title, JOBPOST.job_id, recommendations.reason FROM FDMUSER JOIN RECOMMENDATIONS ON RECOMMENDATIONS.recomendee_id = FDMUSER.user_id JOIN JOBPOST ON RECOMMENDATIONS.job_id = JOBPOST.job_id WHERE RECOMMENDATIONS.recomender_id = " + userId;
            IReadCommand            cmd2      = new ReadCommand();
            DataTable               dt        = cmd2.Execute(qry2);
            List <DbRecommendation> recPeople = new List <DbRecommendation>(dt.Rows.Count);

            recPeople = (from DataRow row in dt.Rows

                         select new DbRecommendation
            {
                Recommended = row["NAME"].ToString(),
                JobTitle = row["TITLE"].ToString(),
                JobID = int.Parse(row["JOB_ID"].ToString()),
                Reason = row["REASON"].ToString()
            }).ToList();

            return(recPeople);
        }
예제 #3
0
        public DbUser DisplayProfile(Guid sessionid)
        {
            UserProfile profile = new UserProfile();
            FindUser    find    = new FindUser();
            int         id      = int.Parse(find.GetUserIDBySessionId(sessionid));
            DbUser      user    = profile.GetUserDetails(id);

            return(user);
        }
예제 #4
0
        public List <DbJob> Execute(DbJob job)
        {
            FindUser find   = new FindUser();
            int      userId = int.Parse(find.GetUserIDBySessionId(sessionID).ToString());

            string qry = "SELECT JOBPOST.job_id, Stream_id, Status_id, Description, Title, DatePosted, Deadline, Company, Location FROM JobPost JOIN FAVOURITE on JOBPOST.Job_id = FAVOURITE.Job_id WHERE FAVOURITE.User_id = " +
                         userId + "ORDER BY DatePosted";
            IReadCommand cmd     = new ReadCommand();
            DataTable    dt      = cmd.Execute(qry);
            List <DbJob> favJobs = new List <DbJob>(dt.Rows.Count);


            //Get text for stream and status
            GetOneStatus status = new GetOneStatus();
            GetOneStream stream = new GetOneStream();

            favJobs = (from DataRow row in dt.Rows

                       select new DbJob
            {
                JobId = int.Parse(row["JOB_ID"].ToString()),
                Stream = stream.Read(int.Parse(row["STREAM_ID"].ToString())),
                Status = status.Read(int.Parse(row["STATUS_ID"].ToString())),
                Description = row["DESCRIPTION"].ToString(),
                Title = row["TITLE"].ToString(),
                DatePosted = DateTime.Parse(row["DATEPOSTED"].ToString()),
                Deadline = DateTime.Parse(row["DEADLINE"].ToString()),
                Company = row["COMPANY"].ToString(),
                Location = row["LOCATION"].ToString()
            }).ToList();

            for (int i = 0; i < favJobs.Count; i++)
            {
                // favJobs[i].JobId = job.JobId;
                favJobs[i].UserId = userId;
            }

            return(favJobs);
        }
예제 #5
0
        public bool GetCommand(DbJob job, List <string> skills, Guid sessionID)
        {
            //string cmdString = "sp_add_job(" + job[0].UserId + ",'" + job[0].StreamId + "','" +
            //                       job[0].StatusId + "','" + job[0].Description + "','" +
            //                       job[0].Title + "','" + job[0].Deadline + "','" +
            //                       job[0].Company + "'," + job[0].Location + ")";
            //IWriteCommand cmd = new WriteCommand();
            //cmd.SetCommand(cmdString);

            //if (cmd.Execute())
            //{
            //    return true;
            //}
            //return false;

            ConnectionString cnString = new ConnectionString();
            IDbConnection    cn       = new OleDbConnection(cnString.GetConnString());

            IDbCommand cmd = new OleDbCommand("sp_add_job", (OleDbConnection)cn);

            cmd.CommandType = CommandType.StoredProcedure;

            try
            {
                cn.Open();
                IDbTransaction tran = cn.BeginTransaction();
                cmd.Transaction = tran;

                // Get IDs
                GetStatusID statusid  = new GetStatusID();
                int         status_ID = int.Parse(statusid.Read(job.Status));

                GetStreamID streamid  = new GetStreamID();
                int         stream_ID = int.Parse(streamid.Read(job.Stream));

                FindUser find   = new FindUser();
                int      userId = int.Parse(find.GetUserIDBySessionId(sessionID).ToString());

                // Add job
                cmd.Parameters.Add(new OleDbParameter("@user_id", userId));
                cmd.Parameters.Add(new OleDbParameter("@stream_id", stream_ID));
                cmd.Parameters.Add(new OleDbParameter("@status_id", status_ID));
                cmd.Parameters.Add(new OleDbParameter("@description", job.Description));
                cmd.Parameters.Add(new OleDbParameter("@title", job.Title));
                cmd.Parameters.Add(new OleDbParameter("@deadline", job.Deadline));
                cmd.Parameters.Add(new OleDbParameter("@company", job.Company));
                cmd.Parameters.Add(new OleDbParameter("@location", job.Location));

                int affectedRows = cmd.ExecuteNonQuery();

                if (affectedRows > 0)
                {
                    // Add jobskills
                    for (int i = 0; i < skills.Count(); i++)
                    {
                        IDbCommand cmd2 = new OleDbCommand("sp_add_jobSkill", (OleDbConnection)cn);
                        cmd2.Transaction = tran;
                        cmd2.CommandType = CommandType.StoredProcedure;

                        string     formattedSkill = FormatSkill(skills[i]);
                        GetSkillId id             = new GetSkillId();
                        int        skillid        = int.Parse(id.Read(formattedSkill));
                        cmd2.Parameters.Add(new OleDbParameter("@skill_id", int.Parse(skillid.ToString())));
                        affectedRows = affectedRows + cmd2.ExecuteNonQuery();
                    }
                    tran.Commit();
                    return(true);
                }
                else
                {
                    tran.Rollback();
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
            finally
            {
                cn.Close();
            }
            return(false);
        }