Exemplo n.º 1
0
        protected AuctionDetails ConvertRow(DataRow dr)
        {
            AuctionDetails ad = new AuctionDetails();

            if (dr != null)
            {
                if (dr.Table.Columns.Count != 0)
                {
                    if (dr.Table.Columns.Contains("ID"))
                    {
                        ad.ID = int.Parse(dr.Table.Rows[0]["ID"].ToString());
                    }
                    if (dr.Table.Columns.Contains("Description"))
                    {
                        ad.Description = dr.Table.Rows[0]["Description"].ToString();
                    }
                    if (dr.Table.Columns.Contains("Type"))
                    {
                        ad.Creator = dr.Table.Rows[0]["Type"].ToString();
                    }
                    if (dr.Table.Columns.Contains("ConfirmationDeadline"))
                    {
                        ad.ConfirmationDeadline = DateTime.Parse(dr.Table.Rows[0]["ConfirmationDeadline"].ToString());
                    }
                    if (dr.Table.Columns.Contains("StartDateTime"))
                    {
                        ad.StartDateTime = DateTime.Parse(dr.Table.Rows[0]["StartDateTime"].ToString());
                    }
                    if (dr.Table.Columns.Contains("EndDateTime"))
                    {
                        ad.EndDateTime = DateTime.Parse(dr.Table.Rows[0]["EndDateTime"].ToString());
                    }
                    if (dr.Table.Columns.Contains("Duration"))
                    {
                        ad.Duration = dr.Table.Rows[0]["Duration"].ToString();
                    }
                    if (dr.Table.Columns.Contains("Creator"))
                    {
                        ad.Creator = dr.Table.Rows[0]["Creator"].ToString();
                    }
                    if (dr.Table.Columns.Contains("CreatorEmail"))
                    {
                        ad.CreatorEmail = dr.Table.Rows[0]["CreatorEmail"].ToString();
                    }
                }
                else
                {
                    throw new EmptyInputException("Data row contains no columns");
                }
            }
            else
            {
                throw new EmptyInputException("Data row is null.");
            }
            return(ad);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Converts a source row's data to auction details
        /// </summary>
        /// <param name="dt">Source row</param>
        public AuctionDetails(DataRow dr)
        {
            AuctionDetails ad = new AuctionDetails();

            ad                   = ConvertRow(dr);
            ID                   = ad.ID;
            Description          = ad.Description;
            Duration             = ad.Duration;
            this.Type            = ad.Type;
            StartDateTime        = ad.StartDateTime;
            EndDateTime          = ad.EndDateTime;
            ConfirmationDeadline = ad.ConfirmationDeadline;
            Creator              = ad.Creator;
            CreatorEmail         = ad.CreatorEmail;
        }