Exemplo n.º 1
0
        public async Task <bool> AddAsync(BO.Bids obj)
        {
            try
            {
                await using (SqlConnection connection = await _context.GetConnection())
                {
                    await using (SqlCommand command = new SqlCommand("BidsAdd", connection)
                    {
                        CommandType = CommandType.StoredProcedure
                    })
                    {
                        command.Parameters.AddWithValue("@BidAmount", obj.BidAmount);
                        command.Parameters.AddWithValue("@EventId", obj.EventId);
                        command.Parameters.AddWithValue("@AuctionId", obj.AuctionId);
                        command.Parameters.AddWithValue("@UserId", obj.UserId);

                        return(await command.ExecuteNonQueryAsync() != -1);
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                return(false);
            }
        }
Exemplo n.º 2
0
        public async Task <List <BO.Bids> > ConvertToObj(SqlDataReader reader)
        {
            var objects = new List <BO.Bids>();

            while (await reader.ReadAsync())
            {
                BO.Bids obj = new BO.Bids
                {
                    Id        = int.Parse(reader["Id"].ToString()),
                    BidDate   = DateTime.Parse(reader["BidDate"].ToString()),
                    BidAmount = decimal.Parse(reader["BidAmount"].ToString()),
                    EventId   = int.Parse(reader["EventId"].ToString()),
                    AuctionId = int.Parse(reader["AuctionId"].ToString()),
                    UserId    = int.Parse(reader["UserId"].ToString())
                };

                objects.Add(obj);
            }

            return(objects);
        }
Exemplo n.º 3
0
        public async Task <BO.Bids> GetThrowbackAsync(BO.WithdrawHistory obj)
        {
            try
            {
                await using (SqlConnection connection = await _context.GetConnection())
                {
                    await using (SqlCommand command = new SqlCommand("GetWithdrawThrowback", connection)
                    {
                        CommandType = CommandType.StoredProcedure
                    })
                    {
                        command.Parameters.AddWithValue("@BidderId", obj.UserId);
                        command.Parameters.AddWithValue("@AuctionId", obj.AuctionId);
                        command.Parameters.AddWithValue("@EventId", obj.EventId);

                        await using SqlDataReader reader = command.ExecuteReader();
                        var objBidHistory = new BO.Bids();
                        while (await reader.ReadAsync())
                        {
                            objBidHistory.Id        = int.Parse(reader["Id"].ToString());
                            objBidHistory.AuctionId = int.Parse(reader["AuctionId"].ToString());
                            objBidHistory.EventId   = int.Parse(reader["EventId"].ToString());
                            objBidHistory.UserId    = int.Parse(reader["UserId"].ToString());
                            objBidHistory.BidAmount = decimal.Parse(reader["BidAmount"].ToString());
                            objBidHistory.BidDate   = DateTime.Parse(reader["BidDate"].ToString());
                        }

                        return(objBidHistory);
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                return(null);
            }
        }
Exemplo n.º 4
0
 public async Task <bool> AddAsync(BO.Bids obj)
 {
     return(await dalBidHistories.AddAsync(obj));
 }