Esempio n. 1
0
        public void TestTicketDao_AddTicket()
        {
            Ticket ticket = new Ticket();
            ticket.Id = "09XXXXXXXX-2999/13/3325:61:62";
            ticket.Name = "單元測試";
            ticket.Phone = "09XXXXXXXX";
            ticket.Quantity = "X張";
            ticket.Date = "2999/13/33";
            ticket.Time = "25:61:62";
            ticket.Aboard = "金門";
            ticket.Getoff = "馬祖";
            ticket.Number = "1000";
            ticket.Price = "50000";
            TicketDao.AddTicket(ticket);

            Ticket dbTicket = TicketDao.GetTicketByName(ticket.Phone);
            Assert.IsNotNull(dbTicket);
            Assert.AreEqual(ticket.Name, dbTicket.Name);

            Console.WriteLine("訂票編號為 = " + dbTicket.Id);
            Console.WriteLine("訂票人為 = " + dbTicket.Name);
            Console.WriteLine("手機為 = " + dbTicket.Phone);
            Console.WriteLine("訂票數量為 = " + dbTicket.Quantity);
            Console.WriteLine("乘車日期為 = " + dbTicket.Date);
            Console.WriteLine("乘車時間為 = " + dbTicket.Time);
            Console.WriteLine("上車站為 = " + dbTicket.Aboard);
            Console.WriteLine("下車站為 = " + dbTicket.Getoff);
            Console.WriteLine("車次為 = " + dbTicket.Number);
            Console.WriteLine("總金額為 = " + dbTicket.Price);

               /* TicketDao.DeleteTicket(dbTicket);
            dbTicket = TicketDao.GetTicketByName(ticket.Phone);
            Assert.IsNull(dbTicket);*/
        }
Esempio n. 2
0
        public void DeleteTicket(Ticket ticket)
        {
            ticket = TicketDao.GetTicketByName(ticket.Name);

            if (ticket != null)
            {
                TicketDao.DeleteTicket(ticket);
            }
        }
Esempio n. 3
0
 public void DeleteEmployee(Ticket ticket)
 {
     try
     {
         TicketService.DeleteTicket(ticket);
     }
     catch (Exception)
     {
         throw new HttpResponseException(HttpStatusCode.InternalServerError);
     }
 }
Esempio n. 4
0
        public Ticket AddTicket(Ticket ticket)
        {
            CheckTicketIsNotNullThrowException(ticket);

            try
            {
                return TicketService.AddTicket(ticket);
            }
            catch (Exception)
            {
                throw new HttpResponseException(HttpStatusCode.InternalServerError);
            }
        }
Esempio n. 5
0
        public Ticket UpdateTicket(Ticket ticket)
        {
            CheckTicketIsNullThrowException(ticket);

            try
            {
                TicketService.UpdateTicket(ticket);
                return TicketService.GetTicketByName(ticket.Name);
            }
            catch (Exception)
            {
                throw new HttpResponseException(HttpStatusCode.InternalServerError);
            }
        }
Esempio n. 6
0
        /// <summary>
        ///     檢查課程資料是否存在,如果不存在則拋出錯誤.
        /// </summary>
        /// <param name="ticket">
        ///     課程資料.
        /// </param>
        private void CheckTicketIsNullThrowException(Ticket ticket)
        {
            Ticket Ticket = TicketService.GetTicketById(ticket.Id);

            if (Ticket == null)
            {
                throw new HttpResponseException(HttpStatusCode.NotFound);
            }
        }
Esempio n. 7
0
        /// <summary>
        ///     檢查課程資料是否存在,如果存在則拋出錯誤.
        /// </summary>
        /// <param name="ticket">
        ///     課程資料.
        /// </param>
        private void CheckTicketIsNotNullThrowException(Ticket ticket)
        {
            Ticket dbTicket = TicketService.GetTicketById(ticket.Id);

            if (dbTicket != null)
            {
                throw new HttpResponseException(HttpStatusCode.Conflict);
            }
        }
Esempio n. 8
0
 public void UpdateTicket(Ticket ticket)
 {
     TicketDao.UpdateTicket(ticket);
 }
Esempio n. 9
0
 public Ticket AddTicket(Ticket ticket)
 {
     TicketDao.AddTicket(ticket);
     return GetTicketByName(ticket.Name);
 }