Exemple #1
0
                public ColContent(Step s)
                {
                    this.Title = "Step " + s.StepIndex;

                    //check type
                    if (s.MediaType == Step.MediaType_Embed)
                    {

                        EmbedVisibility = System.Windows.Visibility.Visible;
                        EmbedURL = s.EmbedURL;
                    }
                    //else if (s.MediaType == Step.MediaType_Image)
                    else
                    {
                        EmbedVisibility = System.Windows.Visibility.Collapsed;
                        //FIXME this is probably bad. We are always assuming there is a .standard availible
                        this.Image1 = s.Image1 + ".standard";
                        this.Image2 = s.Image2 + ".standard";
                        this.Image3 = s.Image3 + ".standard";
                    }

                    Lines = new ObservableCollection<Lines>();
                    foreach (Lines l in s.Lines)
                    {
                        Lines.Add(l);
                    }
                    this.Type = "Step";
                }
Exemple #2
0
        /*
         * Iterate through all steps and their lines, inserting them into the DB
         */
        private void InsertStepsAndLines(Guide parentGuide, GHStep[] steps, iFixitDataContext db)
        {
            //loop through all steps and attempt to insert them
            foreach (GHStep newStep in steps)
            {
                //see if it exists
                //Step sOld = db.StepsTable.FirstOrDefault(s => s.Title == newStep.title);
                Step sOld = DBHelpers.GetCompleteStep(parentGuide.GuideID, newStep.number, db);
                if (sOld == null)
                {
                    //insert it
                    sOld = new Step(newStep);
                    sOld.parentName = parentGuide.GuideID;
                    db.StepsTable.InsertOnSubmit(sOld);
                }
                else
                {
                    //update it
                    sOld.FillFields(newStep);
                }

                //go through all lines
                foreach (GHStepLines newLine in newStep.lines)
                {
                    Lines oldLine = db.LinesTable.FirstOrDefault(l => l.parentName == sOld.parentName + sOld.StepIndex);
                    if (oldLine == null)
                    {
                        //insert it
                        Lines l = new Lines(newLine);
                        l.parentName = sOld.parentName + sOld.StepIndex;
                        db.LinesTable.InsertOnSubmit(l);
                    }
                    else
                    {
                        //add it
                        oldLine.FillFields(newLine);
                        oldLine.parentName = sOld.parentName + sOld.StepIndex;
                    }
                }
            }
        }