/// <summary>
        ///
        /// </summary>
        /// <param name="config"></param>
        /// <returns></returns>
        private static Contract GetContract(IConfigurationSection config)
        {
            var contract = new Contract();
            var index    = 0;

            foreach (var line in File.ReadLines(config.Value))
            {
                var parts  = line.Split(';', StringSplitOptions.RemoveEmptyEntries);
                var name   = parts[0].Trim();
                var type   = parts[1].Trim();
                var length = -1;

                var lengthIndex = type.IndexOf('(');
                if (lengthIndex != -1)
                {
                    var lengthStr = type.Substring(
                        lengthIndex + 1,
                        type.IndexOf(')') - lengthIndex - 1);
                    length = int.Parse(lengthStr);
                    type   = type.Substring(0, lengthIndex);
                }

                contract.Add(index++, new ContractProperty
                {
                    Name      = name,
                    Type      = Enum.Parse <ContractProperty.PropertyType>(type, true),
                    MaxLength = length
                });
            }

            return(contract);
        }
Exemple #2
0
    protected void btnSave_Click(object sender, EventArgs e)
    {
        Bids bid     = new Bids();
        var  _userId = Session["user"].ToString();

        bid.BuyerId   = int.Parse(_userId);
        bid.Date      = DateTime.Now;
        bid.Price     = int.Parse(txtAmount.Text);
        id            = Request.QueryString["id"];
        bid.ProductId = int.Parse(id);
        bid.Add();
        divBidAmount.Visible = true;
        divBidNow.Visible    = false;
        lblYourBid.Text      = bid.Price.ToString();

        Contract contract = new Contract();

        contract.Bid = bid;

        contract.Add();
    }