Exemplo n.º 1
0
        public void UpdatePrereqOverride(PrereqOverride prereq, ref List <string> errors)
        {
            var conn = new SqlConnection(ConnectionString);

            try
            {
                var adapter = new SqlDataAdapter(UpdatePrereqOverrideProcedure, conn)
                {
                    SelectCommand = { CommandType = CommandType.StoredProcedure }
                };
                adapter.SelectCommand.Parameters.Add(new SqlParameter("@student_id", SqlDbType.VarChar, 20));
                adapter.SelectCommand.Parameters.Add(new SqlParameter("@schedule_id", SqlDbType.Int));
                adapter.SelectCommand.Parameters.Add(new SqlParameter("@prof_pre_req_override_status", SqlDbType.Int));
                adapter.SelectCommand.Parameters.Add(new SqlParameter("@admin_pre_req_override_status", SqlDbType.Int));

                adapter.SelectCommand.Parameters["@student_id"].Value  = prereq.StudentId;
                adapter.SelectCommand.Parameters["@schedule_id"].Value = prereq.ScheduleId;
                adapter.SelectCommand.Parameters["@prof_pre_req_override_status"].Value  = prereq.ProfPrereqOverrideStatus;
                adapter.SelectCommand.Parameters["@admin_pre_req_override_status"].Value = prereq.AdminPrereqOverrideStatus;

                var dataSet = new DataSet();
                adapter.Fill(dataSet);
            }
            catch (Exception e)
            {
                errors.Add("Error: " + e);
            }
            finally
            {
                conn.Dispose();
            }
        }
Exemplo n.º 2
0
        public void UpdatePrereqOverride(PrereqOverride prereqOverride, ref List <string> errors)
        {
            if (prereqOverride == null)
            {
                errors.Add("Prereq Override Application cannot be null");
                //// throw new ArgumentException();
                return;
            }

            if (this.CheckStudentId(prereqOverride.StudentId) == false)
            {
                errors.Add("Invalid Student Id");
                //// throw new ArgumentException();
                return;
            }

            if (prereqOverride.ScheduleId <= 0)
            {
                errors.Add("Prereq Override Schedule cannot be null");
                //// throw new ArgumentException();
                return;
            }

            if (string.IsNullOrEmpty(prereqOverride.StudentId))
            {
                errors.Add("Student Id cannot be null");
                //// throw new ArgumentException();
                return;
            }

            this.repository.UpdatePrereqOverride(prereqOverride, ref errors);
        }
Exemplo n.º 3
0
        public List <PrereqOverride> GetPrereqOverride(int scheduleId, ref List <string> errors)
        {
            var conn       = new SqlConnection(ConnectionString);
            var prereqList = new List <PrereqOverride>();

            try
            {
                var adapter = new SqlDataAdapter(GetPrereqOverrideProcedure, conn)
                {
                    SelectCommand =
                    {
                        CommandType = CommandType.StoredProcedure
                    }
                };
                adapter.SelectCommand.CommandType = CommandType.StoredProcedure;

                adapter.SelectCommand.Parameters.Add(new SqlParameter("@schedule_id", SqlDbType.Int));

                adapter.SelectCommand.Parameters["@schedule_id"].Value = scheduleId;

                var dataSet = new DataSet();
                adapter.Fill(dataSet);

                if (dataSet.Tables[0].Rows.Count == 0)
                {
                    return(null);
                }

                for (var i = 0; i < dataSet.Tables[0].Rows.Count; i++)
                {
                    var prereq = new PrereqOverride
                    {
                        StudentId   = dataSet.Tables[0].Rows[i]["student_id"].ToString(),
                        ScheduleId  = (int)dataSet.Tables[0].Rows[i]["schedule_id"],
                        CourseTitle = dataSet.Tables[0].Rows[i]["course_title"].ToString(),
                        ProfPrereqOverrideStatus  = (int)dataSet.Tables[0].Rows[i]["prof_pre_req_override_status_flag"],
                        AdminPrereqOverrideStatus = (int)dataSet.Tables[0].Rows[i]["admin_pre_req_override_status_flag"]
                    };
                    prereqList.Add(prereq);
                }
            }
            catch (Exception e)
            {
                errors.Add("Error: " + e);
            }
            finally
            {
                conn.Dispose();
            }

            return(prereqList);
        }
Exemplo n.º 4
0
        public string UpdatePrereqOverride(PrereqOverride prereq)
        {
            var errors     = new List <string>();
            var repository = new PrereqOverrideRepository();
            var service    = new PrereqOverrideService(repository);

            service.UpdatePrereqOverride(prereq, ref errors);

            if (errors.Count == 0)
            {
                return("ok");
            }

            return("error");
        }
Exemplo n.º 5
0
        //// [ExpectedException(typeof(ArgumentException))]
        public void InsertPrereqOverrideNegativeScheduleIdTest()
        {
            //// Arrange
            var errors                = new List <string>();
            var mockRepository        = new Mock <IPrereqOverrideRepository>();
            var prereqOverrideService = new PrereqOverrideService(mockRepository.Object);
            var prereq                = new PrereqOverride {
                StudentId = "A01234567", ScheduleId = -1, ProfPrereqOverrideStatus = 1, AdminPrereqOverrideStatus = 0
            };

            //// Act
            prereqOverrideService.InsertPrereqOverride(prereq, ref errors);

            //// Assert
            Assert.AreEqual(1, errors.Count);
        }
Exemplo n.º 6
0
        //// [ExpectedException(typeof(ArgumentException))]
        public void UpdatePrereqOverrideSuccessTest()
        {
            //// Arrange
            var errors                = new List <string>();
            var mockRepository        = new Mock <IPrereqOverrideRepository>();
            var prereqOverrideService = new PrereqOverrideService(mockRepository.Object);

            var prereq = new PrereqOverride {
                StudentId = "A0123456", ScheduleId = 2, ProfPrereqOverrideStatus = 1, AdminPrereqOverrideStatus = 0
            };

            //// Act
            prereqOverrideService.UpdatePrereqOverride(prereq, ref errors);

            //// Assert
            Assert.AreEqual(0, errors.Count);
        }
Exemplo n.º 7
0
        ////[ExpectedException(typeof(ArgumentException))]
        public void UpdatePrereqOverrideEmptyStudentIdTest()
        {
            //// Arrange
            var errors                = new List <string>();
            var mockRepository        = new Mock <IPrereqOverrideRepository>();
            var prereqOverrideService = new PrereqOverrideService(mockRepository.Object);

            var prereq = new PrereqOverride {
                StudentId = string.Empty
            };

            //// Act
            prereqOverrideService.UpdatePrereqOverride(prereq, ref errors);

            //// Assert
            Assert.AreEqual(1, errors.Count);
        }