Ejemplo n.º 1
0
 //進行票券購買
 public bool BuyTicketAuto(TicketBuyer buyer)
 {
     using (TicketContextProvider context = new TicketContext())
     {
         return(context.Ticket.BuyTicketAuto(buyer));
     }
 }
Ejemplo n.º 2
0
        public TicketBuyer GetRandomTicket(IEnumerable <TicketEventStatus> status)
        {
            var _items = status.Where(x => x.TicketLeft > 0).ToArray();
            var _index = this._random.Next(0, _items.Length);

            TicketBuyer _buyer = new TicketBuyer();

            _buyer.memberGUID    = Guid.NewGuid();
            _buyer.GateNo        = _items[_index].TicketGateNo;
            _buyer.TicketEventNo = 1;
            _buyer.TicketCount   = this._random.Next(1, 5);

            return(_buyer);
        }
Ejemplo n.º 3
0
        public bool BuyTicketAuto(TicketBuyer buyer)
        {
            using (SqlConnection _conn = new SqlConnection())
            {
                _conn.ConnectionString = this._connectionString;

                SqlCommand _cmd;

                _cmd            = new SqlCommand();
                _cmd.Connection = _conn;

                _cmd.CommandText = "[Tickets].[BuyTicketAuto]";
                _cmd.CommandType = CommandType.StoredProcedure;

                _cmd.Parameters.Add("@TicketEventNo", SqlDbType.Int);
                _cmd.Parameters.Add("@GateNo", SqlDbType.Int);
                _cmd.Parameters.Add("@memberGUID", SqlDbType.UniqueIdentifier);
                _cmd.Parameters.Add("@TicketCount", SqlDbType.TinyInt);
                _cmd.Parameters.Add("@IsSuccess", SqlDbType.Bit);


                _cmd.Parameters["@TicketEventNo"].Value = buyer.TicketEventNo;
                _cmd.Parameters["@GateNo"].Value        = buyer.GateNo;
                _cmd.Parameters["@memberGUID"].Value    = buyer.memberGUID;
                _cmd.Parameters["@TicketCount"].Value   = buyer.TicketCount;
                _cmd.Parameters["@IsSuccess"].Value     = DBNull.Value;

                _cmd.Parameters["@IsSuccess"].Direction = ParameterDirection.Output;

                _conn.Open();
                _cmd.ExecuteNonQuery();
                _conn.Close();

                if (_cmd.Parameters["@IsSuccess"].Value == DBNull.Value)
                {
                    return(false);
                }

                return(Convert.ToBoolean(_cmd.Parameters["@IsSuccess"].Value));
            }
        }