///<summary> /// Returns a Typed StoreContact Entity with mock values. ///</summary> static public StoreContact CreateMockInstance_Generated(TransactionManager tm) { StoreContact mock = new StoreContact(); mock.ModifiedDate = TestUtility.Instance.RandomDateTime(); //OneToOneRelationship Contact mockContactByContactId = ContactTest.CreateMockInstance(tm); DataRepository.ContactProvider.Insert(tm, mockContactByContactId); mock.ContactId = mockContactByContactId.ContactId; //OneToOneRelationship ContactType mockContactTypeByContactTypeId = ContactTypeTest.CreateMockInstance(tm); DataRepository.ContactTypeProvider.Insert(tm, mockContactTypeByContactTypeId); mock.ContactTypeId = mockContactTypeByContactTypeId.ContactTypeId; //OneToOneRelationship Store mockStoreByCustomerId = StoreTest.CreateMockInstance(tm); DataRepository.StoreProvider.Insert(tm, mockStoreByCustomerId); mock.CustomerId = mockStoreByCustomerId.CustomerId; // create a temporary collection and add the item to it TList <StoreContact> tempMockCollection = new TList <StoreContact>(); tempMockCollection.Add(mock); tempMockCollection.Remove(mock); return((StoreContact)mock); }
/// <summary> /// Deep load all StoreContact children. /// </summary> private void Step_03_DeepLoad_Generated() { using (TransactionManager tm = CreateTransaction()) { int count = -1; mock = CreateMockInstance(tm); mockCollection = DataRepository.StoreContactProvider.GetPaged(tm, 0, 10, out count); DataRepository.StoreContactProvider.DeepLoading += new EntityProviderBaseCore <StoreContact, StoreContactKey> .DeepLoadingEventHandler( delegate(object sender, DeepSessionEventArgs e) { if (e.DeepSession.Count > 3) { e.Cancel = true; } } ); if (mockCollection.Count > 0) { DataRepository.StoreContactProvider.DeepLoad(tm, mockCollection[0]); System.Console.WriteLine("StoreContact instance correctly deep loaded at 1 level."); mockCollection.Add(mock); // DataRepository.StoreContactProvider.DeepSave(tm, mockCollection); } //normally one would commit here //tm.Commit(); //IDisposable will Rollback Transaction since it's left uncommitted } }
///<summary> /// Update the Typed StoreContact Entity with modified mock values. ///</summary> static public void UpdateMockInstance(TransactionManager tm, StoreContact mock) { StoreContactTest.UpdateMockInstance_Generated(tm, mock); // make any alterations necessary // (i.e. for DB check constraints, special test cases, etc.) SetSpecialTestData(mock); }
/// <summary> /// Test methods exposed by the EntityHelper class. /// </summary> private void Step_20_TestEntityHelper_Generated() { using (TransactionManager tm = CreateTransaction()) { mock = CreateMockInstance(tm); StoreContact entity = mock.Copy() as StoreContact; entity = (StoreContact)mock.Clone(); Assert.IsTrue(StoreContact.ValueEquals(entity, mock), "Clone is not working"); } }
///<summary> /// Returns a Typed StoreContact Entity with mock values. ///</summary> static public StoreContact CreateMockInstance(TransactionManager tm) { // get the default mock instance StoreContact mock = StoreContactTest.CreateMockInstance_Generated(tm); // make any alterations necessary // (i.e. for DB check constraints, special test cases, etc.) SetSpecialTestData(mock); // return the modified object return(mock); }
/// <summary> /// Serialize the mock StoreContact entity into a temporary file. /// </summary> private void Step_06_SerializeEntity_Generated() { using (TransactionManager tm = CreateTransaction()) { mock = CreateMockInstance(tm); string fileName = System.IO.Path.Combine(System.IO.Path.GetTempPath(), "temp_StoreContact.xml"); EntityHelper.SerializeXml(mock, fileName); Assert.IsTrue(System.IO.File.Exists(fileName), "Serialized mock not found"); System.Console.WriteLine("mock correctly serialized to a temporary file."); } }
/// <summary> /// Serialize a StoreContact collection into a temporary file. /// </summary> private void Step_08_SerializeCollection_Generated() { using (TransactionManager tm = CreateTransaction()) { string fileName = System.IO.Path.Combine(System.IO.Path.GetTempPath(), "temp_StoreContactCollection.xml"); mock = CreateMockInstance(tm); TList <StoreContact> mockCollection = new TList <StoreContact>(); mockCollection.Add(mock); EntityHelper.SerializeXml(mockCollection, fileName); Assert.IsTrue(System.IO.File.Exists(fileName), "Serialized mock collection not found"); System.Console.WriteLine("TList<StoreContact> correctly serialized to a temporary file."); } }
///<summary> /// Update the Typed StoreContact Entity with modified mock values. ///</summary> static public void UpdateMockInstance_Generated(TransactionManager tm, StoreContact mock) { mock.ModifiedDate = TestUtility.Instance.RandomDateTime(); //OneToOneRelationship Contact mockContactByContactId = ContactTest.CreateMockInstance(tm); DataRepository.ContactProvider.Insert(tm, mockContactByContactId); mock.ContactId = mockContactByContactId.ContactId; //OneToOneRelationship ContactType mockContactTypeByContactTypeId = ContactTypeTest.CreateMockInstance(tm); DataRepository.ContactTypeProvider.Insert(tm, mockContactTypeByContactTypeId); mock.ContactTypeId = mockContactTypeByContactTypeId.ContactTypeId; //OneToOneRelationship Store mockStoreByCustomerId = StoreTest.CreateMockInstance(tm); DataRepository.StoreProvider.Insert(tm, mockStoreByCustomerId); mock.CustomerId = mockStoreByCustomerId.CustomerId; }
/// <summary> /// Test Find using the Query class /// </summary> private void Step_30_TestFindByQuery_Generated() { using (TransactionManager tm = CreateTransaction()) { //Insert Mock Instance StoreContact mock = CreateMockInstance(tm); bool result = DataRepository.StoreContactProvider.Insert(tm, mock); Assert.IsTrue(result, "Could Not Test FindByQuery, Insert Failed"); StoreContactQuery query = new StoreContactQuery(); query.AppendEquals(StoreContactColumn.CustomerId, mock.CustomerId.ToString()); query.AppendEquals(StoreContactColumn.ContactId, mock.ContactId.ToString()); query.AppendEquals(StoreContactColumn.ContactTypeId, mock.ContactTypeId.ToString()); query.AppendEquals(StoreContactColumn.Rowguid, mock.Rowguid.ToString()); query.AppendEquals(StoreContactColumn.ModifiedDate, mock.ModifiedDate.ToString()); TList <StoreContact> results = DataRepository.StoreContactProvider.Find(tm, query); Assert.IsTrue(results.Count == 1, "Find is not working correctly. Failed to find the mock instance"); } }
//更新信息 public static StoreInfo StoreInfoUpload(StoreInfo storeInfo, ContactInfo contactInfo , StorePhoto storePhoto, StoreDesc storeDesc, out AlertMessage alertMessage) { //权限检查 if (!AUTH.PermissionCheck(ModuleInfo, ActionInfos.Where(i => i.Name == (storeInfo.ID == 0 ? "Create" : "Modify")).FirstOrDefault(), out string Message)) { alertMessage = new AlertMessage { Message = Message, Type = AlertType.warning }; return(null); } //表单检查 if (string.IsNullOrWhiteSpace(storeInfo.Name)) { alertMessage = new AlertMessage { Message = "门店代码不能为空。", Type = AlertType.warning }; return(null); } if (string.IsNullOrWhiteSpace(storeInfo.Title)) { alertMessage = new AlertMessage { Message = "门店名称不能为空。", Type = AlertType.warning }; return(null); } using (var EF = new EF()) { //修改是否存在?代码、名称唯一? StoreInfo store_exist = null; StoreInfo store_name_exist = null; StoreInfo store_title_exist = null; if (storeInfo.ID == 0) { store_name_exist = EF.StoreInfos.Where(i => i.Name == storeInfo.Name).FirstOrDefault(); store_title_exist = EF.StoreInfos.Where(i => i.Title == storeInfo.Title).FirstOrDefault(); } else { store_exist = EF.StoreInfos.Where(i => i.ID == storeInfo.ID).FirstOrDefault(); if (store_exist == null) { alertMessage = new AlertMessage { Message = string.Format("门店编号[{0}]不存在。", storeInfo.ID), Type = AlertType.warning }; return(null); } store_name_exist = EF.StoreInfos.Where(i => i.ID != storeInfo.ID && i.Name == storeInfo.Name).FirstOrDefault(); store_title_exist = EF.StoreInfos.Where(i => i.ID != storeInfo.ID && i.Title == storeInfo.Title).FirstOrDefault(); } if (store_name_exist != null && store_name_exist.ID > 0) { alertMessage = new AlertMessage { Message = string.Format("门店代码[{0}]已被ID[{1}]使用。", storeInfo.Name, store_name_exist.ID), Type = AlertType.warning }; return(null); } if (store_title_exist != null && store_title_exist.ID > 0) { alertMessage = new AlertMessage { Message = string.Format("门店名称[{0}]已被ID[{1}]使用。", storeInfo.Title, store_title_exist.ID), Type = AlertType.warning }; return(null); } //数据保存 using (TransactionScope TS = new TransactionScope()) { //店名 if (storeInfo.ID == 0) { store_exist = EF.StoreInfos.Add(new StoreInfo { Enabled = true, }); } store_exist.Name = storeInfo.Name; store_exist.Title = storeInfo.Title; store_exist.LogoFileID = storeInfo.LogoFileID; EF.SaveChanges(); //联系信息 var contactInfo_exist = EF.ContactInfos.Where(i => i.EMail == contactInfo.EMail && i.Phone == contactInfo.Phone && i.Address == contactInfo.Address && i.Latitude == contactInfo.Latitude && i.Longitude == contactInfo.Longitude).FirstOrDefault(); if (contactInfo_exist == null) { EF.ContactInfos.Add(contactInfo_exist = contactInfo); EF.SaveChanges(); } var storeContact_exist = EF.StoreContacts.Where(i => i.StoreID == store_exist.ID).FirstOrDefault(); if (storeContact_exist == null) { EF.StoreContacts.Add(storeContact_exist = new StoreContact { StoreID = store_exist.ID, ContactID = contactInfo_exist.ID, }); } else { storeContact_exist.ContactID = contactInfo_exist.ID; } //图文 var photo_exist = EF.StorePhotos.Where(i => i.StoreID == store_exist.ID).FirstOrDefault(); if (photo_exist == null) { EF.StorePhotos.Add(photo_exist = new StorePhoto { StoreID = store_exist.ID, }); } photo_exist.FileIDs = storePhoto.FileIDs; var desc_exist = EF.StoreDescs.Where(i => i.StoreID == store_exist.ID).FirstOrDefault(); if (desc_exist == null) { EF.StoreDescs.Add(desc_exist = new StoreDesc { StoreID = store_exist.ID, }); } desc_exist.BusinessHours = storeDesc.BusinessHours; desc_exist.Description = storeDesc.Description; //保存 EF.SaveChanges(); TS.Complete(); } //更新完成 alertMessage = null; return(store_exist); } }
public static StoreContactDto ToDto(this StoreContact entity) { Init(); return(Mapper.Map <StoreContactDto>(entity)); }
public void TestGetObjectFromFileMethod() { StoreContact.getObjectFromFile(); }
public void TestSaveObjectToFileMethod() { contactlist.Add(new Contact("Chandan", "850741074")); StoreContact.saveObjectToFile(contactlist); }
/// <summary> /// Create a new StoreContact object. /// </summary> /// <param name="customerID">Initial value of CustomerID.</param> /// <param name="contactID">Initial value of ContactID.</param> /// <param name="rowguid">Initial value of rowguid.</param> /// <param name="modifiedDate">Initial value of ModifiedDate.</param> public static StoreContact CreateStoreContact(int customerID, int contactID, global::System.Guid rowguid, global::System.DateTime modifiedDate) { StoreContact storeContact = new StoreContact(); storeContact.CustomerID = customerID; storeContact.ContactID = contactID; storeContact.rowguid = rowguid; storeContact.ModifiedDate = modifiedDate; return storeContact; }
/// <summary> /// There are no comments for StoreContact in the schema. /// </summary> public void AddToStoreContact(StoreContact storeContact) { base.AddObject("StoreContact", storeContact); }
/// <summary> /// Make any alterations necessary (i.e. for DB check constraints, special test cases, etc.) /// </summary> /// <param name="mock">Object to be modified</param> static private void SetSpecialTestData(StoreContact mock) { //Code your changes to the data object here. }