public IQueryable <HsrOrderApp.BL.DomainModel.Customer> GetAll() { var customers = from c in this.db.CustomerSet.Include("Orders").AsEnumerable() select CustomerAdapter.AdaptCustomer(c); return(customers.AsQueryable()); }
public CustomerAdapter PopulateCustomers(Activity activity, int resourceId, int textsomething) { if (customersLock == false) { CustomerAdapter custs = null;//,new List<CustomerSingle>()); JavaList <CustomerSingle> custsList = new JavaList <CustomerSingle>(); if (customers != null) { System.Collections.IEnumerator custEnum = customers.GetEnumerator(); custEnum.Reset(); int i = 0; while (custEnum.MoveNext()) { Customer active = (Customer)custEnum.Current; custsList.Add(new CustomerSingle(active.No_, active.Name, active.Address, i)); i++; } } custs = new CustomerAdapter(activity, resourceId, textsomething, custsList); return(custs); } else { return(null); } }
public void TestDtoToCustomer() { AddressDTO addressDto = new AddressDTO() { Id = 1, AddressLine1 = "FakeStreet", PostalCode = "FakePostalCode", City = "FakeCity", Phone = "FakePhone", Email = "FakeEmail", Version = 0 }; CustomerDTO dto = new CustomerDTO() { Id = 1, Name = "FakeUsername", FirstName = "FakeFirstname", Version = 1 }; dto.Addresses.Add(addressDto); Assert.AreEqual(true, dto.IsValid); Assert.AreEqual(true, addressDto.IsValid); Customer customer = CustomerAdapter.DtoToCustomer(dto); Assert.AreEqual <int>(dto.Id, customer.CustomerId); Assert.AreEqual <string>(dto.Name, customer.Name); Assert.AreEqual <string>(dto.FirstName, customer.FirstName); Assert.AreEqual(dto.Version, customer.Version); Assert.AreEqual(true, customer.IsValid); //Assert.AreEqual<int>(dto.Addresses.Count(), customer.Addresses.Count()); //Assert.AreEqual(true, address.IsValid); }
public ActionResult Delete(int customerId) { CustomerAdapter customerAdapter = new CustomerAdapter(); bool returnValue = customerAdapter.DeleteCustomer(customerId); return(RedirectToAction("Index")); }
public void ShouldFindOriginalAndPassModifiedToRepository() { ICustomerRepository repository = Substitute.For <ICustomerRepository>(); Customer original = new Customer(); setReturnedCustomer(repository, original); ICustomerMapper mapper = Substitute.For <ICustomerMapper>(); Customer modified = new Customer(); CustomerData viewModel = new CustomerData() { CustomerId = Guid.Empty.ToString("N") }; mapper.Convert(Arg.Any <CustomerData>()).Returns(modified); CustomerAdapter adapter = new CustomerAdapter(repository) { CustomerMapper = mapper }; adapter.UpdateCustomer(viewModel); repository.Received().GetCustomer(Arg.Any <Guid>()); mapper.Received().Convert(viewModel); repository.Received().Update(original, modified); }
public IQueryable <HsrOrderApp.BL.DomainModel.Customer> GetAll() { var customers = from c in this.db.Customers select CustomerAdapter.AdaptCustomer(c); return(customers); }
private string GetParentCustNumByCustNum(string code) { string returnV = ""; try { CustomerAdapter adapterCustomer = new CustomerAdapter(this.oTrans); adapterCustomer.BOConnect(); adapterCustomer.GetByCustID(code, false); if (adapterCustomer.CustomerData.Customer.Rows.Count == 1) { DataRow rRow = adapterCustomer.CustomerData.Customer[adapterCustomer.CustomerData.Customer.Rows.Count - 1]; if (rRow != null) { returnV = rRow["CustNum"].ToString(); } } adapterCustomer.Dispose(); } catch (Exception ex) { //ExceptionBox.Show(ex); return(""); } return(returnV); }
private void LoadTaskList() { List <string> taskList = dbHelper.GetTaskList(); adapter = new CustomerAdapter(this, taskList, dbHelper); lstTask.Adapter = adapter; }
public void ShouldSetDefaultMappers() { ICustomerRepository repository = Substitute.For <ICustomerRepository>(); CustomerAdapter adapter = new CustomerAdapter(repository); Assert.IsInstanceOfType(adapter.CustomerMapper, typeof(CustomerMapper), "The wrong customer mapper was set by default."); }
public static Customer PrepareJohnDoeCustomer() { var adapter = new CustomerAdapter(); var customer = adapter.AddCustomer(new CustomerBuilder().JohnDoe().Build()); adapter.SaveChanges(); return(customer); }
static void Main(string[] args) { IInvoicingTarget invoicingTarget = new CustomerAdapter(); ExternalBillingSystem client = new ExternalBillingSystem(invoicingTarget); client.RunInvoicing(); System.Console.ReadLine(); }
public void ShouldThrowExceptionIfCustomerNotFound() { ICustomerRepository repository = Substitute.For <ICustomerRepository>(); setReturnedCustomer(repository, null); CustomerAdapter adapter = new CustomerAdapter(repository); adapter.GetCustomer(Guid.Empty.ToString("N")); }
public void GivenWeTransformACustomerDTO() { customerDTO = new CustomerDTO { FirstName = "Robert", LastName = "Zimmerman" }; customerCompare = new Customer { Name = "Robert Zimmerman" }; customerAdapter = new CustomerAdapter(); }
public void test() { var ourCustomer = new OurCustomer("Sheen", "Dayal"); var adapter = new CustomerAdapter(); var customer = adapter.ConvertToCustomer(ourCustomer); var adaptorInterface = new CustomerAdapter2(); customer = adaptorInterface.Convert(ourCustomer); }
public void TestAdapter() { var adapter = new CustomerAdapter(new ExternalCustomerStore()); var client = new CustomerManagement(adapter); var adaptedCustomers = client.DisplayCustomers(); Assert.IsTrue(adaptedCustomers.Count() == 4); Assert.IsTrue(adaptedCustomers.First().Contains("adapted")); }
public GetCustomerResponse GetCustomerById(GetCustomerRequest request) { GetCustomerResponse response = new GetCustomerResponse(); CustomerBusinessComponent bc = DependencyInjectionHelper.GetCustomerBusinessComponent(); Customer customer = bc.GetCustomerById(request.CustomerId); response.Customer = CustomerAdapter.CustomerToDto(customer); return(response); }
public GetCustomersResponse GetCustomersByCriteria(GetCustomersRequest request) { GetCustomersResponse response = new GetCustomersResponse(); CustomerBusinessComponent bc = DependencyInjectionHelper.GetCustomerBusinessComponent(); IQueryable <Customer> customers = bc.GetCustomersByCriteria(request.SearchType, request.City, request.CustomerName); response.Customers = CustomerAdapter.CustomersToDtos(customers); return(response); }
public Customer GetCustomerObject(string userId, short pin) { ATM.CustomerDataTable customerTable = CustomerAdapter.GetCustomerBySecureInfo(userId, pin); if (customerTable.Count == 0) { return(new Customer()); } Customer customer = new Customer(customerTable[0].CustomerNumber, customerTable[0].FirstName, customerTable[0].LastName); customer.Status = ObjectStatus.Clean; return(customer); }
public void AdapterAddCustomerTest() { var expected = new CustomerBuilder().JohnDoe().Build(); var adapter = new CustomerAdapter(); var response = adapter.AddCustomer(expected); Assert.IsNotNull(response); var comparison = Utilities.CompareObjects(expected, response); Assert.IsTrue(comparison.AreEqual, $"Expected [{expected}] Actual [{response}]"); }
public Customer GetCustomer(string userId, short pin) { Customer customer = new Customer(); ATM.CustomerDataTable customerTable = CustomerAdapter.GetCustomerBySecureInfo(userId, pin); if (customerTable.Count == 0) { return(customer); } return(createCustomer(customerTable[0])); }
public StoreCustomerResponse StoreCustomer(StoreCustomerRequest request) { StoreCustomerResponse response = new StoreCustomerResponse(); CustomerBusinessComponent bc = DependencyInjectionHelper.GetCustomerBusinessComponent(); Customer customer = CustomerAdapter.DtoToCustomer(request.Customer); IEnumerable <ChangeItem> changeItems = CustomerAdapter.GetChangeItems(request.Customer, customer); response.CustomerId = bc.StoreCustomer(customer, changeItems); return(response); }
public void ShouldFindCustomerAndRemoveIt() { ICustomerRepository repository = Substitute.For<ICustomerRepository>(); Customer dto = new Customer(); setReturnedCustomer(repository, dto); CustomerAdapter adapter = new CustomerAdapter(repository); adapter.RemoveCustomer(Guid.Empty.ToString("N")); repository.Received().GetCustomer(Guid.Empty); repository.Received().Remove(dto); }
public void ResetAndInitializeTestData() { ObjectMother.ObjectMother.ClearTestData(); ObjectMother.ObjectMother.Instance.VerifyInitialization(); var bookAdapter = new BookAdapter(); var customerAdapter = new CustomerAdapter(); var libraryCardAdapter = new LibraryCardAdapter(); Assert.IsTrue(bookAdapter.Search(new Contracts.Books.SearchFilters(), null).PageData.Any(), "There are no test books"); Assert.IsTrue(customerAdapter.Search(new Contracts.Customers.SearchFilters(), null).PageData.Any(), "There are no test customers"); Assert.IsTrue(libraryCardAdapter.Search(new Contracts.LibraryCards.SearchFilters(), null).PageData.Any(), "There are no test library cards"); }
public void Initialize() { var adapter = new CustomerAdapter(); JohnDoe = adapter.AddCustomer(new CustomerBuilder().JohnDoe(ObjectMother.Instance.Books.FiveDysfunctions).Build()); adapter.SaveChanges(); JaneDoe = adapter.AddCustomer(new CustomerBuilder().JaneDoe( ObjectMother.Instance.Books.PhoenixProject).Build()); adapter.SaveChanges(); }
void CustomerEditorForm_UpdateAsync(object sender, DataActionEventArgs e) { CustomerAdapter ca = CreateAdapter <CustomerAdapter>(); if (!ca.ExistsWithCode(GetEditorData <Customer>())) { ca.Update(GetEditorData <Customer>()); } else { e.Cancelled = true; e.UserMessage = "An other customer with the specified code already exists."; } }
public void ShouldFindCustomerAndRemoveIt() { ICustomerRepository repository = Substitute.For <ICustomerRepository>(); Customer dto = new Customer(); setReturnedCustomer(repository, dto); CustomerAdapter adapter = new CustomerAdapter(repository); adapter.RemoveCustomer(Guid.Empty.ToString("N")); repository.Received().GetCustomer(Guid.Empty); repository.Received().Remove(dto); }
public StoreCustomerResponse StoreCustomer(StoreCustomerRequest request) { if (!HttpContext.Current.User.Identity.IsAuthenticated) { throw new FaultException <NotAuthenticatedFault>(new NotAuthenticatedFault()); } StoreCustomerResponse response = new StoreCustomerResponse(); CustomerBusinessComponent bc = DependencyInjectionHelper.GetCustomerBusinessComponent(); Customer customer = CustomerAdapter.DtoToCustomer(request.Customer); IEnumerable <ChangeItem> changeItems = CustomerAdapter.GetChangeItems(request.Customer, customer); response.CustomerId = bc.StoreCustomer(customer, changeItems); return(response); }
private void LoadData() { try { CustomerAdapter adapter = new CustomerAdapter( SQLConnection.GetDataBase()); CustomerList = adapter.GetAllCustomer(); LV_Customer.ItemsSource = CustomerList.Tables[0].DefaultView; } catch (Exception ex) { MessageBox.Show("异常发生,请检查数据库连接", "错误", MessageBoxButton.OK, MessageBoxImage.Error); //写入日志 } }
void CustomerViewer_DeleteAsync(object sender, DataActionEventArgs e) { WebsiteAdapter wa = CreateAdapter <WebsiteAdapter>(); CustomerAdapter ca = CreateAdapter <CustomerAdapter>(); int[] indexes = e.GetData <DataViewerOpenArgs>().SelectedIndices; foreach (Customer customer in indexes.Select(i => customerList[i])) { bool removeCustomer = true; Website[] websites = wa.GetFromCustomer(customer.DataID); if (websites.Count() != 0) { string websiteNames = string.Join(", ", websites.Select(w => w.Name).ToArray()); DialogResult result = (DialogResult)Invoke((MessageBoxInvoker) delegate { return(MessageBox.Show( "Removing the customer (" + customer.CodeAndName + ") " + "will remove all associated websites (" + websiteNames + "). " + "Would you like to remove this customer?", "Remove websites", MessageBoxButtons.YesNo, MessageBoxIcon.Warning)); }); removeCustomer = (result == DialogResult.Yes); } if (removeCustomer) { CustomerDeleteResult cdr = ca.Delete(customer.DataID); if (cdr.Errors.Length != 0) { Invoke((MethodInvoker) delegate { MessageBox.Show( "One or more errors occured while deleting " + "customer '" + customer.CodeAndName + "'.\r\n\r\n" + string.Join("\r\n", cdr.Errors.Select(error => "> " + error).ToArray()), "Delete customer", MessageBoxButtons.OK, MessageBoxIcon.Warning); }); } } } }
public ActionResult Edit(int customerId) { CustomerAdapter customerAdapter = new CustomerAdapter(); Customer customer = customerAdapter.GetById(customerId); if (customer == null) { return(RedirectToAction("Index")); } else { CustomerModels model = new CustomerModels(); model.CustomerId = customer.CustomerId; model.FirstName = customer.FirstName; model.LastName = customer.LastName; return(View(model)); } }
public void TestDtoToAddress() { CustomerDTO customerDTO = new CustomerDTO(); customerDTO.MarkChildForInsertion(new AddressDTO { Id = 1, City = "FakeCity", Email = "FakeEmail", Phone = "09", PostalCode = "1234", AddressLine1 = "FakeStreet", Version = 0 }); customerDTO.MarkChildForUpdate(new AddressDTO { Id = 2, City = "FakeCity", Email = "FakeEmail", Phone = "09", PostalCode = "1234", AddressLine1 = "FakeStreet", Version = 0 }); customerDTO.MarkChildForDeletion(new AddressDTO { Id = 3, City = "FakeCity", Email = "FakeEmail", Phone = "09", PostalCode = "1234", AddressLine1 = "FakeStreet", Version = 0 }); IEnumerable <ChangeItem> changeItems = CustomerAdapter.GetChangeItems(customerDTO, new Customer()); Assert.AreEqual <int>(3, changeItems.Count()); }
public void ShouldFindOriginalAndPassModifiedToRepository() { ICustomerRepository repository = Substitute.For<ICustomerRepository>(); Customer original = new Customer(); setReturnedCustomer(repository, original); ICustomerMapper mapper = Substitute.For<ICustomerMapper>(); Customer modified = new Customer(); CustomerData viewModel = new CustomerData() { CustomerId = Guid.Empty.ToString("N") }; mapper.Convert(Arg.Any<CustomerData>()).Returns(modified); CustomerAdapter adapter = new CustomerAdapter(repository) { CustomerMapper = mapper }; adapter.UpdateCustomer(viewModel); repository.Received().GetCustomer(Arg.Any<Guid>()); mapper.Received().Convert(viewModel); repository.Received().Update(original, modified); }
public void ShouldAddConvertedCustomerToRepositoryAndReturnUpdated() { ICustomerRepository repository = Substitute.For<ICustomerRepository>(); ICustomerMapper mapper = Substitute.For<ICustomerMapper>(); Customer dto = new Customer(); CustomerData viewModelInput = new CustomerData(); CustomerData viewModelOutput = new CustomerData(); mapper.Convert(viewModelInput).Returns(dto); mapper.Convert(dto).Returns(viewModelOutput); CustomerAdapter adapter = new CustomerAdapter(repository) { CustomerMapper = mapper }; CustomerData result = adapter.AddCustomer(viewModelInput); Assert.AreSame(viewModelOutput, result, "The updated view model was not returned."); mapper.Received().Convert(viewModelInput); repository.Received().Add(dto); mapper.Received().Convert(dto); }
public void ShouldThrowExceptionIfCustomerNotFound() { ICustomerRepository repository = Substitute.For<ICustomerRepository>(); setReturnedCustomer(repository, null); CustomerAdapter adapter = new CustomerAdapter(repository); adapter.GetCustomer(Guid.Empty.ToString("N")); }
public void ShouldSetDefaultMappers() { ICustomerRepository repository = Substitute.For<ICustomerRepository>(); CustomerAdapter adapter = new CustomerAdapter(repository); Assert.IsInstanceOfType(adapter.CustomerMapper, typeof(CustomerMapper), "The wrong customer mapper was set by default."); }
public void ShouldMapCustomerToViewModel() { ICustomerRepository repository = Substitute.For<ICustomerRepository>(); Customer dto = new Customer(); setReturnedCustomer(repository, dto); ICustomerMapper mapper = Substitute.For<ICustomerMapper>(); CustomerData viewModel = new CustomerData(); mapper.Convert(dto).Returns(viewModel); CustomerAdapter adapter = new CustomerAdapter(repository) { CustomerMapper = mapper }; PrimitiveMapper primitiveMapper = new PrimitiveMapper(); CustomerData data = adapter.GetCustomer(primitiveMapper.ToString(Guid.Empty)); repository.Received().GetCustomer(dto.CustomerId); mapper.Received().Convert(dto); Assert.IsNotNull(data, "The returned view model was null."); }
private void OnBind(int index, string as_where) { ListView list = FindViewById<ListView>(Resource.Id.customer_items); TextView page = FindViewById<TextView>(Resource.Id.customer_Page); DataTable ldt = new DataTable(); int count = 0; string sql = "select cus_code,cus_name,mobile from customer "; if (!string.IsNullOrEmpty(as_where)) { sql += "where cus_code like '%" + as_where + "%'"; sql += "or cus_name like '%" + as_where + "%'"; sql += "or mobile like '%" + as_where + "%'"; } ldt = SqliteHelper.ExecuteDataTable(sql, pageSize, pageIndex, ref count); if (count % 10 == 0) pageCount = count / 10; else pageCount = count / 10 + 1; page.Text = pageIndex + "/" + pageCount; CustomerAdapter listItemAdapter = new CustomerAdapter(this, ldt); list.Adapter = listItemAdapter; }
/// <summary> /// 屏蔽返回键 /// </summary> //public override bool OnKeyDown(Android.Views.Keycode keyCode, Android.Views.KeyEvent e) //{ // if (keyCode == Keycode.Back) // { // return false; // } // return base.OnKeyDown(keyCode, e); //} private void OnBind(int index, string as_where) { ListView list = FindViewById<ListView>(Resource.Id.customer_items); TextView page = FindViewById<TextView>(Resource.Id.customer_Page); DataTable ldt = new DataTable(); int count = 0; string ls_where = ""; string sql = "select customer.cus_code,customer.cus_name,customer.mobile,customer.cus_city from customer where 1=1 #### order by modifydate desc"; if (ab_check) { //当选择有补货时 只显示最近一年有订货的 and oldsaleprice.saledate>=date(datetime(),'start of day','-1 days','-1 year') group by customer.cus_code sql = @"select customer.cus_code,customer.cus_name,customer.mobile,customer.cus_city from customer where lastsaledate<>'' #### order by lastsaledate desc"; } if (!string.IsNullOrEmpty(as_where)) { ls_where += " and customer.cus_code like '%" + as_where + "%'"; ls_where += "or customer.cus_name like '%" + as_where + "%'"; ls_where += "or customer.mobile like '%" + as_where + "%' "; sql = sql.Replace("####", ls_where); } else sql = sql.Replace("####", ""); ldt = SqliteHelper.ExecuteDataTable(sql, pageSize, pageIndex, ref count); for (int i = 0; i < ldt.Rows.Count; i++) { string city = ldt.Rows[i]["cus_city"].ToString(); if (!SysVisitor.IsChinese(city)) { string newCity = SqliteHelper.ExecuteScalar("select * from city where cityno='" + city + "'"); if (!string.IsNullOrEmpty(newCity)) ldt.Rows[i]["cus_city"] = newCity; } } if (count % 10 == 0) pageCount = count / 10; else pageCount = count / 10 + 1; page.Text = pageIndex + "/" + pageCount; CustomerAdapter listItemAdapter = new CustomerAdapter(this, ldt, IntentName); list.Adapter = listItemAdapter; }
public CustomerAdapter PopulateCustomers(Activity activity, int resourceId, int textsomething) { if (customersLock == false) { CustomerAdapter custs = null;//,new List<CustomerSingle>()); JavaList<CustomerSingle> custsList = new JavaList<CustomerSingle>(); if (customers != null) { System.Collections.IEnumerator custEnum = customers.GetEnumerator(); custEnum.Reset(); int i = 0; while (custEnum.MoveNext()) { Customer active = (Customer)custEnum.Current; custsList.Add(new CustomerSingle(active.No_, active.Name, active.Address, i)); i++; } } custs = new CustomerAdapter(activity, resourceId, textsomething, custsList); return custs; } else { return null; } }
public void ShouldGetCustomersFromRepository() { ICustomerRepository repository = Substitute.For<ICustomerRepository>(); Customer[] customers = new Customer[] { new Customer() }; repository.GetCustomers().Returns(customers); ICustomerMapper mapper = Substitute.For<ICustomerMapper>(); mapper.Convert(Arg.Any<Customer>()).Returns(new CustomerData()); CustomerAdapter adapter = new CustomerAdapter(repository) { CustomerMapper = mapper }; IEnumerable<CustomerData> results = adapter.GetCustomers(); repository.Received().GetCustomers(); mapper.Received(1).Convert(customers[0]); Assert.IsNotNull(results, "Null was returned by the adapter."); Assert.AreEqual(1, results.Count(), "The wrong number of view models were returned."); }