Exemplo n.º 1
0
        protected void btnAdd_Click(object sender, EventArgs e)
        {
            lblSuccess.Text = "";
            job             = (DbJob)Session["Job"];
            int  jobId     = job.JobId;
            Guid sessionId = (Guid)Session["sessionId"];

            if (service.AddComment(jobId, sessionId, txtComment.Text) == true)
            {
                lblSuccess.Text   = "Your comment has been successfully added";
                lblError.Text     = "";
                pnlAddCom.Visible = false;
                txtComment.Text   = "";
                dt = ToDataTable <DbComments>(service.ViewComments(job.JobId).ToList());
                dt.Columns.Remove("CommentId");
                dt.Columns.Remove("JobId");

                gvComments.DataSource = dt;
                gvComments.DataBind();
            }
            else
            {
                lblError.Text = "Something went wrong! Please try again";
            }
        }
Exemplo n.º 2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            job                 = (DbJob)Session["Job"];
            lblStatus.Text      = job.Status;
            lblStream.Text      = job.Stream;
            lblLocation.Text    = job.Location;
            lblCompany.Text     = job.Company;
            lblTitle.Text       = job.Title;
            lblDescription.Text = job.Description;
            lblDateposted.Text  = job.DatePosted.ToString();
            lblDeadline.Text    = job.Deadline.ToString();
            lblAccMan.Text      = (string)Session["AccMan"];
            blSkills.DataSource = Session["Skills"];
            blSkills.DataBind();
            lblSuccess.Text = "";
            lblError.Text   = "";

            dt = ToDataTable <DbComments>(service.ViewComments(job.JobId).ToList());
            dt.Columns.Remove("CommentId");
            dt.Columns.Remove("JobId");

            gvComments.DataSource = dt;
            gvComments.DataBind();

            if (service.ViewComments(job.JobId).ToList().Count == 0)
            {
                lblSuccess.Text = "There are currently no comments for this post";
            }
        }
        /// <summary>
        /// Gets all notifications stored in a collection as an 'object'.
        /// These notifications must NOT be mistaken as the Model class Notification.
        /// The objects can be of either Job or Project
        ///
        /// Examples on how to use this list:
        /// List<object> notifications = GetNotificationList();
        /// for (n in notifications) {
        ///     if (n is Job) {
        ///         // DO spesific Job code
        ///         Job job = (Job)n;
        ///         string date = job.expiryDate; // Will work
        ///     }
        ///     else if (n is Project) {
        ///         // Do spesific Project  code.
        ///         Project p = (Project)n;
        ///     }
        /// }
        /// </summary>
        /// <returns>A list of objects suitable for to be dislayed to the user as notifications</returns>
        public List <Advert> GetNotificationList()
        {
            DbJob                      dbJob         = new DbJob();
            DbNotification             db            = new DbNotification();
            JobsController             jc            = new JobsController();
            DbProject                  dbProject     = new DbProject();
            IEnumerable <Notification> notifications = db.GetNotifications();

            List <Advert> notificationList = new List <Advert>();

            foreach (var n in notifications)
            {
                System.Diagnostics.Debug.WriteLine("GetNotificationList: var n.id = " + n.id);
                System.Diagnostics.Debug.WriteLine("GetNotificationList: var n.jobUuid = " + n.jobUuid);
                System.Diagnostics.Debug.WriteLine("GetNotificationList: var n.projectUuid = " + n.projectUuid);

                if (!string.IsNullOrWhiteSpace(n.jobUuid))
                {
                    Job job = dbJob.GetJobByUuid(n.jobUuid);
                    job.companies = dbJob.GetAllCompaniesRelatedToJob(job);
                    notificationList.Add(job);
                }
                else
                {
                    Project project = dbProject.GetProjectByUuid(n.projectUuid);
                    project.companies = dbProject.GetAllCompaniesRelatedToProject(project);
                    notificationList.Add(project);
                }
            }
            return(notificationList.OrderByDescending(a => a.published).ToList());
        }
Exemplo n.º 4
0
        public void UpdateGraphWithChildDeletes(ProductLine productLine)
        {
            if (productLine == null)
            {
                throw new ArgumentNullException(nameof(productLine), $"{nameof(productLine)} is null.");
            }

            productLine.ApplyKeys();

            //Note: This could all be done in a single query transaction leveraging the MERGE feature
            using (var con = OpenConnection())
                using (var trans = con.BeginTransaction())
                {
                    //Find products
                    var originalProductKeys = BuildGetProductKeys(productLine.ProductLineKey).Execute(trans);

                    foreach (var item in productLine.Products)
                    {
                        originalProductKeys.Remove(item.ProductKey);
                    }

                    //Leverage DbConnector's Job Batching feature
                    DbJob.ExecuteAll(trans, BuildUpdateProductLine(productLine), BuildInsertOrUpdateProducts(productLine.Products));

                    //Remove products
                    if (originalProductKeys.Count > 0)
                    {
                        BuildDeleteProducts(originalProductKeys).Execute(trans);
                    }

                    trans.Commit();
                }
        }
Exemplo n.º 5
0
        public void Test_UpdateClass_GetCommandMethod_Returns_A_bool()
        {
            DbJob job = new DbJob();

            job.JobId = 5;

            List <DbJob> jobs = new List <DbJob>();

            jobs.Add(job);


            List <string> deleteskills = new List <string>();

            deleteskills.Add(".Net");

            List <string> Addedskills = new List <string>();

            Addedskills.Add("SQL");
            Addedskills.Add("Java");
            Addedskills.Add("VMware");


            UpdateJob upjob  = new UpdateJob();
            bool      result = upjob.GetCommand(jobs, deleteskills);

            Assert.IsInstanceOf(typeof(bool), result);
        }
Exemplo n.º 6
0
        protected void gvComments_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            int rowIndex = e.RowIndex;

            job = (DbJob)Session["Job"];
            dt  = ToDataTable <DbComments>(service.ViewComments(job.JobId).ToList());
            DataRow dr        = dt.Rows[rowIndex];
            int     commentId = (int)dr["CommentId"];
            int     userId    = service.GetUserIdByCommentId(commentId);
            int     userId2   = int.Parse(Session["userid"].ToString());

            if (userId != userId2)
            {
                lblError.Text = "You can only delete your own comments";
            }
            else
            {
                if (service.DeleteComment(commentId) == true)
                {
                    lblSuccess.Text = "Your comment has been successfully deleted";
                    lblError.Text   = "";
                    dt = ToDataTable <DbComments>(service.ViewComments(job.JobId).ToList());
                    dt.Columns.Remove("CommentId");
                    dt.Columns.Remove("JobId");

                    gvComments.DataSource = dt;
                    gvComments.DataBind();
                }
                else
                {
                    lblError.Text = "Something went wrong! Please try again";
                }
            }
        }
Exemplo n.º 7
0
        protected void recsLBTN_Click(object sender, EventArgs e)
        {
            GridViewRow row = gvRecentJobs.SelectedRow;

            dt2 = ToDataTable <DbJob>(service.RecentJobs("All"));
            DataRow dRow = dt2.Rows[row.RowIndex];

            jobId  = (int)dRow["JobId"];
            userId = (int)dRow["UserId"];

            DbJob job = new DbJob();

            job.JobId       = jobId;
            job.UserId      = userId;
            job.Stream      = row.Cells[5].Text;
            job.Status      = row.Cells[6].Text;
            job.Location    = row.Cells[4].Text;
            job.Company     = row.Cells[3].Text;
            job.Title       = row.Cells[2].Text;
            job.Description = dRow["Description"].ToString();
            job.DatePosted  = DateTime.Parse(row.Cells[1].Text);
            job.Deadline    = DateTime.Parse(row.Cells[7].Text);

            Session["Job"] = job;
            Response.Redirect("AddRecommendation.aspx");
        }
Exemplo n.º 8
0
        public int Create(ProductLine productLine)
        {
            if (productLine == null)
            {
                throw new ArgumentNullException(nameof(productLine), $"{nameof(productLine)} is null.");
            }

            const string sql = "INSERT INTO Production.ProductLine ( ProductLineName ) OUTPUT Inserted.ProductLineKey VALUES (@ProductLineName);";

            //Build the main IDbJob.
            IDbJob <int> jobProductLine = DbConnector
                                          .Scalar <int>(sql, productLine)
                                          .OnExecuted((int result, IDbExecutedModel im) =>
            {
                productLine.ProductLineKey = result;
                productLine.ApplyKeys();
                return(result);
            });

            if (productLine.Products.Count == 0)
            {
                return(jobProductLine.Execute());
            }
            else
            {
                //Leverage DbConnector's Job Batching feature
                DbJob.ExecuteAll(jobProductLine, BuildInsertOrUpdateProducts(productLine.Products));

                return(productLine.ProductLineKey);
            }
        }
Exemplo n.º 9
0
        protected void InsertRecBTN_Click(object sender, EventArgs e)
        {
            DbJob         recJob         = (DbJob)Session["Job"];
            int           recommender_id = int.Parse(Session["userid"].ToString());
            List <DbUser> recommendee    = service.GetUserByUserName(SearchConsultantsRecLBX.SelectedValue);
            int           recommendee_id = recommendee[0].UserId;

            service.AddRecommendation(recommender_id, recommendee_id, recJob.JobId, ReasonTBX.Text);
            Response.Redirect("Default.aspx");
        }
Exemplo n.º 10
0
        public void UpdateGraph(ProductLine productLine)
        {
            if (productLine == null)
            {
                throw new ArgumentNullException(nameof(productLine), $"{nameof(productLine)} is null.");
            }

            productLine.ApplyKeys();

            //Leverage DbConnector's Job Batching feature
            DbJob.ExecuteAll(BuildUpdateProductLine(productLine), BuildInsertOrUpdateProducts(productLine.Products));
        }
Exemplo n.º 11
0
        public void TestGetDetailsReturnsAJob()
        {
            int jobID = 1;
            RetrieveJobDetails get = new RetrieveJobDetails();
            DbJob job = get.GetDetails(jobID);

            Console.WriteLine(job.Title);
            Console.WriteLine(job.Skills[0]);
            string title = "Ace Dot Net Dev";

            Assert.AreEqual(title, job.Title.ToString());
        }
Exemplo n.º 12
0
        public void JoinedExecution_Handled_Custom_Transaction()
        {
            using (var conn = new SqlConnection(TestBase.ConnectionString))
            {
                conn.Open();

                using (var transaction = conn.BeginTransaction())
                {
                    IDbJob <int?> jobInsert = _dbConnector.NonQuery((cmd) =>
                    {
                        cmd.CommandText = @"
                            INSERT INTO [Production].[Location]
                                ([Name]
                                ,[CostRate])
                            VALUES
                                (@Name
                                ,@CostRate)
                        ";

                        cmd.Parameters.AddFor(new
                        {
                            Name     = "9104",
                            CostRate = 5
                        });
                    });

                    IDbJob <int?> jobDelete = _dbConnector.NonQuery((cmd) =>
                    {
                        cmd.CommandText = @"
                        DELETE FROM [Production].[Location] WHERE Name = @Name
                    ";

                        cmd.Parameters.AddFor(new
                        {
                            Name     = "9104",
                            CostRate = 5
                        });
                    });

                    var result = DbJob.ExecuteAllHandled(transaction, jobInsert, jobDelete);

                    transaction.Commit();

                    Assert.NotNull(result);
                    Assert.Equal(1, result.Data[0].Item2);
                    Assert.Equal(1, result.Data[1].Item2);
                }
            }
        }
Exemplo n.º 13
0
        public DbEmail Execute(Guid sessionID, string recipientEmail, DbJob job)
        {
            // Get userEmail
            string qry = "SELECT email FROM FDMUSER JOIN SESSIONS ON FDMUSER.user_id = SESSIONS.user_id WHERE session_guid = '" + sessionID.ToString() + "'";
            ReadOneCommand cmd = new ReadOneCommand();
            string userEmail = cmd.Execute(qry);

            DbEmail email = new DbEmail();
            email.Sender = userEmail;
            email.Recipient = recipientEmail;
            email.Subject = "Application for " + job.Title + " at " + job.Location;
            email.Body = "Hi ";

            return email;
        }
Exemplo n.º 14
0
 private void FillJobCollection()
 {
     jobList = client.CheckAccManagerJobExists(username);
     for (int i = 0; i < jobList.Count; i++)
     {
         DbJob job = jobList[i];
         _JobCollection.Add(new DbJob
         {
             Location   = job.Location.ToString(),
             Company    = job.Company.ToString(),
             Title      = job.Title.ToString(),
             DatePosted = job.DatePosted
         });
     }
 }
Exemplo n.º 15
0
        public DbJob SetupJob()
        {
            DbJob job = new DbJob();

            job.Location    = "Manchester";
            job.Status      = "Interviewing";
            job.Stream      = "Testing";
            job.Title       = "Testing insert job";
            job.Description = "A series of tests to test that a job is added to the database along with related skills.";
            job.UserId      = 9;
            job.Deadline    = DateTime.Now;
            job.DatePosted  = DateTime.Now;
            job.Company     = "Barclays";

            return(job);
        }
Exemplo n.º 16
0
        public DbEmail Execute(Guid sessionID, string recipientEmail, DbJob job)
        {
            // Get userEmail
            string         qry       = "SELECT email FROM FDMUSER JOIN SESSIONS ON FDMUSER.user_id = SESSIONS.user_id WHERE session_guid = '" + sessionID.ToString() + "'";
            ReadOneCommand cmd       = new ReadOneCommand();
            string         userEmail = cmd.Execute(qry);

            DbEmail email = new DbEmail();

            email.Sender    = userEmail;
            email.Recipient = recipientEmail;
            email.Subject   = "Application for " + job.Title + " at " + job.Location;
            email.Body      = "Hi ";

            return(email);
        }
Exemplo n.º 17
0
        public void Test_GetFavClass_ExecuteMethod_Retruns_A_True_When_User_Has_Favr()
        {
            DbJob job = new DbJob();

            job.JobId = 1;
            List <DbJob> jobList = new List <DbJob>();

            jobList.Add(job);

            GetFav getFav = new GetFav();

            getFav.setSessionId(Guid.Parse("023bf663-97ea-421d-89fc-611edea5f79d"));

            List <DbJob> jobs = getFav.Execute(job);

            Assert.AreEqual(3, jobs.Count);
        }
Exemplo n.º 18
0
        public void Test_GetFavClass_ExecuteMethod_Retruns_A_List_of_DbJob()
        {
            DbJob job = new DbJob();

            job.JobId = 1;
            List <DbJob> jobList = new List <DbJob>();

            jobList.Add(job);

            GetFav getFav = new GetFav();

            getFav.setSessionId(Guid.Parse("023bf663-97ea-421d-89fc-611edea5f79d"));

            List <DbJob> jobs = getFav.Execute(job);

            Assert.IsInstanceOf(typeof(List <DbJob>), jobs);
        }
Exemplo n.º 19
0
 protected void Page_Load(object sender, EventArgs e)
 {
     recJob = (DbJob)Session["Job"];
     SelectTextLBL.Visible           = false;
     SearchConsultantsRecLBX.Visible = false;
     ReasonLBL.Visible = false;
     ReasonTBX.Visible = false;
     //SearchTraineeTBX.AutoCompleteMode = AutoCompleteMode.SuggestAppend;
     //SearchTraineeTBX.AutoCompleteSource = AutoCompleteSource.CustomSource;
     //SearchTraineeTBX.AutoCompleteCustomSource = namesCollection;
     selectedJobLBL.Text = recJob.Title + " at " + recJob.Company;
     if (!Page.IsPostBack)
     {
         streamFilterCBX.DataSource = service.GetStreams();
         streamFilterCBX.DataBind();
     }
 }
Exemplo n.º 20
0
        protected void Page_Load(object sender, EventArgs e)
        {
            recJob = (DbJob)Session["Job"];
            SelectTextLBL.Visible = false;
            SearchConsultantsRecLBX.Visible = false;
            ReasonLBL.Visible = false;
            ReasonTBX.Visible = false;
            //SearchTraineeTBX.AutoCompleteMode = AutoCompleteMode.SuggestAppend;
            //SearchTraineeTBX.AutoCompleteSource = AutoCompleteSource.CustomSource;
            //SearchTraineeTBX.AutoCompleteCustomSource = namesCollection;
            selectedJobLBL.Text = recJob.Title + " at " + recJob.Company;
            if (!Page.IsPostBack)
            {

                streamFilterCBX.DataSource = service.GetStreams();
                streamFilterCBX.DataBind();
            }
        }
Exemplo n.º 21
0
        public void UpdateGraphWithDeletes(ProductLine productLine, IList <int> productKeysToRemove)
        {
            if (productLine == null)
            {
                throw new ArgumentNullException(nameof(productLine), $"{nameof(productLine)} is null.");
            }

            productLine.ApplyKeys();

            if (productKeysToRemove == null || productKeysToRemove.Count == 0)
            {
                DbJob.ExecuteAll(BuildUpdateProductLine(productLine), BuildInsertOrUpdateProducts(productLine.Products));
            }
            else
            {
                DbJob.ExecuteAll(BuildUpdateProductLine(productLine), BuildInsertOrUpdateProducts(productLine.Products), BuildDeleteProducts(productKeysToRemove));
            }
        }
Exemplo n.º 22
0
        private void updateBtn_Click(object sender, EventArgs e)
        {
            //testLbl.Text = hiddenLbl.Text;
            DbJob job = new DbJob();
            BindingList <string> skills = new BindingList <string>();

            for (int i = 0; i < myFullJobsList.Count; i++)
            {
                skills = new BindingList <string>(service.GetJobSkills(myFullJobsList[i].JobId).ToList());
                if (hiddenLbl.Text == myFullJobsList[i].Title)
                {
                    //skills = new BindingList<string>(service.GetJobSkills(myFullJobsList[i].JobId).ToList());
                    //listViewSkills.DataSource = skills;

                    job.Stream      = streamComBox.SelectedValue.ToString();
                    job.Status      = statusComBox.SelectedValue.ToString();
                    job.Location    = editLocTxtBox.Text;
                    job.Deadline    = deadLinePicker.Value;
                    job.JobId       = myFullJobsList[i].JobId;
                    job.Description = editDescTxtBox.Text;
                    job.Company     = editCompTxtBox.Text;
                    job.Title       = editTitleTxtBox.Text;
                }
            }

            List <DbJob> jobList = new List <DbJob>();

            jobList.Add(job);
            if (service.UpdateAMJob(jobList))
            {
                //fillMyJobsDataGrid();
                hiddenLbl.ForeColor = Color.Green;
                hiddenLbl.Text      = "Job successfully update.";
                editPanel.Visible   = false;
                hiddenLbl.Visible   = true;
                myJobsGridView.Refresh();
            }
            else
            {
                hiddenLbl.Text      = "Job update unsuccessful.";
                hiddenLbl.ForeColor = Color.Red;
                hiddenLbl.Visible   = true;
            }
        }
Exemplo n.º 23
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            // Create the temp job
            DbJob job = new DbJob();

            // set the values
            job.Stream      = streamCBX.SelectedValue.ToString();
            job.Status      = statusCBX.SelectedValue.ToString();
            job.Description = descriptionBX.Text;
            job.Title       = titleBX.Text;
            job.DatePosted  = DateTime.Now;
            job.Deadline    = datePickerDeadline.Value;
            job.Company     = companyBX.Text;
            job.Location    = locationBX.Text;

            List <string> skills = new List <string>();

            for (int k = 0; k < selectedSkills.Count(); k++)
            {
                skills.Add(selectedSkills[k].ToString());
            }

            // add the job to the system
            if (service.InsertJob(job, skills, sessionId))
            {
                descriptionBX.Text        = "";
                titleBX.Text              = "";
                companyBX.Text            = "";
                locationBX.Text           = "";
                addedSkillsLBX.DataSource = new List <string>();
                tabControl1.SelectedTab   = homeTab;
                fillMyJobsDataGrid();
            }
            else
            {
                postedStatusLBL2.ForeColor = Color.Red;
                postedStatusLBL2.Text      = "Job not posted";
                postedStatusLBL2.Visible   = true;
                //for (int j = 0; j < skills.Count(); j++)
                //{
                //    postedStatusLBL2.Text += skills[j];
                //}
            }
        }
Exemplo n.º 24
0
        protected void gvRecJobs_SelectedIndexChanged(object sender, EventArgs e)
        {
            GridViewRow row = gvRecJobs.SelectedRow;

            dt2 = ToDataTable <DbRecommendation>(recPeople.ToList());
            DataRow dRow = dt2.Rows[row.RowIndex];

            jobId = (int)dRow["JobId"];
            pnlSelectJob.Visible = true;
            DbJob job = service.GetOneJob(jobId);

            string accountManager = service.GetOneUser(job.UserId);

            //int rowCount = gvRecJobs.SelectedIndex;

            //lblStatus.Text = jobId.ToString();
            lblStatus.Text      = job.Status;
            lblStream.Text      = job.Stream;
            lblLocation.Text    = job.Location;
            lblCompany.Text     = job.Company;
            lblTitle.Text       = job.Title;
            lblDescription.Text = job.Description;
            lblDateposted.Text  = job.DatePosted.ToString();
            lblDeadline.Text    = job.Deadline.ToString();
            lblAccMan.Text      = accountManager;
            blSkills.DataSource = job.Skills;
            blSkills.DataBind();

            //lblMsg.Visible = false;
            pnlSelectJob.Visible = true;
            Session["jobId"]     = jobId;

            lbtnAddComment.Visible = true;
            BindCommentData(jobId);

            if (service.ViewComments(jobId).ToList().Count == 0)
            {
                lblSuccess.Text   = "There are currently no comments for this post";
                cmntTimer.Enabled = false;
            }
            cmntTimer.Enabled = true;
        }
Exemplo n.º 25
0
        public async Task TestComplexObjectPersistence()
        {
            var   dbJob            = SampleData.SampleJobs.SampleJob1;
            DbJob lastJobBeforeAdd = null;

            using (var databaseContext = new DatabaseContext())
            {
                if (databaseContext.Jobs != null && databaseContext.Jobs.Any())
                {
                    lastJobBeforeAdd = await databaseContext.Jobs.LastOrDefaultAsync();
                }

                databaseContext.Jobs.Add(dbJob);
                await databaseContext.SaveChangesAsync();
            }

            using (var databaseContext = new DatabaseContext())
            {
                // ToDo: Remove temporary DbSet iterations due to a bug in EF Core 1.0 RC2
                foreach (var force in databaseContext.Forces)
                {
                }

                foreach (var location in databaseContext.JobLocations)
                {
                }

                foreach (var relation in databaseContext.ForceJobRelations)
                {
                }

                foreach (var job in databaseContext.Jobs)
                {
                }

                var lastJobAfterAdd = await databaseContext.Jobs.LastOrDefaultAsync();

                Assert.AreEqual(lastJobAfterAdd.Forces?.Count, dbJob.Forces.Count);
                Assert.AreEqual(lastJobAfterAdd.Location.Id, dbJob.Location.Id);
            }
        }
        public List <object> GetNotificationListJobOnly()
        {
            DbJob                      dbJob         = new DbJob();
            DbNotification             db            = new DbNotification();
            IEnumerable <Notification> notifications = db.GetNotifications();

            List <object> notificationList = new List <object>();

            foreach (var n in notifications)
            {
                System.Diagnostics.Debug.WriteLine("GetNotificationList: var n.id = " + n.id);
                System.Diagnostics.Debug.WriteLine("GetNotificationList: var n.jobUuid = " + n.jobUuid);
                if (!string.IsNullOrWhiteSpace(n.jobUuid))
                {
                    Job job = dbJob.GetJobByUuid(n.jobUuid);
                    job.companies = dbJob.GetAllCompaniesRelatedToJob(job);
                    notificationList.Add(job);
                }
            }
            return(notificationList);
        }
Exemplo n.º 27
0
        public void JoinedExecution_Handled()
        {
            IDbJob <int?> jobInsert = _dbConnector.NonQuery((cmd) =>
            {
                cmd.CommandText = @"
                    INSERT INTO [Production].[Location]
                        ([Name]
                        ,[CostRate])
                    VALUES
                        (@Name
                        ,@CostRate)
                ";

                cmd.Parameters.AddFor(new
                {
                    Name     = "9300",
                    CostRate = 5
                });
            });

            IDbJob <int?> jobDelete = _dbConnector.NonQuery((cmd) =>
            {
                cmd.CommandText = @"
                    DELETE FROM [Production].[Location] WHERE Name = @Name
                ";

                cmd.Parameters.AddFor(new
                {
                    Name     = "9300",
                    CostRate = 5
                });
            });

            var result = DbJob.ExecuteAllHandled(jobInsert, jobDelete);

            Assert.NotNull(result);
            Assert.NotNull(result.Data);
            Assert.Equal(1, result.Data[0].Item2);
            Assert.Equal(1, result.Data[1].Item2);
        }
Exemplo n.º 28
0
        public void JoinedExecution_Handled_ExceptionThrow()
        {
            IDbJob <int?> jobInsert = _dbConnector.NonQuery((cmd) =>
            {
                cmd.CommandText = @"
                    INSERT INTO [Production].[Location]
                        ([Name]
                        ,[CostRate])
                    VALUES
                        (@Name
                        ,@CostRate)
                ";

                cmd.Parameters.AddFor(new
                {
                    Name     = "9400",
                    CostRate = 5
                });
            });

            IDbJob <int?> jobDelete = _dbConnector.NonQuery((cmd) =>
            {
                cmd.CommandText = @"
                    DELETE FROM [Production].[Location] WHERE Name = @Name
                ";

                cmd.Parameters.AddFor(new
                {
                    Name     = "9400",
                    CostRate = 5
                });

                throw new System.Exception("Test Exception!");
            });

            var result = DbJob.ExecuteAllHandled(jobInsert, jobDelete);

            Assert.NotNull(result);
            Assert.Equal("Test Exception!", result.Error.Message);
        }
Exemplo n.º 29
0
        public void JoinedExecution_Exception()
        {
            Assert.Throws <Exception>(() =>
            {
                IDbJob <int?> jobInsert = _dbConnector.NonQuery((cmd) =>
                {
                    cmd.CommandText = @"
                            INSERT INTO [Production].[Location]
                                ([Name]
                                ,[CostRate])
                            VALUES
                                (@Name
                                ,@CostRate)
                        ";

                    cmd.Parameters.AddFor(new
                    {
                        Name     = "9200",
                        CostRate = 5
                    });
                });

                IDbJob <int?> jobDelete = _dbConnector.NonQuery((cmd) =>
                {
                    cmd.CommandText = @"
                        DELETE FROM [Production].[Location] WHERE Name = @Name
                    ";

                    cmd.Parameters.AddFor(new
                    {
                        Name     = "9200",
                        CostRate = 5
                    });

                    throw new System.Exception("Test Exception!");
                });

                var result = DbJob.ExecuteAll(jobInsert, jobDelete);
            });
        }
Exemplo n.º 30
0
        public void Test_UpdateJobClass_GetCommandMethod_Returns_A_bool()
        {
            DbJob job = new DbJob();

            job.JobId       = 6;
            job.UserId      = 6;
            job.Stream      = "Testing";
            job.Status      = "Interviewing";
            job.Company     = "MyCompany";
            job.Location    = "Manchester";
            job.Title       = "updating From Tests";
            job.Description = "I commit this change via NUnit";
            job.Deadline    = DateTime.Now;

            List <DbJob> jobList = new List <DbJob>();

            jobList.Add(job);

            UpdateJob upjob  = new UpdateJob();
            bool      result = upjob.GetCommand(jobList);

            Assert.IsInstanceOf(typeof(bool), result);
        }
Exemplo n.º 31
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            // Create the temp job
            DbJob job = new DbJob();

            // set the values
            job.Stream = streamCBX.SelectedValue.ToString();
            job.Status = statusCBX.SelectedValue.ToString();
            job.Description = descriptionBX.Text;
            job.Title = titleBX.Text;
            job.DatePosted = DateTime.Now;
            job.Deadline = datePickerDeadline.Value;
            job.Company = companyBX.Text;
            job.Location = locationBX.Text;

            List<string> skills = new List<string>();

            for (int k = 0; k < selectedSkills.Count(); k++)
            {
                skills.Add(selectedSkills[k].ToString());
            }

            // add the job to the system
            if (service.InsertJob(job, skills, sessionId))
            {
                descriptionBX.Text = "";
                titleBX.Text = "";
                companyBX.Text = "";
                locationBX.Text = "";
                addedSkillsLBX.DataSource = new List<string>();
                tabControl1.SelectedTab = homeTab;
                fillMyJobsDataGrid();

            }
            else
            {
                postedStatusLBL2.ForeColor = Color.Red;
                postedStatusLBL2.Text = "Job not posted";
                postedStatusLBL2.Visible = true;
                //for (int j = 0; j < skills.Count(); j++)
                //{
                //    postedStatusLBL2.Text += skills[j];
                //}
            }
        }
Exemplo n.º 32
0
        /// <summary>
        /// This test method require that you have not logged in and got no authorization
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void TestDeleteExpiredJobs(object sender, EventArgs e)
        {
            DbJob jc = new DbJob();

            DbContext        DbContext = DbContext.GetDbContext;
            SQLiteConnection Db        = DbContext.Db;

            DateTime yesterday = DateTime.Now.AddDays(-1);
            long     n         = long.Parse(yesterday.ToString("yyyyMMddHHmmss"));

            string testUuid = "colemak";
            Job    job      = new Job()
            {
                uuid       = testUuid,
                expiryDate = n
            };

            string  companyId = "Ikea";
            Company comp      = new Company()
            {
                id = companyId
            };

            string   locationId = "sverige";
            Location loc        = new Location()
            {
                id = locationId
            };

            string     sgId = "dykking";
            StudyGroup sg   = new StudyGroup()
            {
                id = sgId
            };

            StudyGroupJob sgj = new StudyGroupJob()
            {
                StudyGroupId = sgId,
                JobUuid      = testUuid
            };

            LocationJob lj = new LocationJob()
            {
                LocationId = locationId,
                JobUuid    = testUuid
            };

            CompanyJob cj = new CompanyJob()
            {
                CompanyId = companyId,
                JobUuid   = testUuid
            };

            string  jtId = "10aarErfaringEcma6";
            JobType jt   = new JobType()
            {
                id = jtId
            };

            JobTypeJob jtj = new JobTypeJob()
            {
                JobUuid   = testUuid,
                JobTypeId = jtId
            };

            Db.Insert(comp);
            Db.Insert(job);
            Db.Insert(loc);
            Db.Insert(sg);
            Db.Insert(sgj);
            Db.Insert(lj);
            Db.Insert(cj);
            Db.Insert(jt);
            Db.Insert(jtj);

            Job j = Db.Get <Job>(testUuid);

            System.Diagnostics.Debug.WriteLine("j.expiryDate: " + j.expiryDate);
            System.Diagnostics.Debug.WriteLine("StudyGroup.Count: " +
                                               Db.Query <StudyGroup>("Select * from StudyGroup").Count());
            System.Diagnostics.Debug.WriteLine("Job.Count: " +
                                               Db.Query <Job>("Select * from Job").Count());
            System.Diagnostics.Debug.WriteLine("JobType.Count: " +
                                               Db.Query <JobType>("Select * from JobType").Count());
            System.Diagnostics.Debug.WriteLine("Location.Count: " +
                                               Db.Query <Location>("Select * from Location").Count());
            System.Diagnostics.Debug.WriteLine("Company.Count: " +
                                               Db.Query <Company>("Select * from Company").Count());

            System.Diagnostics.Debug.WriteLine("CompanyJob.Count: " +
                                               Db.Query <CompanyJob>("Select * from CompanyJob").Count());
            System.Diagnostics.Debug.WriteLine("JobTypeJob.Count: " +
                                               Db.Query <JobTypeJob>("Select * from JobTypeJob").Count());
            System.Diagnostics.Debug.WriteLine("LocationJob.Count: " +
                                               Db.Query <LocationJob>("Select * from LocationJob").Count());
            System.Diagnostics.Debug.WriteLine("StudyGroupJob.Count: " +
                                               Db.Query <StudyGroupJob>("Select * from StudyGroupJob").Count());

            System.Diagnostics.Debug.WriteLine("Time for delete");
            jc.DeleteAllExpiredJobs();
            System.Diagnostics.Debug.WriteLine("Job.Count: " +
                                               Db.Query <Job>("Select * from Job").Count());
            System.Diagnostics.Debug.WriteLine("CompanyJob.Count: " +
                                               Db.Query <CompanyJob>("Select * from CompanyJob").Count());
            System.Diagnostics.Debug.WriteLine("JobTypeJob.Count: " +
                                               Db.Query <JobTypeJob>("Select * from JobTypeJob").Count());
            System.Diagnostics.Debug.WriteLine("LocationJob.Count: " +
                                               Db.Query <LocationJob>("Select * from LocationJob").Count());
            System.Diagnostics.Debug.WriteLine("StudyGroupJob.Count: " +
                                               Db.Query <StudyGroupJob>("Select * from StudyGroupJob").Count());
            //CompanyJobs, StudyGroupJob, LocationJob og JobTypeJob.
        }
Exemplo n.º 33
0
        /// <summary>
        /// Peter ikke se på denne metoden, den er kun for å teste databasen :D
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void TestJobsFilterDb_OnClicked(object sender, EventArgs e)
        {
            List <string> studyGroups   = new List <string>();
            string        helse         = Hasher.Base64Encode("helse");
            string        datateknologi = Hasher.Base64Encode("datateknologi");

            studyGroups.Add(helse);
            studyGroups.Add(datateknologi);

            Dictionary <string, string> filter = new Dictionary <string, string>();
            string vestagder = Hasher.Base64Encode("vestagder");
            string heltid    = Hasher.Base64Encode("heltid");

            filter.Add("locations", vestagder);
            filter.Add("types", heltid);


            DbJob jc   = new DbJob();
            var   jobs = jc.GetJobsFromDbBasedOnFilter(null, filter);

            if (jobs == null)
            {
                System.Diagnostics.Debug.WriteLine("TestJobsFilterDb:  was null aka failed!");
            }
            else
            {
                System.Diagnostics.Debug.WriteLine("GetJobsBasedOnFilter: jobs.Count(): " +
                                                   jobs.Count());

                foreach (var job in jobs)
                {
                    System.Diagnostics.Debug.WriteLine("Jobs title: " + job.title);
                    if (job.companies != null)
                    {
                        System.Diagnostics.Debug.WriteLine("Companies is not null: " + job.companies[0].id);
                    }
                }
            }

            var jobs2 = jc.GetJobsFromDbBasedOnFilter(studyGroups);

            if (jobs2 == null)
            {
                System.Diagnostics.Debug.WriteLine("TestJobsFilterDb:  was null aka failed!");
            }
            else
            {
                System.Diagnostics.Debug.WriteLine("GetJobsBasedOnFilter: jobs2.Count(): " +
                                                   jobs2.Count());

                foreach (var job in jobs2)
                {
                    System.Diagnostics.Debug.WriteLine("Jobs2 title: " + job.title);
                    if (job.companies != null)
                    {
                        System.Diagnostics.Debug.WriteLine("Companies is not null: " + job.companies[0].id);
                        System.Diagnostics.Debug.WriteLine("Companies is not null: " + job.companies[0].name);
                        System.Diagnostics.Debug.WriteLine("Companies is not null: " + job.companies[0].logo);
                    }
                }
            }

            var jobs3 = jc.GetJobsFromDbBasedOnFilter(studyGroups, filter);

            if (jobs3 == null)
            {
                System.Diagnostics.Debug.WriteLine("TestJobsFilterDb:  was null aka failed!");
            }
            else
            {
                System.Diagnostics.Debug.WriteLine("GetJobsBasedOnFilter: jobs3.Count(): " +
                                                   jobs3.Count());

                foreach (var job in jobs3)
                {
                    System.Diagnostics.Debug.WriteLine("Jobs3 title: " + job.title);
                    if (job.companies != null)
                    {
                        System.Diagnostics.Debug.WriteLine("Companies is not null: " + job.companies[0].id);
                    }
                }
            }

            Dictionary <string, string> filter2 = new Dictionary <string, string>();

            //string internship = Hasher.Base64Encode("Internship");
            filter2.Add("titles", "Internship");

            var jobs4 = jc.GetJobsFromDbBasedOnFilter(studyGroups, filter2);

            if (jobs4 == null)
            {
                System.Diagnostics.Debug.WriteLine("TestJobsFilterDb:  was null aka failed!");
            }
            else
            {
                System.Diagnostics.Debug.WriteLine("GetJobsBasedOnFilter: jobs4.Count(): " +
                                                   jobs4.Count());

                foreach (var job in jobs4)
                {
                    System.Diagnostics.Debug.WriteLine("Jobs4 title: " + job.title);
                    if (job.companies != null)
                    {
                        System.Diagnostics.Debug.WriteLine("Companies is not null: " + job.companies[0].id);
                    }
                }
            }

            /*
             * StudyGroupsController sgc = new StudyGroupsController();
             * sgc.UpdateStudyGroupsFromServer(); */
        }
Exemplo n.º 34
0
 public void setJob(DbJob job)
 {
     this.job = job;
 }
Exemplo n.º 35
0
        private void assignBtn_Click(object sender, RoutedEventArgs e)
        {
            if (AccManJobList.SelectedIndex != -1)
            {

                if (AvailAccManList.SelectedIndex != -1)
                {
                    DbJob selectedJob = (DbJob)AccManJobList.SelectedItem;
                    string jobTitle = selectedJob.Title;
                    string company = selectedJob.Company;
                    int jobId = 0;
                    int userId = 0;

                    DbUser selectedUser = (DbUser)AvailAccManList.SelectedItem;
                    string userName = selectedUser.FirstName.ToLower() + "." + selectedUser.LastName.ToLower();
                    for (int i = 0; i < jobList.Count; i++)
                    {
                        if (jobList[i].Title == jobTitle && jobList[i].Company == company)
                        {
                            jobId = jobList[i].JobId;

                        }
                    }
                    for (int i = 0; i < users.Count; i++)
                    {
                        if (users[i].Username == userName)
                        {
                            userId = users[i].UserId;
                        }
                    }

                    DbJob updateJob = new DbJob();
                    updateJob.UserId = userId;
                    updateJob.JobId = jobId;
                    List<DbJob> jobUpdate = new List<DbJob>();
                    jobUpdate.Add(updateJob);
                    if (client.UpdateUserIdOfAJob(jobUpdate, 0))
                    {
                        errLbl.Content = "Job reassigned '" + jobTitle + "'";
                        errLbl.Foreground = new SolidColorBrush(Colors.Green);
                        errLbl.Visibility = Visibility.Visible;
                        _JobCollection.Remove((DbJob)AccManJobList.SelectedItem);
                        if (_JobCollection.Count == 0)
                        {
                            form.Show();
                            this.Close();
                            form.DeleteAccountManager();
                        }
                    }
                    else
                    {
                        errLbl.Content = "Failed to reassigned job '" + jobTitle + "' Please try again later.";
                        errLbl.Foreground = new SolidColorBrush(Colors.Red);
                    }
                }
                else
                {
                    errLbl.Content = "Please select an account manager";
                    errLbl.Foreground = new SolidColorBrush(Colors.Red);
                    errLbl.Visibility = Visibility.Visible;
                }
            }
            else
            {
                errLbl.Content = "Please select a job";
                errLbl.Foreground = new SolidColorBrush(Colors.Red);
                errLbl.Visibility = Visibility.Visible;
            }
        }
Exemplo n.º 36
0
        private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            BindingList<string> skills = new BindingList<string>();
            string jobTitle = myJobsGridView.Rows[e.RowIndex].Cells["Title"].Value.ToString();

            //Checking if view is clicked
            if (e.ColumnIndex == 0)
            {
                //Hiding the editPanel and find the title of the job selected
                editPanel.Visible = false;
                hiddenLbl.Visible = false;

                //Finding all the information about the selected job and initialsing the correspondent txtBoxes
                for (int i = 0; i < myFullJobsList.Count; i++)
                {
                    if (jobTitle == myFullJobsList[i].Title)
                    {
                        skills = new BindingList<string>(service.GetJobSkills(myFullJobsList[i].JobId).ToList());
                        listViewSkills.DataSource = skills;

                        txtBoxStream.Text = myFullJobsList[i].Stream;
                        txtBoxStatus.Text = myFullJobsList[i].Status;
                        txtBoxLoc.Text = myFullJobsList[i].Location;
                        txtBoxDeadline.Text = myFullJobsList[i].Deadline.ToString();
                        txtBoxDatePosted.Text = myFullJobsList[i].DatePosted.ToString();
                        txtBoxDesc.Text = myFullJobsList[i].Description;
                        txtBoxCompany.Text = myFullJobsList[i].Company;
                        txtBoxTitle.Text = jobTitle;
                        jobId = myFullJobsList[i].JobId;
                    }
                }
                //show the description of selected job
                panelDescription.Visible = true;
                //MessageBox.Show((e.RowIndex + 1) + "  Row  " + (e.ColumnIndex + 1) + "  Column button clicked ");
            }

            //Otherwise Check if the selected column is edit column
            else if (e.ColumnIndex == 1)
            {
                panelDescription.Hide();
                hiddenLbl.Visible = false;
                for (int i = 0; i < myFullJobsList.Count; i++)
                {
                    if (jobTitle == myFullJobsList[i].Title)
                    {
                        skills = new BindingList<string>(service.GetJobSkills(myFullJobsList[i].JobId).ToList());
                        editSkillListBox.DataSource = skills;

                        streamComBox.DataSource = service.GetStreams();
                        streamComBox.SelectedItem = myFullJobsList[i].Stream;
                        statusComBox.DataSource = service.GetStatuses();
                        statusComBox.SelectedItem = myFullJobsList[i].Status;
                        editLocTxtBox.Text = myFullJobsList[i].Location;
                        editDPTxtBox.Text = myFullJobsList[i].Deadline.ToString();
                        txtBoxDatePosted.Text = myFullJobsList[i].DatePosted.ToString();
                        editDescTxtBox.Text = myFullJobsList[i].Description;
                        editCompTxtBox.Text = myFullJobsList[i].Company;
                        editTitleTxtBox.Text = jobTitle;
                        deadLinePicker.Value = myFullJobsList[i].Deadline;
                        editJob.JobId = myFullJobsList[i].JobId;
                        hiddenLbl.Text = jobTitle;
                    }
                }
                editPanel.Size = panelDescription.Size;
                editPanel.Location = panelDescription.Location;
                panelDescription.Visible = false;
                editPanel.Visible = true;
            }

            //Otherwise Check if the selected column is delete column
            else if (e.ColumnIndex == 2)
            {
                if (MessageBox.Show("Are you sure You want to delete this job?", "Confirm",
                        MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    for (int i = 0; i < myFullJobsList.Count; i++)
                    {
                        if (jobTitle == myFullJobsList[i].Title)
                        {
                            DbJob job = new DbJob();
                            job.JobId = myFullJobsList[i].JobId;
                            List<DbJob> jobs = new List<DbJob>();
                            jobs.Add(job);
                            if (service.DeleteJob(jobs, 1))
                            {
                                editPanel.Hide();
                                panelDescription.Hide();
                                fillMyJobsDataGrid();
                                hiddenLbl.ForeColor = Color.Green;
                                hiddenLbl.Text = "Job successfully deleted. ";
                                hiddenLbl.Visible = true;
                            }
                            else
                            {
                                hiddenLbl.Text = "Job delete unsuccessful. ";
                                hiddenLbl.ForeColor = Color.Red;
                                hiddenLbl.Visible = true;
                            }
                        }
                    }
                }
                else
                {
                    // user clicked no
                }
            }
        }
Exemplo n.º 37
0
        private void updateBtn_Click(object sender, EventArgs e)
        {
            //testLbl.Text = hiddenLbl.Text;
            DbJob job = new DbJob();
            BindingList<string> skills = new BindingList<string>();
            for (int i = 0; i < myFullJobsList.Count; i++)
            {
                skills = new BindingList<string>(service.GetJobSkills(myFullJobsList[i].JobId).ToList());
                if (hiddenLbl.Text == myFullJobsList[i].Title)
                {
                    //skills = new BindingList<string>(service.GetJobSkills(myFullJobsList[i].JobId).ToList());
                    //listViewSkills.DataSource = skills;

                    job.Stream = streamComBox.SelectedValue.ToString();
                    job.Status = statusComBox.SelectedValue.ToString();
                    job.Location = editLocTxtBox.Text;
                    job.Deadline = deadLinePicker.Value;
                    job.JobId = myFullJobsList[i].JobId;
                    job.Description = editDescTxtBox.Text;
                    job.Company = editCompTxtBox.Text;
                    job.Title = editTitleTxtBox.Text;
                }
            }

            List<DbJob> jobList = new List<DbJob>();
            jobList.Add(job);
            if (service.UpdateAMJob(jobList))
            {
                //fillMyJobsDataGrid();
                hiddenLbl.ForeColor = Color.Green;
                hiddenLbl.Text = "Job successfully update.";
                editPanel.Visible = false;
                hiddenLbl.Visible = true;
                myJobsGridView.Refresh();

            }
            else
            {
                hiddenLbl.Text = "Job update unsuccessful.";
                hiddenLbl.ForeColor = Color.Red;
                hiddenLbl.Visible = true;
            }
        }