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(); } }
internal static void DeleteBd() { using (DocSystDbContext context = new DocSystDbContext()) { context.Database.Delete(); } }
private User AttachCreatorUser(DocSystDbContext context, User creatorUser) { User user = context.Users.Where(userDb => userDb.Username == creatorUser.Username).FirstOrDefault(); context.Users.Attach(user); return(user); }
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(); } }
private void AttachObserverList(DocSystDbContext context, IList <StyleClass> observerList) { foreach (StyleClass observer in observerList) { context.StyleClasses.Attach(observer); } }
public void Add(User user) { using (DocSystDbContext context = new DocSystDbContext()) { context.Users.Add(user); context.SaveChanges(); } }
public void Add(AuditLog aAuditLog) { using (DocSystDbContext context = new DocSystDbContext()) { context.AuditLogs.Add(aAuditLog); context.SaveChanges(); } }
public void Add(Style style) { using (DocSystDbContext context = new DocSystDbContext()) { context.Styles.Add(style); context.SaveChanges(); } }
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(); } }
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(); } }
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(); } }
public IList <Paragraph> Get() { IList <Paragraph> paragraphs = null; using (DocSystDbContext context = new DocSystDbContext()) { paragraphs = (context.Paragraphs.Include(paragraphDb => paragraphDb.Texts)).ToList <Paragraph>(); } return(paragraphs); }
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); }
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); }
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); }
public IList <AuditLog> Get() { IList <AuditLog> auditLogs = null; using (DocSystDbContext context = new DocSystDbContext()) { auditLogs = context.AuditLogs.ToList <AuditLog>(); } return(auditLogs); }
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); }
public User Get(string username) { User user = null; using (DocSystDbContext context = new DocSystDbContext()) { user = context.Users.Where(userDb => userDb.Username == username).FirstOrDefault(); } return(user); }
public bool Exists(Guid aMargin) { bool exists = false; using (DocSystDbContext context = new DocSystDbContext()) { exists = context.Margins.Any(marginDb => marginDb.Id == aMargin); } return(exists); }
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); }
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(); } }
public IList <User> Get() { IList <User> users = null; using (DocSystDbContext context = new DocSystDbContext()) { users = context.Users.ToList <User>(); } return(users); }