Example #1
0
        public void UpdateArchiveBookingByID(int id, ArchiveBooking booking)
        {
            if (id == 0)
            {
                throw new IndexOutOfRangeException("Invalid id.");
            }

            if (booking == null)
            {
                throw new IndexOutOfRangeException("Empty booking.");
            }

            ArchiveBooking oldBooking = context.ArchiveBookings.Where(a => a.ID_ArchiveBooking == id).FirstOrDefault();

            if (oldBooking == null)
            {
                //throw new ArgumentNullException("No booking with that id in db.");
                return;
            }
            oldBooking.ID_ArchiveCode = booking.ID_ArchiveCode;
            oldBooking.DocumentNumber = booking.DocumentNumber;
            oldBooking.Date           = booking.Date;
            oldBooking.Year           = booking.Year;
            oldBooking.ID_Sender      = booking.ID_Sender;
            oldBooking.Subject        = booking.Subject;
            oldBooking.EntryCode      = booking.EntryCode;
            context.ArchiveBookings.Update(oldBooking);
            context.SaveChanges();
        }
        // GET: PreSchedules
        public ActionResult Index()
        {
            var preSchedules = db.PreSchedules.Include(p => p.Resources);

            foreach (var pre in preSchedules.ToList())
            {
                ArchiveBooking Archive = new ArchiveBooking();
                if (pre.end <= DateTime.Now)
                {
                    var Find = db.PreSchedules.Find(pre.PreId);
                    //Add it to the new class
                    Archive.PreId           = Find.PreId;
                    Archive.RefNum          = Find.RefNum;
                    Archive.ContainerSize   = Find.ContainerSize;
                    Archive.pickupLocation  = Find.pickupLocation;
                    Archive.dropoffLocation = Find.dropoffLocation;
                    Archive.transportType   = Find.transportType;
                    Archive.start           = Find.start;
                    Archive.end             = Find.end;
                    Archive.transit         = Find.transit;
                    Archive.Booked          = Find.Booked;
                    Archive.id = Find.id;
                    db.ArchiveBookings.Add(Archive);
                    db.SaveChanges();
                    //Deletes The Selected Records
                    db.PreSchedules.Remove(Find);
                    db.SaveChanges();
                }
            }
            return(View(preSchedules.ToList()));
        }
Example #3
0
        public void InsertArchiveBooking()
        {
            //Arrange
            var          archiveBookingEngine = new ArchiveBookingEngine();
            const int    ID             = 100;
            const int    ID_ArchiveCode = 22;
            const string DocumentNumber = "03";
            DateTime     Date           = new DateTime(2020, 03, 03);
            const int    Year           = 20;
            const string Subject        = "ghjkfl";
            const int    ID_Sender      = 2;
            const string EntryCode      = "04-02/20";

            //Act
            ArchiveBooking booking = new ArchiveBooking(ID, ID_ArchiveCode, DocumentNumber, Date.Date, Year, Subject, ID_Sender, EntryCode);

            archiveBookingEngine.InsertArchiveBooking(booking);
            booking = null;
            booking = archiveBookingEngine.GetArchiveBookingByDocumentNumber(DocumentNumber);

            //Assert
            Assert.NotNull(booking);
            Assert.Equal(22, booking.ID_ArchiveCode);
            Assert.Equal("03", booking.DocumentNumber);
            Assert.Equal(new DateTime(2020, 03, 03), booking.Date);
            Assert.Equal(20, booking.Year);
            Assert.Equal("ghjkfl", booking.Subject);
            Assert.Equal(2, booking.ID_Sender);
            Assert.Equal("04-02/20", booking.EntryCode);
        }
Example #4
0
        public void InsertArchiveBooking(ArchiveBooking booking)
        {
            if (booking == null)
            {
                throw new Exception("parameter booking is null.");
            }

            using (connection = new SqlConnection(connectionString))
            {
                connection.Open();

                using (adapter = new SqlDataAdapter())
                {
                    string sql = "INSERT INTO ArchiveBooking(ID_ArchiveCode, DocumentNumber, Date, Year, Subject, ID_Sender, EntryCode) VALUES(" +
                                 "@archiveCode, @docNumber, @date, @year, @subject, @sender, @entryCode)";
                    command = new SqlCommand(sql, connection);
                    command.Parameters.AddWithValue("@archiveCode", booking.ID_ArchiveCode);
                    command.Parameters.AddWithValue("@docNumber", booking.DocumentNumber);
                    command.Parameters.AddWithValue("@date", booking.Date);
                    command.Parameters.AddWithValue("@year", booking.Year);
                    command.Parameters.AddWithValue("@subject", booking.Subject);
                    command.Parameters.AddWithValue("@sender", booking.ID_Sender);
                    command.Parameters.AddWithValue("@entryCode", booking.EntryCode);
                    adapter.InsertCommand = command;
                    adapter.InsertCommand.ExecuteNonQuery();
                }
                command.Dispose();
                connection.Close();
            }
        }
Example #5
0
        public void DeleteBookingsByDate()
        {
            //Arrange
            var archiveBookingEngine             = new ArchiveBookingEngine();
            List <ArchiveBooking> bookings       = new List <ArchiveBooking>();
            const int             ID             = 100;
            const int             ID_ArchiveCode = 22;
            const string          DocumentNumber = "23";
            DateTime     Date      = new DateTime(2020, 08, 08);
            const int    Year      = 20;
            const string Subject   = "ghjkfl";
            const int    ID_Sender = 2;
            const string EntryCode = "04-02/20";

            //Act
            ArchiveBooking booking = new ArchiveBooking(ID, ID_ArchiveCode, DocumentNumber, Date.Date, Year, Subject, ID_Sender, EntryCode);

            archiveBookingEngine.InsertArchiveBooking(booking);
            archiveBookingEngine.DeleteArchiveBookingsByDate(Date);
            bookings = archiveBookingEngine.GetArchiveBookingsByDate(Date);

            //Assert
            foreach (ArchiveBooking b in bookings)
            {
                Assert.Null(b.DocumentNumber);
            }
        }
Example #6
0
        public void UpdateArchiveBookingByID()
        {
            //Arrange
            var          archiveBookingEngine = new ArchiveBookingEngine();
            const int    ID             = 100;
            const int    ID_ArchiveCode = 22;
            const string DocumentNumber = "02";
            DateTime     Date           = new DateTime(2020, 03, 03);
            const int    Year           = 20;
            const string Subject        = "grdfdger";
            const int    ID_Sender      = 2;
            const string EntryCode      = "04-02/20";

            //Act
            ArchiveBooking booking = new ArchiveBooking(ID, ID_ArchiveCode, DocumentNumber, Date.Date, Year, Subject, ID_Sender, EntryCode);

            archiveBookingEngine.UpdateArchiveBookingByID(70, booking);
            booking = null;
            booking = archiveBookingEngine.GetArchiveBookingByID(73);

            //Assert
            Assert.Equal(22, booking.ID_ArchiveCode);
            Assert.Equal("02", booking.DocumentNumber);
            Assert.Equal(Date, booking.Date);
            Assert.Equal(20, booking.Year);
            Assert.Equal("grdfdger", booking.Subject);
            Assert.Equal(2, booking.ID_Sender);
            Assert.Equal("04-02/20", booking.EntryCode);
        }
Example #7
0
        public ActionResult DeleteConfirmed(int id)
        {
            ArchiveBooking archiveBooking = db.ArchiveBookings.Find(id);

            db.ArchiveBookings.Remove(archiveBooking);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Example #8
0
        public void InsertArchiveBookings()
        {
            //Arrange
            var archiveBookingEngine              = new ArchiveBookingEngine();
            List <ArchiveBooking> bookings        = new List <ArchiveBooking>();
            List <ArchiveBooking> result          = new List <ArchiveBooking>();
            const int             ID1             = 100;
            const int             ID_ArchiveCode1 = 22;
            const string          DocumentNumber1 = "04";
            DateTime     Date1           = new DateTime(2020, 03, 03);
            const int    Year1           = 20;
            const string Subject1        = "ghjkfl";
            const int    ID_Sender1      = 2;
            const string EntryCode1      = "04-02/20";
            const int    ID2             = 100;
            const int    ID_ArchiveCode2 = 22;
            const string DocumentNumber2 = "05";
            DateTime     Date2           = new DateTime(2020, 03, 03);
            const int    Year2           = 20;
            const string Subject2        = "ghjkfl";
            const int    ID_Sender2      = 2;
            const string EntryCode2      = "04-02/20";
            const int    ID3             = 100;
            const int    ID_ArchiveCode3 = 22;
            const string DocumentNumber3 = "06";
            DateTime     Date3           = new DateTime(2020, 03, 03);
            const int    Year3           = 20;
            const string Subject3        = "ghjkfl";
            const int    ID_Sender3      = 2;
            const string EntryCode3      = "04-02/20";

            //Act
            ArchiveBooking booking1 = new ArchiveBooking(ID1, ID_ArchiveCode1, DocumentNumber1, Date1.Date, Year1, Subject1, ID_Sender1, EntryCode1);
            ArchiveBooking booking2 = new ArchiveBooking(ID2, ID_ArchiveCode2, DocumentNumber2, Date2.Date, Year2, Subject2, ID_Sender2, EntryCode2);
            ArchiveBooking booking3 = new ArchiveBooking(ID3, ID_ArchiveCode3, DocumentNumber3, Date3.Date, Year3, Subject3, ID_Sender3, EntryCode3);

            bookings.Add(booking1);
            bookings.Add(booking2);
            bookings.Add(booking3);
            archiveBookingEngine.InsertArchiveBookings(bookings);
            result.Add(archiveBookingEngine.GetArchiveBookingByDocumentNumber(DocumentNumber1));
            result.Add(archiveBookingEngine.GetArchiveBookingByDocumentNumber(DocumentNumber2));
            result.Add(archiveBookingEngine.GetArchiveBookingByDocumentNumber(DocumentNumber3));

            //Assert
            Assert.NotNull(result);
            Assert.Equal(bookings.Count, result.Count);
            for (int i = 0; i < result.Count; i++)
            {
                Assert.Equal(bookings[i].ID_ArchiveCode, result[i].ID_ArchiveCode);
                Assert.Equal(bookings[i].DocumentNumber, result[i].DocumentNumber);
                Assert.Equal(bookings[i].Date, result[i].Date);
                Assert.Equal(bookings[i].Year, result[i].Year);
                Assert.Equal(bookings[i].Subject, result[i].Subject);
                Assert.Equal(bookings[i].ID_Sender, result[i].ID_Sender);
                Assert.Equal(bookings[i].EntryCode, result[i].EntryCode);
            }
        }
Example #9
0
 public ActionResult Edit([Bind(Include = "PreId,RefNum,ContainerSize,pickupLocation,dropoffLocation,transportType,start,end,transit,Booked,id")] ArchiveBooking archiveBooking)
 {
     if (ModelState.IsValid)
     {
         db.Entry(archiveBooking).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(archiveBooking));
 }
Example #10
0
        public List <ArchiveBooking> GetArchiveBookingsBySender(string sender)
        {
            if (sender == null)
            {
                throw new IndexOutOfRangeException("No booking.");
            }

            List <ArchiveBooking> result = new List <ArchiveBooking>();

            using (connection = new SqlConnection(connectionString))
            {
                connection.Open();

                string sql = "SELECT ID_Sender FROM Sender WHERE SenderName=@sender";
                int    id  = 0;
                command = new SqlCommand(sql, connection);
                command.Parameters.AddWithValue("@sender", sender);

                using (reader = command.ExecuteReader())
                {
                    if (reader.Read())
                    {
                        id = reader.GetInt32(0);
                    }
                }

                sql     = "SELECT * FROM ArchiveBooking WHERE ID_Sender=@id";
                command = new SqlCommand(sql, connection);
                command.Parameters.AddWithValue("@id", id);

                using (reader = command.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        ArchiveBooking booking = new ArchiveBooking();

                        booking.ID_ArchiveBooking = reader.GetInt32("ID_ArchiveBooking");
                        booking.ID_ArchiveCode    = reader.GetInt32("ID_ArchiveCode");
                        booking.DocumentNumber    = reader.GetString("DocumentNumber");
                        booking.Date      = reader.GetDateTime("Date");
                        booking.Year      = reader.GetInt32("Year");
                        booking.Subject   = reader.GetString("Subject");
                        booking.ID_Sender = reader.GetInt32("ID_Sender");
                        booking.EntryCode = reader.GetString("EntryCode");

                        result.Add(booking);
                    }
                }
                reader.Close();
                command.Dispose();
                connection.Close();
            }

            return(result);
        }
Example #11
0
        public void InsertArchiveBooking(ArchiveBooking booking)
        {
            if (booking == null)
            {
                throw new Exception("Empty booking.");
            }

            booking.ID_ArchiveBooking = null;

            context.ArchiveBookings.Add(booking);
            context.Entry <ArchiveBooking>(booking).State = EntityState.Detached;
            context.SaveChanges();
        }
Example #12
0
        public void DeleteBookingsBySubject()
        {
            //Arrange
            var            archiveBookingEngine = new ArchiveBookingEngine();
            ArchiveBooking booking = new ArchiveBooking();

            //Act
            archiveBookingEngine.DeleteArchiveBookingsBySubject("fhjerk");
            booking = null;
            booking = archiveBookingEngine.GetArchiveBookingByDocumentNumber("11");

            //Assert
            Assert.Null(booking.DocumentNumber);
        }
Example #13
0
        // GET: ArchiveBookings/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            ArchiveBooking archiveBooking = db.ArchiveBookings.Find(id);

            if (archiveBooking == null)
            {
                return(HttpNotFound());
            }
            return(View(archiveBooking));
        }
Example #14
0
        public void DeleteBookingById()
        {
            //Arrange
            var archiveBookingEngine = new ArchiveBookingEngine();

            //Act
            archiveBookingEngine.DeleteArchiveBookingById(77);
            ArchiveBooking booking = null;

            booking = archiveBookingEngine.GetArchiveBookingByID(77);

            //Assert
            Assert.Null(booking.DocumentNumber);
        }
Example #15
0
        public void DeleteBookingsByYear()
        {
            //Arrange
            var            archiveBookingEngine = new ArchiveBookingEngine();
            ArchiveBooking booking = new ArchiveBooking();

            //Act
            archiveBookingEngine.DeleteArchiveBookingsByYear(22);
            booking = null;
            booking = archiveBookingEngine.GetArchiveBookingByDocumentNumber("08");

            //Assert
            Assert.Null(booking.DocumentNumber);
        }
Example #16
0
        public void DeleteBookingsBySenderID()
        {
            //Arrange
            var            archiveBookingEngine = new ArchiveBookingEngine();
            ArchiveBooking booking = new ArchiveBooking();

            //Act
            archiveBookingEngine.DeleteArchiveBookingsBySenderID(2);
            booking = null;
            List <ArchiveBooking> bookings = archiveBookingEngine.GetArchiveBookingsBySender("gfdshgt");

            //Assert
            Assert.Empty(bookings);
        }
Example #17
0
        public void DeleteBookingsByEntryCode()
        {
            //Arrange
            var            archiveBookingEngine = new ArchiveBookingEngine();
            ArchiveBooking booking = new ArchiveBooking();

            //Act
            archiveBookingEngine.DeleteArchiveBookingsByEntryCode("07-07/20");
            booking = null;
            booking = archiveBookingEngine.GetArchiveBookingByEntryCode("07-07/20");

            //Assert
            Assert.Null(booking.DocumentNumber);
        }
Example #18
0
        public void DeleteBookingsBySubject()
        {
            //Arrange
            var            archiveBookingEngine = new ArchiveBookingEngine();
            ArchiveBooking booking = new ArchiveBooking();

            //Act
            archiveBookingEngine.DeleteArchiveBookingsBySubject("fhjerk");
            booking = null;
            List <ArchiveBooking> bookings = archiveBookingEngine.GetArchiveBookingsBySubject("fhjerk");

            //Assert
            Assert.Empty(bookings);
        }
Example #19
0
        public void DeleteBookingsBySenderID()
        {
            //Arrange
            var            archiveBookingEngine = new ArchiveBookingEngine();
            ArchiveBooking booking = new ArchiveBooking();

            //Act
            archiveBookingEngine.DeleteArchiveBookingsBySenderID(3);
            booking = null;
            List <ArchiveBooking> bookings = archiveBookingEngine.GetArchiveBookingsBySender("gtdhtd");

            //Assert
            foreach (ArchiveBooking b in bookings)
            {
                Assert.Null(b);
            }
        }
Example #20
0
        public void DeleteArchiveBookingById(int id)
        {
            if (id == 0)
            {
                throw new IndexOutOfRangeException("Invalid id.");
            }

            ArchiveBooking booking = context.ArchiveBookings.Where(a => a.ID_ArchiveBooking == id).FirstOrDefault();

            if (booking == null)
            {
                //throw new ArgumentNullException("No booking with that id in db.");
                return;
            }
            context.ArchiveBookings.Remove(booking);
            context.SaveChanges();
        }
Example #21
0
        public void DeleteArchiveBookingByDocumentNumber(string number)
        {
            if (number == null)
            {
                throw new IndexOutOfRangeException("Invalid DocumentNumber.");
            }

            ArchiveBooking booking = context.ArchiveBookings.Where(a => a.DocumentNumber == number).FirstOrDefault();

            if (booking == null)
            {
                //throw new ArgumentNullException("No booking with that Document Number in db.");
                return;
            }
            context.ArchiveBookings.Remove(booking);
            context.SaveChanges();
        }
Example #22
0
        public void DeleteArchiveBookingsByEntryCode(string entryCode)
        {
            if (entryCode == null)
            {
                throw new IndexOutOfRangeException("Invalid entryCode.");
            }

            ArchiveBooking booking = context.ArchiveBookings.Where(a => a.EntryCode == entryCode).FirstOrDefault();

            if (booking == null)
            {
                //throw new ArgumentNullException("No booking with that Entry Code in db.");
                return;
            }
            context.ArchiveBookings.Remove(booking);
            context.SaveChanges();
        }
Example #23
0
        public void GetBookingByDocumentNumber()
        {
            //Arrange
            var archiveBookingEngine = new ArchiveBookingEngine();

            //Act
            ArchiveBooking booking = archiveBookingEngine.GetArchiveBookingByDocumentNumber("05");

            //Assert
            Assert.Equal(69, booking.ID_ArchiveBooking);
            Assert.Equal(24, booking.ID_ArchiveCode);
            Assert.Equal("05", booking.DocumentNumber);
            Assert.Equal(new DateTime(2020, 05, 03), booking.Date);
            Assert.Equal(20, booking.Year);
            Assert.Equal("grsgr", booking.Subject);
            Assert.Equal(2, booking.ID_Sender);
            Assert.Equal("04-03/20", booking.EntryCode);
        }
Example #24
0
        public void GetBookingByEntryCode()
        {
            //Arrange
            var archiveBookingEngine = new ArchiveBookingEngine();

            //Act
            ArchiveBooking booking = archiveBookingEngine.GetArchiveBookingByEntryCode("04-02/20");

            //Assert
            Assert.Equal(122, booking.ID_ArchiveBooking);
            Assert.Equal(22, booking.ID_ArchiveCode);
            Assert.Equal("02", booking.DocumentNumber);
            Assert.Equal(new DateTime(2020, 03, 03), booking.Date);
            Assert.Equal(20, booking.Year);
            Assert.Equal("ghjkfl", booking.Subject);
            Assert.Equal(2, booking.ID_Sender);
            Assert.Equal("04-02/20", booking.EntryCode);
        }
Example #25
0
        public List <ArchiveBooking> GetArchiveBookingsByYear(int year)
        {
            if (year == 0)
            {
                throw new IndexOutOfRangeException("Year cannot be null.");
            }

            List <ArchiveBooking> result = new List <ArchiveBooking>();

            using (connection = new SqlConnection(connectionString))
            {
                connection.Open();

                string sql = "SELECT * FROM ArchiveBooking WHERE Year=@year";
                command = new SqlCommand(sql, connection);
                command.Parameters.AddWithValue("@year", year);

                using (reader = command.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        ArchiveBooking booking = new ArchiveBooking();

                        booking.ID_ArchiveBooking = reader.GetInt32("ID_ArchiveBooking");
                        booking.ID_ArchiveCode    = reader.GetInt32("ID_ArchiveCode");
                        booking.DocumentNumber    = reader.GetString("DocumentNumber");
                        booking.Date      = reader.GetDateTime("Date");
                        booking.Year      = reader.GetInt32("Year");
                        booking.Subject   = reader.GetString("Subject");
                        booking.ID_Sender = reader.GetInt32("ID_Sender");
                        booking.EntryCode = reader.GetString("EntryCode");

                        result.Add(booking);
                    }
                }
                reader.Close();
                command.Dispose();
                connection.Close();
            }

            return(result);
        }
Example #26
0
        public ArchiveBooking GetArchiveBookingByID(int id)
        {
            if (id == 0)
            {
                throw new IndexOutOfRangeException("ID cannot be 0.");
            }

            ArchiveBooking booking = new ArchiveBooking();

            using (connection = new SqlConnection(connectionString))
            {
                connection.Open();

                string sql = "SELECT * FROM ArchiveBooking WHERE ID_ArchiveBooking=@id";
                command = new SqlCommand(sql, connection);
                command.Parameters.AddWithValue("@id", id);

                using (reader = command.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        booking.ID_ArchiveBooking = reader.GetInt32("ID_ArchiveBooking");
                        booking.ID_ArchiveCode    = reader.GetInt32("ID_ArchiveCode");
                        booking.DocumentNumber    = reader.GetString("DocumentNumber");
                        booking.Date      = reader.GetDateTime("Date");
                        booking.Year      = reader.GetInt32("Year");
                        booking.Subject   = reader.GetString("Subject");
                        booking.ID_Sender = reader.GetInt32("ID_Sender");
                        booking.EntryCode = reader.GetString("EntryCode");
                    }

                    reader.Close();
                    command.Dispose();
                    connection.Close();
                }
            }

            return(booking);
        }
Example #27
0
        public void UpdateArchiveBookingByID(int id, ArchiveBooking booking)
        {
            if (id == 0)
            {
                throw new IndexOutOfRangeException("No booking.");
            }

            if (booking == null)
            {
                throw new IndexOutOfRangeException("No booking.");
            }

            using (connection = new SqlConnection(connectionString))
            {
                connection.Open();

                using (adapter = new SqlDataAdapter())
                {
                    string sql = "UPDATE ArchiveBooking SET ID_ArchiveCode = @archiveCode, DocumentNumber = @docNumber, Date = @date, " +
                                 "Year = @year, Subject = @subject, ID_Sender = @sender, EntryCode = @entryCode WHERE ID_ArchiveBooking = @id";

                    command = new SqlCommand(sql, connection);
                    command.Parameters.AddWithValue("@archiveCode", booking.ID_ArchiveCode);
                    command.Parameters.AddWithValue("@docNumber", booking.DocumentNumber);
                    command.Parameters.AddWithValue("@date", booking.Date);
                    command.Parameters.AddWithValue("@year", booking.Year);
                    command.Parameters.AddWithValue("@subject", booking.Subject);
                    command.Parameters.AddWithValue("@sender", booking.ID_Sender);
                    command.Parameters.AddWithValue("@entryCode", booking.EntryCode);
                    command.Parameters.AddWithValue("@id", id);
                    adapter.UpdateCommand = command;
                    adapter.UpdateCommand.ExecuteNonQuery();
                }
                command.Dispose();
                connection.Close();
            }
        }
Example #28
0
        public List <ArchiveBooking> GetArchiveBookings()
        {
            List <ArchiveBooking> result = new List <ArchiveBooking>();

            using (connection = new SqlConnection(connectionString))
            {
                connection.Open();

                string sql = "SELECT * FROM ArchiveBooking";
                command = new SqlCommand(sql, connection);

                using (reader = command.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        ArchiveBooking booking = new ArchiveBooking();

                        booking.ID_ArchiveBooking = reader.GetInt32("ID_ArchiveBooking");
                        booking.ID_ArchiveCode    = reader.GetInt32("ID_ArchiveCode");
                        booking.DocumentNumber    = reader.GetString("DocumentNumber");
                        booking.Date      = reader.GetDateTime("Date");
                        booking.Year      = reader.GetInt32("Year");
                        booking.Subject   = reader.GetString("Subject");
                        booking.ID_Sender = reader.GetInt32("ID_Sender");
                        booking.EntryCode = reader.GetString("EntryCode");

                        result.Add(booking);
                    }
                }

                reader.Close();
                command.Dispose();
                connection.Close();
            }

            return(result);
        }
Example #29
0
        public void DeleteBookingsByDocumentNumber()
        {
            //Arrange
            var          archiveBookingEngine = new ArchiveBookingEngine();
            const int    ID             = 100;
            const int    ID_ArchiveCode = 22;
            const string DocumentNumber = "48";
            DateTime     Date           = new DateTime(2020, 03, 03);
            const int    Year           = 20;
            const string Subject        = "ghjkfl";
            const int    ID_Sender      = 2;
            const string EntryCode      = "04-02/20";

            //Act
            ArchiveBooking booking = new ArchiveBooking(ID, ID_ArchiveCode, DocumentNumber, Date.Date, Year, Subject, ID_Sender, EntryCode);

            archiveBookingEngine.InsertArchiveBooking(booking);
            archiveBookingEngine.DeleteArchiveBookingsByDocumentNumber(DocumentNumber);
            booking = null;
            booking = archiveBookingEngine.GetArchiveBookingByDocumentNumber(DocumentNumber);

            //Assert
            Assert.Null(booking.DocumentNumber);
        }