public void Add(int AssociationId) { var doc = new Document(); doc.Title = WriteRead.WRL("Enter document title: "); doc.Text = WriteRead.WRL("Enter document text: "); var date = new DateTime(); if (DateTime.TryParse(WriteRead.WRL("Enter date document becomes valid: "), out date)) { doc.DateValidFrom = date; } else { doc.DateValidFrom = DateTime.Now; } if (DateTime.TryParse(WriteRead.WRL("Enter date document valid till"), out date)) { doc.DateValidTill = date; } else { doc.DateValidTill = DateTime.Now.AddYears(1); } doc.AssociationId = AssociationId; using (var db = new EntityContext()) { db.Documents.Add(doc); db.SaveChanges(); } }
public void Add(string UserName) { var pprofile = new Profile(); pprofile.UserName = UserName; Console.WriteLine("Fill the form:"); pprofile.Name = WriteRead.WRL(" Name: "); pprofile.FamilyName = WriteRead.WRL(" Family name: "); var date = new DateTime(); if (DateTime.TryParse(WriteRead.WRL(" Date of birth: "), out date)) { pprofile.BirthDate = date; } else { pprofile.BirthDate = DateTime.Now; } pprofile.Mobile = WriteRead.WRL(" Mobile number: "); pprofile.EMail = WriteRead.WRL(" E_Mail: "); using (var db = new EntityContext()) { db.Profiles.Add(pprofile); db.SaveChanges(); } }
public void Add() { var assoc = new Association(); assoc.Name = WriteRead.WRL("Enter association nam: "); var db = new EntityContext(); db.Associations.Add(assoc); db.SaveChanges(); }
public void Add() { var User = new User() { UserName = WriteRead.WRL("Enter user name: ") }; using (var db = new EntityContext()) { db.Users.Add(User); db.SaveChanges(); } }