public void TestEditScrum()
        {
            ScrumModel scrumModel = new ScrumModel();
            scrumModel.AnswerList = new System.Collections.ArrayList();

            Answers answers = new Answers();
            answers.Answer = "Test Edit";
            answers.QuestionId = 1;
            answers.UserId = 1;
            answers.AnswerKey = 0;
            scrumModel.AnswerList.Add(answers);

            answers = new Answers();
            answers.Answer = "Test Edit";
            answers.QuestionId = 2;
            answers.UserId = 1;
            answers.AnswerKey = 0;
            scrumModel.AnswerList.Add(answers);

            answers = new Answers();
            answers.Answer = "None";
            answers.QuestionId = 3;
            answers.UserId = 1;
            answers.AnswerKey = 0;
            scrumModel.AnswerList.Add(answers);

            Assert.IsTrue(new ScrumController().EditScrum(scrumModel));
        }
        protected void submit_Click(object sender, EventArgs e)
        {
            ScrumModel scrumModel = new ScrumModel();
            scrumModel.AnswerList = new System.Collections.ArrayList();

            Answers answer = new Answers();
            answer.QuestionId = 1;
            answer.AnswerKey = Convert.ToInt32(Request["AnswerKey"]);
            answer.Answer = txtBoxAnswer1.Text;
            scrumModel.AnswerList.Add(answer);

            answer = new Answers();
            answer.QuestionId = 2;
            answer.AnswerKey = Convert.ToInt32(Request["AnswerKey"]);
            answer.Answer = txtBoxAnswer2.Text;
            scrumModel.AnswerList.Add(answer);

            answer = new Answers();
            answer.QuestionId = 3;
            answer.AnswerKey = Convert.ToInt32(Request["AnswerKey"]);
            answer.Answer = txtBoxAnswer3.Text;
            scrumModel.AnswerList.Add(answer);

            new Controllers.ScrumController().EditScrum(scrumModel);
            Response.Redirect("~/Scrum/ViewScrumData.aspx");
        }
        protected void submit_Click(object sender, EventArgs e)
        {
            User user = (User)Session["User"];
            ScrumModel scrumModel = new ScrumModel();
            scrumModel.AnswerList = new System.Collections.ArrayList();

            Answers answers = new Answers();
            answers.Answer = answer1.Text;
            answers.QuestionId = Convert.ToInt32(answer1.ID);
            answers.UserId = user.UserId;
            scrumModel.AnswerList.Add(answers);

            answers = new Answers();
            answers.Answer = answer2.Text;
            answers.QuestionId = Convert.ToInt32(answer2.ID);
            answers.UserId = user.UserId;
            scrumModel.AnswerList.Add(answers);

            answers = new Answers();
            answers.Answer = answer3.Text;
            answers.QuestionId = Convert.ToInt32(answer3.ID);
            answers.UserId = user.UserId;
            scrumModel.AnswerList.Add(answers);

            bool dataInserted = new ScrumController().InputNewScrum(scrumModel);
            if (dataInserted)
            {
                Session.Add("Message", "The scrum data was successfully entered.");
                Response.Redirect("~/Scrum/ViewScrumData.aspx");
            }
            else
            {
                Message.Text = "There was an error inserting the scrum data.";
            }
        }
Beispiel #4
0
 public ScrumModel GetScrumQuestions()
 {
     ScrumModel scrumModel = new ScrumModel();
     using (SqlConnection sqlConnection = new SqlConnection(Constants.DATABASE.CONNECTION_STRING))
     {
         sqlConnection.Open();
         using (SqlCommand sqlCommand = new SqlCommand("SELECT * FROM ScrumQuestions WHERE Active=" + 1, sqlConnection))
         {
             using (SqlDataReader sqlDataReader = sqlCommand.ExecuteReader())
             {
                 if (sqlDataReader.HasRows)
                 {
                     scrumModel.QuestionList = new System.Collections.ArrayList();
                     while (sqlDataReader.Read())
                     {
                         Questions question = new Questions();
                         question.QuestionId = Convert.ToInt32(sqlDataReader["ScrumQuestionId"]);
                         question.Question = Convert.ToString(sqlDataReader["ScrumQuestion"]);
                         scrumModel.QuestionList.Add(question);
                     }
                 }
                 sqlDataReader.Close();
             }
         }
         sqlConnection.Close();
     }
     return scrumModel;
 }
Beispiel #5
0
 public ScrumModel GetScrumDetails(int AnswerKey)
 {
     ScrumModel scrumModel = new ScrumModel();
     using (SqlConnection sqlConnection = new SqlConnection(Constants.DATABASE.CONNECTION_STRING))
     {
         sqlConnection.Open();
         using (SqlCommand sqlCommand = new SqlCommand("SELECT * FROM ScrumAnswers WHERE AnswerKey=" + AnswerKey, sqlConnection))
         {
             using (SqlDataReader sqlDataReader = sqlCommand.ExecuteReader())
             {
                 if (sqlDataReader.HasRows)
                 {
                     scrumModel.AnswerList = new System.Collections.ArrayList();
                     while (sqlDataReader.Read())
                     {
                         Answers answers = new Answers();
                         answers.QuestionId = Convert.ToInt32(sqlDataReader["QuestionId"]);
                         answers.Answer = Convert.ToString(sqlDataReader["Answer"]);
                         scrumModel.AnswerList.Add(answers);
                     }
                 }
                 sqlDataReader.Close();
             }
         }
         sqlConnection.Close();
     }
     return scrumModel;
 }
Beispiel #6
0
 public bool EditScrum(ScrumModel scrumModel)
 {
     try
     {
         using (SqlConnection sqlConnection = new SqlConnection(Constants.DATABASE.CONNECTION_STRING))
         {
             sqlConnection.Open();
             foreach (Answers answer in scrumModel.AnswerList)
             {
                 using (SqlCommand sqlCommand = new SqlCommand("Update ScrumAnswers SET  Answer = @Answer, DateModified = @DateModified WHERE QuestionId = @QuestionId AND AnswerKey = @AnswerKey", sqlConnection))
                 {
                     sqlCommand.Parameters.Add(new SqlParameter("Answer", answer.Answer));
                     sqlCommand.Parameters.Add(new SqlParameter("DateModified", DateTime.Now));
                     sqlCommand.Parameters.Add(new SqlParameter("QuestionId", answer.QuestionId));
                     sqlCommand.Parameters.Add(new SqlParameter("AnswerKey", answer.AnswerKey));
                     sqlCommand.ExecuteNonQuery();
                 }
             }
             sqlConnection.Close();
         }
         return true;
     }
     catch
     {
         return false;
     }
 }
Beispiel #7
0
 public bool InputNewScrum(ScrumModel scrum)
 {
     return new ScrumDAL().InputNewScrum(scrum);
 }
Beispiel #8
0
 public bool EditScrum(ScrumModel scrum)
 {
     return new ScrumDAL().EditScrum(scrum);
 }
        public void TestInputNewScrum()
        {
            ScrumModel scrumModel = new ScrumModel();
            scrumModel.AnswerList = new System.Collections.ArrayList();

            Answers answers = new Answers();
            answers.Answer = "Worked on Unit Test Cases";
            answers.QuestionId = 1;
            answers.UserId = 1;
            scrumModel.AnswerList.Add(answers);

            answers = new Answers();
            answers.Answer = "Worked on Scrum Room";
            answers.QuestionId = 2;
            answers.UserId = 1;
            scrumModel.AnswerList.Add(answers);

            answers = new Answers();
            answers.Answer = "None";
            answers.QuestionId = 3;
            answers.UserId = 1;
            scrumModel.AnswerList.Add(answers);

            Assert.IsTrue(new ScrumController().InputNewScrum(scrumModel));
        }
Beispiel #10
0
        public ScrumModel ViewScrumDataByDate(string date, string nextDay)
        {
            ScrumModel scrumModel = new ScrumModel();
            using (SqlConnection sqlConnection = new SqlConnection(Constants.DATABASE.CONNECTION_STRING))
            {
                sqlConnection.Open();

                string sqlString = "SELECT Users.FirstName, Users.LastName, dbo.ScrumQuestions.ScrumQuestion, ScrumAnswers. * " +
                                   "FROM ScrumAnswers " +
                                   "INNER JOIN dbo.ScrumQuestions ON dbo.ScrumQuestions.ScrumQuestionId = dbo.ScrumAnswers.QuestionId " +
                                   "INNER JOIN dbo.Users ON dbo.Users.UserID = dbo.ScrumAnswers.UserId WHERE " +
                                   "ScrumAnswers.DateEntered >= '"  + date + "' " +
                                   "AND ScrumAnswers.DateEntered < '" + nextDay + "' " +
                                   "ORDER BY ScrumAnswers.DateEntered, Users.LastName, ScrumAnswers.QuestionId";
                using (SqlCommand sqlCommand = new SqlCommand(sqlString, sqlConnection))
                {
                    using (SqlDataReader sqlDataReader = sqlCommand.ExecuteReader())
                    {
                        if (sqlDataReader.HasRows)
                        {
                            scrumModel.ScrumList = new System.Collections.ArrayList();
                            while (sqlDataReader.Read())
                            {
                                ScrumData scrumData = new ScrumData();
                                scrumData.FirstName = Convert.ToString(sqlDataReader["FirstName"]);
                                scrumData.LastName = Convert.ToString(sqlDataReader["LastName"]);
                                scrumData.Question = Convert.ToString(sqlDataReader["ScrumQuestion"]);
                                scrumData.AnswerId = Convert.ToInt32(sqlDataReader["AnswerId"]);
                                scrumData.AnswerKey = Convert.ToInt32(sqlDataReader["AnswerKey"]);
                                scrumData.Answer = Convert.ToString(sqlDataReader["Answer"]);
                                scrumData.QuestionId = Convert.ToInt32(sqlDataReader["QuestionId"]);
                                scrumData.UserId = Convert.ToInt32(sqlDataReader["UserId"]);
                                scrumData.DateEntered = Convert.ToDateTime(sqlDataReader["DateEntered"]);
                                scrumData.DateModified = Convert.ToDateTime(sqlDataReader["DateModified"]);
                                scrumModel.ScrumList.Add(scrumData);
                            }
                        }
                        sqlDataReader.Close();
                    }
                }
                sqlConnection.Close();
            }
            return scrumModel;
        }
Beispiel #11
0
        public bool InputNewScrum(ScrumModel scrumModel)
        {
            try
            {
                using (SqlConnection sqlConnection = new SqlConnection(Constants.DATABASE.CONNECTION_STRING))
                {
                    sqlConnection.Open();
                    int sequence = 0;
                    using (SqlCommand sqlCommand = new SqlCommand("SELECT MAX(AnswerKey) As Sequence FROM ScrumAnswers", sqlConnection))
                    {
                        using (SqlDataReader sqlDataReader = sqlCommand.ExecuteReader())
                        {
                            if (sqlDataReader.HasRows)
                            {
                                if (sqlDataReader.Read())
                                {
                                    if (sqlDataReader["Sequence"] != DBNull.Value)
                                    {
                                        sequence = Convert.ToInt32(sqlDataReader["Sequence"]);
                                        sequence += 1;
                                    }
                                }

                            }
                            sqlDataReader.Close();
                        }
                    }

                    foreach (Answers answer in scrumModel.AnswerList)
                    {
                        using (SqlCommand sqlCommand = new SqlCommand("INSERT INTO ScrumAnswers VALUES (@Answer, @AnswerKey, @QuestionId, @UserId, @DateEntered, @DateModified)", sqlConnection))
                        {

                            sqlCommand.Parameters.Add(new SqlParameter("Answer", answer.Answer));
                            sqlCommand.Parameters.Add(new SqlParameter("AnswerKey", sequence));
                            sqlCommand.Parameters.Add(new SqlParameter("QuestionId", answer.QuestionId));
                            sqlCommand.Parameters.Add(new SqlParameter("UserId", answer.UserId));
                            sqlCommand.Parameters.Add(new SqlParameter("DateEntered", DateTime.Now));
                            sqlCommand.Parameters.Add(new SqlParameter("DateModified", DateTime.Now));
                            sqlCommand.ExecuteNonQuery();

                        }
                    }
                    sqlConnection.Close();
                }
                return true;
            }
            catch (Exception ex)
            {
                return false;
            }
        }