Exemple #1
0
        public List <OfferDal> GetOffers(int skip, int take)
        {
            List <OfferDal> proposedReturnValue = new List <OfferDal>();

            try
            {
                EnsureConnected();
                using (SqlCommand command = new SqlCommand("GetOffers", _connection))
                {
                    command.CommandType = System.Data.CommandType.StoredProcedure;
                    command.Parameters.AddWithValue("@Skip", skip);
                    command.Parameters.AddWithValue("@Take", take);
                    using (SqlDataReader reader = command.ExecuteReader())
                    {
                        OfferMapper m = new OfferMapper(reader);
                        while (reader.Read())
                        {
                            OfferDal r = m.OfferFromReader(reader);
                            proposedReturnValue.Add(r);
                        }
                    }
                }
            }
            catch (Exception ex) when(Log(ex))
            {
            }
            return(proposedReturnValue);
        }
Exemple #2
0
        //Offer
        public OfferDal FindOfferByID(int OfferID)
        {
            OfferDal ProposedReturnValue = null;

            try
            {
                EnsureConnected();
                using (SqlCommand command = new SqlCommand("FindOfferByID", _connection))
                {
                    command.CommandType = System.Data.CommandType.StoredProcedure;
                    command.Parameters.AddWithValue("@OfferID", OfferID);
                    using (SqlDataReader reader = command.ExecuteReader())
                    {
                        OfferMapper m     = new OfferMapper(reader);
                        int         count = 0;
                        while (reader.Read())
                        {
                            ProposedReturnValue = m.OfferFromReader(reader);
                            count++;
                        }
                        if (count > 1)
                        {
                            throw new Exception($"Found more than 1 Offer with key{OfferID}");
                        }
                    }
                }
            }
            catch (Exception ex) when(Log(ex))
            {
            }
            return(ProposedReturnValue);
        }
Exemple #3
0
        public OfferDal OfferFromReader(System.Data.SqlClient.SqlDataReader reader)
        {
            OfferDal ProposedReturnValue = new OfferDal();

            ProposedReturnValue.offerID       = reader.GetInt32(OffsetToOfferID);
            ProposedReturnValue.ProductID     = reader.GetInt32(OffsetToProductID);
            ProposedReturnValue.BuyerID       = reader.GetInt32(OffsetToBuyerID);
            ProposedReturnValue.Offerprice    = reader.GetDecimal(OffsetToOfferPrice);
            ProposedReturnValue.offerstate    = reader.GetInt32(OffsetToOfferstate);
            ProposedReturnValue.ExpireDate    = reader.GetDateTime(OffsetToExpireDate);
            ProposedReturnValue.Comments      = reader.GetString(OffsetToComments);
            ProposedReturnValue.ProductName   = reader.GetString(OffsetToProductName);
            ProposedReturnValue.BuyerName     = reader.GetString(OffsetToBuyerName);
            ProposedReturnValue.EmailAdderess = reader.GetString(OffsetToEmailAdderess);

            return(ProposedReturnValue);
        }