示例#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();
            }
        }
示例#2
0
 internal static void DeleteBd()
 {
     using (DocSystDbContext context = new DocSystDbContext())
     {
         context.Database.Delete();
     }
 }
示例#3
0
        private User AttachCreatorUser(DocSystDbContext context, User creatorUser)
        {
            User user = context.Users.Where(userDb => userDb.Username == creatorUser.Username).FirstOrDefault();

            context.Users.Attach(user);
            return(user);
        }
示例#4
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();
            }
        }
示例#5
0
 private void AttachObserverList(DocSystDbContext context, IList <StyleClass> observerList)
 {
     foreach (StyleClass observer in observerList)
     {
         context.StyleClasses.Attach(observer);
     }
 }
示例#6
0
 public void Add(User user)
 {
     using (DocSystDbContext context = new DocSystDbContext())
     {
         context.Users.Add(user);
         context.SaveChanges();
     }
 }
示例#7
0
 public void Add(AuditLog aAuditLog)
 {
     using (DocSystDbContext context = new DocSystDbContext())
     {
         context.AuditLogs.Add(aAuditLog);
         context.SaveChanges();
     }
 }
示例#8
0
 public void Add(Style style)
 {
     using (DocSystDbContext context = new DocSystDbContext())
     {
         context.Styles.Add(style);
         context.SaveChanges();
     }
 }
示例#9
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();
     }
 }
示例#10
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(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();
     }
 }
示例#12
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();
     }
 }
示例#13
0
        public IList <Paragraph> Get()
        {
            IList <Paragraph> paragraphs = null;

            using (DocSystDbContext context = new DocSystDbContext())
            {
                paragraphs = (context.Paragraphs.Include(paragraphDb => paragraphDb.Texts)).ToList <Paragraph>();
            }
            return(paragraphs);
        }
示例#14
0
        public bool Exists(Guid aParagraph)
        {
            bool exists = false;

            using (DocSystDbContext context = new DocSystDbContext())
            {
                exists = context.Paragraphs.Any(paragraphDb => paragraphDb.Id == aParagraph);
            }
            return(exists);
        }
        public List <Text> GetTextsInBody(Guid BodyId)
        {
            List <Text> text = null;

            using (DocSystDbContext context = new DocSystDbContext())
            {
                text = context.Texts.Where(textDb => textDb.BodyId == BodyId).ToList();
            }
            return(text);
        }
示例#16
0
        public IList <Margin> Get()
        {
            IList <Margin> margins = null;

            using (DocSystDbContext context = new DocSystDbContext())
            {
                margins = (context.Margins.Include(marginsDb => marginsDb.Texts)).ToList <Margin>();
            }
            return(margins);
        }
        public IList <Text> Get()
        {
            IList <Text> texts = null;

            using (DocSystDbContext context = new DocSystDbContext())
            {
                texts = context.Texts.ToList <Text>();
            }
            return(texts);
        }
示例#18
0
        public User Get(Guid token)
        {
            User user = null;

            using (DocSystDbContext context = new DocSystDbContext())
            {
                user = context.Users.Where(userDb => userDb.Token == token).FirstOrDefault();
            }
            return(user);
        }
        public bool Exists(Guid aText)
        {
            bool exists = false;

            using (DocSystDbContext context = new DocSystDbContext())
            {
                exists = context.Texts.Any(textDb => textDb.Id == aText);
            }
            return(exists);
        }
示例#20
0
        public IList <AuditLog> Get()
        {
            IList <AuditLog> auditLogs = null;

            using (DocSystDbContext context = new DocSystDbContext())
            {
                auditLogs = context.AuditLogs.ToList <AuditLog>();
            }
            return(auditLogs);
        }
示例#21
0
        public bool Exists(string username)
        {
            bool exists = false;

            using (DocSystDbContext context = new DocSystDbContext())
            {
                exists = context.Users.Any(userDb => userDb.Username == username);
            }
            return(exists);
        }
        public IList <Body> Get()
        {
            IList <Body> bodys = null;

            using (DocSystDbContext context = new DocSystDbContext())
            {
                bodys = (context.Bodys.Include(bodysDb => bodysDb.Texts)).ToList <Body>();
            }
            return(bodys);
        }
示例#23
0
        public User Get(string username)
        {
            User user = null;

            using (DocSystDbContext context = new DocSystDbContext())
            {
                user = context.Users.Where(userDb => userDb.Username == username).FirstOrDefault();
            }
            return(user);
        }
示例#24
0
        public bool Exists(Guid aMargin)
        {
            bool exists = false;

            using (DocSystDbContext context = new DocSystDbContext())
            {
                exists = context.Margins.Any(marginDb => marginDb.Id == aMargin);
            }
            return(exists);
        }
示例#25
0
        public bool Exists(Guid id)
        {
            bool exists = false;

            using (DocSystDbContext context = new DocSystDbContext())
            {
                exists = context.Formats.Any(formatDb => formatDb.Id == id);
            }
            return(exists);
        }
        public Text Get(Guid id)
        {
            Text text = null;

            using (DocSystDbContext context = new DocSystDbContext())
            {
                text = context.Texts.Where(textDb => textDb.Id == id).FirstOrDefault();
            }
            return(text);
        }
        public bool Exists(Guid aBody)
        {
            bool exists = false;

            using (DocSystDbContext context = new DocSystDbContext())
            {
                exists = context.Bodys.Any(bodyDb => bodyDb.Id == aBody);
            }
            return(exists);
        }
示例#28
0
        public bool Exists(Guid id)
        {
            bool exists = false;

            using (DocSystDbContext context = new DocSystDbContext())
            {
                exists = context.StyleClasses.Any(styleClassDb => styleClassDb.Id == id);
            }
            return(exists);
        }
 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();
     }
 }
示例#30
0
        public IList <User> Get()
        {
            IList <User> users = null;

            using (DocSystDbContext context = new DocSystDbContext())
            {
                users = context.Users.ToList <User>();
            }
            return(users);
        }