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(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 TestRead() { string exceptedMoney = "666"; WriteRead writeRead = new WriteRead(); string actualMoney = writeRead.Read(); Assert.AreEqual(exceptedMoney, actualMoney); }
public void Add() { var assoc = new Association(); assoc.Name = WriteRead.WRL("Enter association nam: "); var db = new EntityContext(); db.Associations.Add(assoc); db.SaveChanges(); }
/// <summary> /// 数据库 连接 /// </summary> /// <param name="writeRead"></param> /// <returns></returns> public IDbConnection GetDbConnection(WriteRead writeRead) { connection.ConnectionString = writeRead switch { WriteRead.Write => option.WriteConnection, //增删改 -- 主数据库 WriteRead.Read => QueryStrategy(), // 如果是查询的时候,我们自由选择查询数据库 _ => throw new ArgumentNullException(nameof(writeRead), "选择数据库 出错···") }; return(connection); }
private void BLoad_Click(object sender, EventArgs e) { // WriteRead reader = new WriteRead(); bool isCorrectLoad = WriteRead.DeSerialize(Books); if (isCorrectLoad) { MessageBox.Show("Load success", "Message", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); } }
public void SerializeLazyWriteThenRead() { var input = new WriteRead(); serializerFile.Save(Call, input); WriteRead output = serializerFile.Load <WriteRead>(Call, true); output.StringTest = "abc"; string temp = output.StringTest; Assert.AreEqual(output.StringTest, "abc"); }
public void Add() { var User = new User() { UserName = WriteRead.WRL("Enter user name: ") }; using (var db = new EntityContext()) { db.Users.Add(User); db.SaveChanges(); } }
public void TestsavePropertyToBinary() { WriteRead writeRead = new WriteRead(); Property Kobe = new Property("kobe"); Property Allen = new Property("allen"); ArrayList properties = new ArrayList(); properties.Add(Kobe); properties.Add(Allen); bool r = writeRead.savePropertyToBinary(properties); Assert.IsTrue(r); }
public void TestsavePlayerToBinary() { WriteRead writeRead = new WriteRead(); Player Kobe = new Player("kobe", true); Player Allen = new Player("allen", false); ArrayList players = new ArrayList(); players.Add(Kobe); players.Add(Allen); bool r = writeRead.savePlayerToBinary(players); Assert.IsTrue(r); }
public void TestopenPlayerBinaryFile() { //the excepted Arraylist ArrayList Exceptedplayers = new ArrayList(); Player Kobe = new Player("kobe", true); Player Allen = new Player("allen", false); Exceptedplayers.Add(Kobe); Exceptedplayers.Add(Allen); ////Actualplayers is the actrual Arraylist WriteRead writeRead = new WriteRead(); ArrayList Actualplayers = new ArrayList(); Actualplayers = writeRead.openPlayerBinaryFile(); //compare CollectionAssert.AreEqual(Exceptedplayers, Actualplayers); }
public void TestopenPropertyBinaryFile() { //the excepted Arraylist ArrayList Exceptedproperties = new ArrayList(); Property Kobe = new Property("kobe"); Property Allen = new Property("allen"); Exceptedproperties.Add(Kobe); Exceptedproperties.Add(Allen); //Actualproperities is the actrual Arraylist WriteRead writeRead = new WriteRead(); ArrayList Actualproperities = new ArrayList(); Actualproperities = writeRead.openPropertyBinaryFile(); //compare CollectionAssert.AreEqual(Exceptedproperties, Actualproperities); }
public TWDBContext(WriteRead writeRead) : base(writeRead == WriteRead.Write ? DBConfig.Write : DBConfig.Read) { }