Beispiel #1
0
        /**
         * Purpose: Update this Incident in the database
         * Arguments:
         *     void
         * Return:
         *     void
         */
        public void update()
        {
            string query = $"UPDATE Incident SET Resolution = \"{this.Resolution}\", DateResolved = {this.DateResolved.Value.ToString("yyyyMMdd")} "
                           + $"WHERE IncidentId = {this.IncidentId}";
            BangazonConnection conn = new BangazonConnection();

            conn.insert(query);
        }
Beispiel #2
0
        /**
         * Purpose: Insert this Incident into the database via SQL
         * Arguments:
         *     void
         * Return:
         *     void
         */
        public void save()
        {
            string query;

            if (this.Resolution == null)
            {
                query = "INSERT INTO Incident (OrderId,EmployeeId,IncidentTypeId,Resolution,DateResolved) "
                        + $"VALUES ({this.OrderId},{this.EmployeeId},{this.IncidentTypeId},'',null)";
            }
            else
            {
                query = "INSERT INTO Incident (OrderId,EmployeeId,IncidentTypeId,Resolution,DateResolved) "
                        + $"VALUES ({this.OrderId},{this.EmployeeId},{this.IncidentTypeId},'{this.Resolution}',{this.DateResolved.Value.ToString("yyyyMMdd")})";
            }
            BangazonConnection conn = new BangazonConnection();

            conn.insert(query);
        }
Beispiel #3
0
        public void CanUpdateIncidentInDB()
        {
            var      fact = new IncidentFactory();
            Incident last = fact.getAll().Last();

            last.Resolution   = "Test Resolution";
            last.DateResolved = DateTime.Today;
            last.update();

            Incident updated = fact.get(last.IncidentId);

            Assert.Equal(updated.Resolution, last.Resolution);
            Assert.Equal(updated.DateResolved, last.DateResolved);
            // Remove Last Incident from Database
            if (last.IncidentId == updated.IncidentId)
            {
                var conn = new BangazonConnection();
                conn.insert($"DELETE FROM Incident WHERE IncidentId = {updated.IncidentId}");
            }
        }