Example #1
0
        public void Add(Paragraph aParagraph)
        {
            if (!Exists(aParagraph.Id))
            {
                ITextDataAccess textDataAccess = new TextDataAccess();
                foreach (Text text in aParagraph.Texts)
                {
                    textDataAccess.Add(text);
                }

                using (DocSystDbContext context = new DocSystDbContext())
                {
                    aParagraph.Texts = AttachTextList(context, aParagraph.Texts).ToList();
                    context.Paragraphs.Add(aParagraph);
                    context.SaveChanges();
                }
            }
        }
Example #2
0
        public void Add(Margin aMargin)
        {
            if (!Exists(aMargin.Id))
            {
                ITextDataAccess textDataAccess = new TextDataAccess();
                foreach (Text text in aMargin.Texts)
                {
                    textDataAccess.Add(text);
                }

                using (DocSystDbContext context = new DocSystDbContext())
                {
                    aMargin.Texts = AttachTextList(context, aMargin.Texts).ToList();
                    context.Margins.Add(aMargin);
                    context.SaveChanges();
                }
            }
        }
Example #3
0
        public void Modify(Margin aMargin)
        {
            ITextDataAccess textDataAccess = new TextDataAccess();

            foreach (Text text in aMargin.Texts)
            {
                textDataAccess.Add(text);
            }

            using (DocSystDbContext context = new DocSystDbContext())
            {
                List <Text> textList = AttachTextList(context, aMargin.Texts);
                aMargin.Texts = textList;

                Margin actualMargin = context.Margins.Include(marginhDb => marginhDb.Texts)
                                      .FirstOrDefault(marginhDb => marginhDb.Id == aMargin.Id);

                context.Entry(actualMargin).Entity.Texts = aMargin.Texts;
                context.Entry(actualMargin).CurrentValues.SetValues(aMargin);

                context.SaveChanges();
            }
        }
Example #4
0
        public void Modify(Paragraph aParagraph)
        {
            ITextDataAccess textDataAccess = new TextDataAccess();

            foreach (Text text in aParagraph.Texts)
            {
                textDataAccess.Add(text);
            }

            using (DocSystDbContext context = new DocSystDbContext())
            {
                List <Text> textList = AttachTextList(context, aParagraph.Texts);
                aParagraph.Texts = textList;

                Paragraph actualParagraph = context.Paragraphs.Include(paragraphDb => paragraphDb.Texts)
                                            .FirstOrDefault(paragraphDb => paragraphDb.Id == aParagraph.Id);

                context.Entry(actualParagraph).Entity.Texts = aParagraph.Texts;
                context.Entry(actualParagraph).CurrentValues.SetValues(aParagraph);
                actualParagraph.Texts = aParagraph.Texts;

                context.SaveChanges();
            }
        }