Exemple #1
0
        public void AddOptionComb(OptionComb optComb)
        {
            using (TradingWizardEntities context = new TradingWizardEntities())
            {
                context.OptionCombs.Add(optComb);

                context.SaveChanges();
            }
        }
        public void AddOptionComb(OptionComb optComb)
        {
            using (TradingWizardEntities context = new TradingWizardEntities())
            {
                context.OptionCombs.Add(optComb);

                context.SaveChanges();
            }
        }
        public ActionResult Create(/*FormCollection collection*/ OptionComb optComb)
        {
            try
            {
                TradingWizardRepository repository = new TradingWizardRepository();
                repository.AddOptionComb(optComb);

                return RedirectToAction("Index");
            }
            catch(Exception exp)
            {
                return View();
            }
        }
        //public OptionCombination Options
        //{
        //    get
        //    {
        //        if (this._optionCombinations==null)
        //        {
        //            if (this.OptionCombinationXML.Length > 0)
        //            {
        //                var ser = new XmlSerializer(typeof(OptionCombination));

        //                this._optionCombinations = (OptionCombination)ser.Deserialize(new StringReader(this.OptionCombinationXML));
        //            }
        //        }

        //        return this._optionCombinations;
        //    }

        //    set
        //    {
        //        this._optionCombinations = value;

        //        if (this._optionCombinations != null)
        //        {
        //            var xs = new XmlSerializer(this._optionCombinations.GetType());
        //            var xml = new StringWriter();
        //            xs.Serialize(xml, this._optionCombinations);

        //            this.OptionCombinationXML = xml.ToString();
        //        }
        //    }
        //}

        public UserOptionComb(OptionComb optComb)
        {
            this.OptionCombID         = optComb.OptionCombID;
            this.UserID               = optComb.UserID;
            this.Name                 = optComb.Name;
            this.OptionCombinationXML = optComb.OptionCombinationXML;
            this.Description          = optComb.Description;
            this.Options              = null;

            if (!string.IsNullOrEmpty(this.OptionCombinationXML))
            {
                var ser = new XmlSerializer(typeof(OptionCombination));

                this.Options = (OptionCombination)ser.Deserialize(new StringReader(this.OptionCombinationXML));
            }
        }
        //public OptionCombination Options
        //{
        //    get
        //    {
        //        if (this._optionCombinations==null)
        //        {
        //            if (this.OptionCombinationXML.Length > 0)
        //            {
        //                var ser = new XmlSerializer(typeof(OptionCombination));
        //                this._optionCombinations = (OptionCombination)ser.Deserialize(new StringReader(this.OptionCombinationXML));
        //            }
        //        }
        //        return this._optionCombinations;
        //    }
        //    set
        //    {
        //        this._optionCombinations = value;
        //        if (this._optionCombinations != null)
        //        {
        //            var xs = new XmlSerializer(this._optionCombinations.GetType());
        //            var xml = new StringWriter();
        //            xs.Serialize(xml, this._optionCombinations);
        //            this.OptionCombinationXML = xml.ToString();
        //        }
        //    }
        //}
        public UserOptionComb(OptionComb optComb)
        {
            this.OptionCombID = optComb.OptionCombID;
            this.UserID = optComb.UserID;
            this.Name = optComb.Name;
            this.OptionCombinationXML = optComb.OptionCombinationXML;
            this.Description = optComb.Description;
            this.Options = null;

            if (!string.IsNullOrEmpty(this.OptionCombinationXML))
            {
                var ser = new XmlSerializer(typeof(OptionCombination));

                this.Options = (OptionCombination)ser.Deserialize(new StringReader(this.OptionCombinationXML));

            }
        }