Ejemplo n.º 1
0
        public IEnumerable <CMSProduct> GetProductCMS(string product)
        {
            List <CMSProduct> products = new List <CMSProduct>();

            using (SqlConnection con = new SqlConnection(getConnectionStringFromSettings()))
            {
                try
                {
                    con.Open();
                    string qryGetUsers = "SELECT ProductID_CMS, ProductName_CMS, DockSpotTimeslotDuration FROM dbo.ProductsCMS WHERE ProductID_CMS = @prod";
                    using (SqlCommand command = new SqlCommand(qryGetUsers, con))
                    {
                        command.Parameters.Add(new SqlParameter("@prod", product));
                        SqlDataReader sReader = command.ExecuteReader();
                        while (sReader.Read())
                        {
                            products.Add(CMSProduct.adaptToProductCMS(sReader));
                        }
                    }
                }
                catch (Exception ex)
                {
                    string     strErr = " Exception Error in DataProvider GetProductCMS(). Details: " + ex.ToString();
                    MessageLog alog   = new MessageLog(MessageType.Exception, "GetProductCMS Exception Message=" + strErr);
                    logger.Error(alog.CreateAuditLogMessage());
                    throw;
                }
            }

            return(products);
        }
Ejemplo n.º 2
0
        public static CMSProduct adaptToProductCMS(IDataRecord record)
        {
            CMSProduct cmsProduct = new CMSProduct();

            cmsProduct.ProductID_CMS            = record["ProductID_CMS"].ToString();
            cmsProduct.ProductName_CMS          = record["ProductName_CMS"].ToString();
            cmsProduct.DockSpotTimeslotDuration = (int)record["DockSpotTimeslotDuration"];

            return(cmsProduct);
        }