public List <TTicket> SyncTicket()
        {
            try
            {
                IEnumerable <TicketHistory> changedTicketId;

                using (ThanhVanTranSysEntities context = new ThanhVanTranSysEntities())
                    using (TicketBusiness business = new TicketBusiness())
                    {
                        changedTicketId = context.TicketHistories
                                          .Where(i => i.changed_date.Year == DateTime.Now.Year && i.changed_date.Month == DateTime.Now.Month && i.changed_date.Day == DateTime.Now.Day)
                                          .OrderBy(i => i.ticket_id).ThenBy(i => i.changed_date);

                        //insert/update records
                        var tickets = (from t in business.GetAll()
                                       join th in changedTicketId on t.id equals th.ticket_id
                                       where t.departure_time >= DateTime.Now
                                       select ThriftUtil.ConvertToTTicket(t, th.action == Constants.DELETE_ACTION)).ToList();

                        //deleted records
                        tickets.AddRange((from th in changedTicketId
                                          where th.action == Constants.DELETE_ACTION
                                          select new TTicket
                        {
                            TicketId = th.ticket_id,
                            BusId = string.Empty,
                            CusIdNo = string.Empty,
                            CusName = string.Empty,
                            CusPhone = string.Empty,
                            DepartTime = DateTime.Now.ToString(),
                            IsDeleted = true,
                            SeatNo = 0,
                            SeatType = string.Empty,
                            Status = string.Empty,
                            TicketPrice = 0,
                            TourId = string.Empty,
                            UserId = string.Empty
                        }));

                        return(tickets);
                    }
            }
            catch (Exception exc)
            {
                ServerLogger.logError("[LoadTicket]", exc);
                return(new List <TTicket>());
            }
        }
 public List <TTicket> LoadTicket()
 {
     try
     {
         using (TicketBusiness business = new TicketBusiness())
         {
             return(business.GetAll().ToList()
                    .Where(i => i.departure_time >= DateTime.Now)
                    .Select(i => ThriftUtil.ConvertToTTicket(i)).ToList());
         }
     }
     catch (Exception exc)
     {
         ServerLogger.logError("[LoadTicket]", exc);
         return(new List <TTicket>());
     }
 }