public IEnumerable<Ticket> GetTicketDetails(string mobile_number) { DAL dal = new DAL(); SqlCommand cmd = new SqlCommand(); cmd.CommandText = "GetTicketDetail"; cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@mobile_number", mobile_number); DataTable dt = dal.Execute(cmd); List<Ticket> tickets = new List<Ticket>(); foreach (DataRow dr in dt.Rows) { Ticket ticket = new Ticket { passenger_id = Int64.Parse(dr["passenger_id"].ToString()), ticket_id = Int64.Parse(dr["ticket_id"].ToString()), schedule_id = Int64.Parse(dr["schedule_id"].ToString()) }; tickets.Add(ticket); } return tickets; }
public Ticket AddTicket(Ticket item ) { DAL dal = new DAL(); SqlCommand cmd = new SqlCommand(); cmd.CommandType = CommandType.StoredProcedure; cmd.CommandText = "SaveTicket"; cmd.Parameters.AddWithValue("@mobile_number", item.mobileNumber); cmd.Parameters.AddWithValue("@schedule_id", item.schedule_id); int ticketsAdded = dal.ExecuteProcNonQuery(cmd); return item; }
public Ticket AddTicket(Ticket item) { return repository.AddTicket(item); }