Exemple #1
0
        public List <Incident> GetAllIncidents()
        {
            List <Incident> lstIncidents   = new List <Incident>();
            DataTable       dtAllIncidents = new DataTable();

            IncidentDAL incDal = new IncidentDAL();

            dtAllIncidents = incDal.RetrieveAllIncidents();


            foreach (DataRow dr in dtAllIncidents.Rows)
            {
                Incident anIncident = new Incident();
                anIncident.IncidentID  = (int)dr["IncidentID"];
                anIncident.CustomerID  = (int)dr["CustomerID"];
                anIncident.ProductCode = (string)dr["ProductCode"];
                anIncident.TechID      = dr["TechID"] == DBNull.Value ? (int?)null : Convert.ToInt32(dr["TechID"]);
                anIncident.DateOpened  = (DateTime)dr["DateOpened"];
                anIncident.DateClosed  = dr["DateClosed"] == DBNull.Value ? (DateTime?)null : Convert.ToDateTime(dr["DateClosed"]);
                anIncident.Title       = dr["Title"].ToString();
                anIncident.Description = dr["Description"].ToString();

                lstIncidents.Add(anIncident);
            }
            return(lstIncidents);
        }
        public List <Incident> GetAllIncidents()
        {
            List <Incident> lstIncidents   = new List <Incident>();
            DataTable       dtAllIncidents = new DataTable();
            IncidentDAL     incidentDAL    = new IncidentDAL();

            dtAllIncidents = incidentDAL.RetrieveAllIncidents();

            foreach (DataRow dr in dtAllIncidents.Rows)
            {
                Incident incidentA = new Incident();
                incidentA.IncidentID  = (int)dr["IncidentID"];
                incidentA.CustomerID  = (int)dr["CustomerID"];
                incidentA.ProductCode = dr["ProductCode"].ToString();

                //Need to account for if the TechID value returns a null value.
                if (dr["TechID"] == DBNull.Value)
                {
                    incidentA.TechID = null;
                }
                else
                {
                    incidentA.TechID = (int?)dr["TechID"];
                }

                incidentA.DateOpened = (DateTime)dr["DateOpened"];

                if (dr["DateClosed"] == DBNull.Value)
                {
                    incidentA.DateClosed = null;
                }
                else
                {
                    incidentA.DateClosed = (DateTime?)dr["DateClosed"];
                }

                incidentA.Title       = dr["Title"].ToString();
                incidentA.Description = dr["Description"].ToString();
                lstIncidents.Add(incidentA);
            }
            return(lstIncidents);
        }