Exemplo n.º 1
0
        public void Add(Document aDocument)
        {
            IBodyDataAccess bodyDataAccess = new BodyDataAccess();

            foreach (Body body in aDocument.DocumentMargins)
            {
                bodyDataAccess.Add(body);
            }

            IParagraphDataAccess paragraphDataAccess = new ParagraphDataAccess();

            foreach (Paragraph paragraph in aDocument.DocumentParagraphs)
            {
                paragraphDataAccess.Add(paragraph);
            }

            using (DocSystDbContext context = new DocSystDbContext())
            {
                aDocument.CreatorUser        = AttachCreatorUser(context, aDocument.CreatorUser);
                aDocument.DocumentMargins    = AttachDocumentMarginList(context, aDocument.DocumentMargins).ToList();
                aDocument.DocumentParagraphs = AttachDocumentParagraphsList(context, aDocument.DocumentParagraphs).ToList();
                context.Documents.Add(aDocument);
                context.SaveChanges();
            }
        }
Exemplo n.º 2
0
        public void Modify(Document aDocument)
        {
            aDocument.LastModifyDate = DateTime.Today;

            IBodyDataAccess bodyDataAccess = new BodyDataAccess();

            foreach (Body body in aDocument.DocumentMargins)
            {
                bodyDataAccess.Add(body);
            }

            IParagraphDataAccess paragraphDataAccess = new ParagraphDataAccess();

            foreach (Paragraph paragraph in aDocument.DocumentParagraphs)
            {
                paragraphDataAccess.Add(paragraph);
            }

            using (DocSystDbContext context = new DocSystDbContext())
            {
                IList <Margin>    bodyList      = AttachDocumentMarginList(context, aDocument.DocumentMargins);
                IList <Paragraph> paragraphList = AttachDocumentParagraphsList(context, aDocument.DocumentParagraphs);
                aDocument.DocumentMargins    = bodyList.ToList();
                aDocument.DocumentParagraphs = paragraphList.ToList();

                Document actualDocument = context.Documents.Include("DocumentMargins").Include("DocumentParagraphs")
                                          .FirstOrDefault(documenthDb => documenthDb.Id == aDocument.Id);

                context.Entry(actualDocument).Entity.DocumentMargins    = aDocument.DocumentMargins;
                context.Entry(actualDocument).Entity.DocumentParagraphs = aDocument.DocumentParagraphs;
                context.Entry(actualDocument).CurrentValues.SetValues(aDocument);

                context.SaveChanges();
            }
        }
Exemplo n.º 3
0
 public void Add(User user)
 {
     using (DocSystDbContext context = new DocSystDbContext())
     {
         context.Users.Add(user);
         context.SaveChanges();
     }
 }
Exemplo n.º 4
0
 public void Add(Style style)
 {
     using (DocSystDbContext context = new DocSystDbContext())
     {
         context.Styles.Add(style);
         context.SaveChanges();
     }
 }
Exemplo n.º 5
0
 public void Add(AuditLog aAuditLog)
 {
     using (DocSystDbContext context = new DocSystDbContext())
     {
         context.AuditLogs.Add(aAuditLog);
         context.SaveChanges();
     }
 }
 public void Modify(Text aText)
 {
     using (DocSystDbContext context = new DocSystDbContext())
     {
         Text actualText = context.Texts.FirstOrDefault(textDb => textDb.Id == aText.Id);
         context.Entry(actualText).CurrentValues.SetValues(aText);
         context.SaveChanges();
     }
 }
Exemplo n.º 7
0
 public void Modify(AuditLog aAuditLog)
 {
     using (DocSystDbContext context = new DocSystDbContext())
     {
         AuditLog actualAuditLog = context.AuditLogs.FirstOrDefault(auditLogDb => auditLogDb.Id == aAuditLog.Id);
         context.Entry(actualAuditLog).CurrentValues.SetValues(aAuditLog);
         context.SaveChanges();
     }
 }
Exemplo n.º 8
0
 public void Modify(User newUser)
 {
     using (DocSystDbContext context = new DocSystDbContext())
     {
         User actualUser = context.Users.Where(userDb => userDb.Username == newUser.Username).FirstOrDefault();
         context.Entry(actualUser).CurrentValues.SetValues(newUser);
         context.SaveChanges();
     }
 }
 public void Modify(Body aBody)
 {
     using (DocSystDbContext context = new DocSystDbContext())
     {
         Body actualBody = context.Bodys.Include(bodyhDb => bodyhDb.Texts)
                           .FirstOrDefault(bodyhDb => bodyhDb.Id == aBody.Id);
         context.Entry(actualBody).CurrentValues.SetValues(aBody);
         context.SaveChanges();
     }
 }
Exemplo n.º 10
0
 public void Add(Format format)
 {
     using (DocSystDbContext context = new DocSystDbContext())
     {
         IList <StyleClass> stClass = AttachStyleClassList(context, format.StyleClasses);
         format.StyleClasses = stClass;
         context.Formats.Add(format);
         context.SaveChanges();
     }
 }
Exemplo n.º 11
0
 public void Modify(Style style)
 {
     using (DocSystDbContext context = new DocSystDbContext())
     {
         Style actualStyle = context.Styles.Where(styleDb => styleDb.Name == style.Name).FirstOrDefault();
         context.Entry(actualStyle).Entity.Value = style.Value;
         context.Entry(actualStyle).CurrentValues.SetValues(style);
         context.SaveChanges();
     }
 }
        public void Delete(Guid id)
        {
            Text text = Get(id);

            using (DocSystDbContext context = new DocSystDbContext())
            {
                context.Texts.Attach(text);
                context.Texts.Remove(text);
                context.SaveChanges();
            }
        }
 public void Add(Body aBody)
 {
     using (DocSystDbContext context = new DocSystDbContext())
     {
         if (!Exists(aBody.Id))
         {
             context.Bodys.Add(aBody);
             context.SaveChanges();
         }
     }
 }
Exemplo n.º 14
0
        public void Delete(string username)
        {
            User user = Get(username);

            using (DocSystDbContext context = new DocSystDbContext())
            {
                context.Users.Attach(user);
                context.Users.Remove(user);
                context.SaveChanges();
            }
        }
Exemplo n.º 15
0
        public void Delete(Guid id)
        {
            AuditLog auditLog = Get(id);

            using (DocSystDbContext conauditLog = new DocSystDbContext())
            {
                conauditLog.AuditLogs.Attach(auditLog);
                conauditLog.AuditLogs.Remove(auditLog);
                conauditLog.SaveChanges();
            }
        }
 public void Add(Text aText)
 {
     if (!Exists(aText.Id))
     {
         using (DocSystDbContext context = new DocSystDbContext())
         {
             context.Texts.Add(aText);
             context.SaveChanges();
         }
     }
 }
Exemplo n.º 17
0
        public void Delete(string name)
        {
            Style style = Get(name);

            using (DocSystDbContext context = new DocSystDbContext())
            {
                context.Styles.Attach(style);
                context.Styles.Remove(style);
                context.SaveChanges();
            }
        }
        public void Delete(Guid id)
        {
            Body body = Get(id);

            using (DocSystDbContext context = new DocSystDbContext())
            {
                context.Bodys.Attach(body);
                context.Bodys.Remove(body);
                context.SaveChanges();
            }
        }
Exemplo n.º 19
0
 public void Modify(Format format)
 {
     using (DocSystDbContext context = new DocSystDbContext())
     {
         IList <StyleClass> stClass = AttachStyleClassList(context, format.StyleClasses);
         format.StyleClasses = stClass;
         Format actualFormat = context.Formats.Include(STYLE_CLASSES).Where(formatDb => formatDb.Id == format.Id).FirstOrDefault();
         context.Entry(actualFormat).Entity.StyleClasses = format.StyleClasses;
         context.Entry(actualFormat).CurrentValues.SetValues(format);
         context.SaveChanges();
     }
 }
Exemplo n.º 20
0
        public void Delete(Guid id)
        {
            Paragraph paragraph = Get(id);

            using (DocSystDbContext context = new DocSystDbContext())
            {
                List <Text> textList = AttachTextList(context, paragraph.Texts);
                paragraph.Texts = textList;
                context.Paragraphs.Attach(paragraph);
                context.Paragraphs.Remove(paragraph);
                context.SaveChanges();
            }
        }
Exemplo n.º 21
0
        public void Delete(Guid id)
        {
            Margin margin = Get(id);

            using (DocSystDbContext context = new DocSystDbContext())
            {
                List <Text> textList = AttachTextList(context, margin.Texts);
                margin.Texts = textList;
                context.Margins.Attach(margin);
                context.Margins.Remove(margin);
                context.SaveChanges();
            }
        }
Exemplo n.º 22
0
        public void Delete(Guid id)
        {
            Format format = Get(id);

            using (DocSystDbContext context = new DocSystDbContext())
            {
                IList <StyleClass> stClass = AttachStyleClassList(context, format.StyleClasses);
                format.StyleClasses = stClass;
                context.Formats.Attach(format);
                context.Formats.Remove(format);
                context.SaveChanges();
            }
        }
Exemplo n.º 23
0
 public void Add(StyleClass styleClass)
 {
     using (DocSystDbContext context = new DocSystDbContext())
     {
         AttachInheritedStyleClass(context, styleClass.InheritedStyleClass);
         IList <Style> st = AttachStyleList(context, styleClass.InheritedPlusProperStyles);
         styleClass.InheritedPlusProperStyles = st;
         styleClass.ProperStyles = st;
         AttachObserverList(context, styleClass.Observers);
         context.StyleClasses.Add(styleClass);
         context.SaveChanges();
     }
 }
Exemplo n.º 24
0
        public void Delete(Guid id)
        {
            StyleClass styleClass = Get(id);

            using (DocSystDbContext context = new DocSystDbContext())
            {
                AttachInheritedStyleClass(context, styleClass.InheritedStyleClass);
                IList <Style> st = AttachStyleList(context, styleClass.InheritedPlusProperStyles);
                styleClass.InheritedPlusProperStyles = st;
                styleClass.ProperStyles = st;
                AttachObserverList(context, styleClass.Observers);
                context.StyleClasses.Attach(styleClass);
                context.StyleClasses.Remove(styleClass);
                context.SaveChanges();
            }
        }
Exemplo n.º 25
0
        public void Delete(Guid id)
        {
            Document document = Get(id);

            using (DocSystDbContext context = new DocSystDbContext())
            {
                IList <Margin> bodyList = AttachDocumentMarginList(context, document.DocumentMargins);
                document.DocumentMargins = bodyList.ToList();
                IList <Paragraph> paragraphList = AttachDocumentParagraphsList(context, document.DocumentParagraphs);
                document.DocumentParagraphs = paragraphList.ToList();

                context.Documents.Attach(document);
                context.Documents.Remove(document);
                context.SaveChanges();
            }
        }
Exemplo n.º 26
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();
                }
            }
        }
Exemplo n.º 27
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();
                }
            }
        }
Exemplo n.º 28
0
        public void Modify(StyleClass styleClass)
        {
            using (DocSystDbContext context = new DocSystDbContext())
            {
                StyleClass styleC = AttachInheritedStyleClass(context, styleClass.InheritedStyleClass);
                styleClass.InheritedStyleClass = styleC;
                IList <Style> st = AttachStyleList(context, styleClass.InheritedPlusProperStyles);
                styleClass.InheritedPlusProperStyles = st;
                styleClass.ProperStyles = st;
                AttachObserverList(context, styleClass.Observers);
                StyleClass actualStyleClass = context.StyleClasses.Include("ProperStyles").Include("InheritedStyleClass")
                                              .Include("InheritedPlusProperStyles").Include("Observers").Where(styleClassDb => styleClassDb.Id == styleClass.Id).FirstOrDefault();

                context.Entry(actualStyleClass).Entity.InheritedPlusProperStyles = styleClass.InheritedPlusProperStyles;
                context.Entry(actualStyleClass).Entity.SetInheritedStyleClass(styleClass.InheritedStyleClass);
                context.Entry(actualStyleClass).Entity.Observers    = styleClass.Observers;
                context.Entry(actualStyleClass).Entity.ProperStyles = styleClass.ProperStyles;
                context.Entry(actualStyleClass).CurrentValues.SetValues(styleClass);
                context.SaveChanges();
            }
        }
Exemplo n.º 29
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();
            }
        }
Exemplo n.º 30
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();
            }
        }