Example #1
0
 //purchase ticket
 public int updateTicket(EventTicket _ticket)
 {
     try
     {
         using (EventrixDBDataContext dbd = new EventrixDBDataContext())
         {
             int isAvail = (from st in dbd.Guest_Tickets where st.ticket_temp_id.Equals(_ticket._TicketID) && st.G_ID.Equals(_ticket._GuestID) select st).Count();
             if (isAvail != 0)
             {
                 return(0);    //ticket already exist
             }
             else  //update available tickets
             {
                 Guest_Ticket toInsert = new Guest_Ticket();
                 toInsert.ticket_temp_id = _ticket._TicketID;
                 toInsert.G_ID           = _ticket._GuestID;
                 toInsert.numTicket      = _ticket.numTicket;
                 dbd.Guest_Tickets.InsertOnSubmit(toInsert);
                 dbd.SubmitChanges();
             }
         }
         using (EventrixDBDataContext dbd = new EventrixDBDataContext())
         {
             Guest_Ticket toInsert = (from st in dbd.Guest_Tickets where st.ticket_temp_id.Equals(_ticket._TicketID) && st.G_ID.Equals(_ticket._GuestID) select st).First();
             int          ID       = toInsert.ticket_Id;
             return(ID);
         };
     }
     catch (Exception)
     {
         return(-1);
     }
 }
Example #2
0
        public int purchaseTicket(EventTicket _ticket)
        {
            string tracker = "";

            using (EventrixDBDataContext dbd = new EventrixDBDataContext())
            {
                try
                {
                    Guest_Ticket toInsert = new Guest_Ticket();
                    toInsert.G_ID           = _ticket._GuestID;
                    toInsert.ticket_temp_id = _ticket._TicketID;
                    //  toInsert.numTicket = 0;
                    dbd.Guest_Tickets.InsertOnSubmit(toInsert);
                    dbd.SubmitChanges();
                    tracker = "success";
                }
                catch (Exception)
                {
                    return(0);
                }
            };
            using (EventrixDBDataContext db = new EventrixDBDataContext())
            {
                if (tracker.Equals("success"))
                {
                    var          query = (from tk in db.Guest_Tickets select tk).ToList();
                    Guest_Ticket tick  = query.Last();
                    int          ID    = tick.ticket_Id;
                    return(ID);
                }
                else
                {
                    return(0);
                }
            };
        }