public void LoadData() { _Customers = new ObservableCollection <CustomerModel>(); var customerList = customerRepository.Retrieve(); CustomerTypeRepository customerTypeRepository = new CustomerTypeRepository(); var customerTypeList = customerTypeRepository.Retrieve(); //var sortedList = customerRepository.SortByName(customerList); // var itemList = customerRepository.GetNamesAndId(customerList); //var itemList = customerRepository.GetNamesAndType(customerList, // customerTypeList); var query = customerList.Join(customerTypeList, c => c.CustomerTypeId, ct => ct.CustomerTypeId, (c, ct) => new CustomerModel { Name = c.LastName + ", " + c.FirstName, CustomerTypeName = ct.TypeName }); foreach (var customerInstance in query.OrderBy(c => c.Name)) { _Customers.Add(customerInstance); } ChartData = customerRepository.GetInvoiceTotalByCustomerType(customerList, customerTypeList).ToList(); }
static void Main(string[] args) { CustomerRepository cRep = new CustomerRepository(); CustomerTypeRepository ctRep = new CustomerTypeRepository(); Console.WriteLine("\n********** Customers **********\n"); foreach (var customer in cRep.Customers) { Console.WriteLine(customer.CustomerId + " " + customer.LastName + " " + customer.FirstName + " " + customer.EmailAddress); } Console.WriteLine("\n********** CustomersByOrder **********\n"); cRep.OrderCustomers(); foreach (var customer in cRep.Customers) { Console.WriteLine(customer.CustomerId + " " + customer.LastName + " " + customer.FirstName + " " + customer.EmailAddress); } Console.WriteLine("\n********** CustomersName&Type **********\n"); var query = cRep.GetNamesAndTypes(cRep.Customers, ctRep.CustomerType); foreach (var customer in query) { Console.WriteLine(customer); } }
public CustomerRepositoryTestShould(CustomerRepositoryFixture customerRepoFixture, CustomerTypeRepositoryFixture customerTypeRepoFixture, ITestOutputHelper output) { customerRepo = customerRepoFixture.CustomerRepository; invoiceRepo = customerRepoFixture.InvoiceRepository; customerTypeRepo = customerTypeRepoFixture.Repository; this.output = output; }
public void TestGetNamesTypes() { CustomerRepository testRepo = new CustomerRepository(); CustomerTypeRepository typeRepo = new CustomerTypeRepository(); testRepo.GetNamesAndType(testRepo.Retrieve(), typeRepo.Retrieve()); }
public void GetInvoiceTotalByCustomerTypeTest() { //Arange CustomerRepository customerRepo = new CustomerRepository(); var customerList = customerRepo.Retrieve(); CustomerTypeRepository customerTypeRepo = new CustomerTypeRepository(); var customerTypeList = customerTypeRepo.Retrieve(); //Act var result = customerRepo.GetInvoiceTotalByCustomerType(customerList, customerTypeList); }
public void GetNamesAndTypesTest() { // Arrange CustomerRepository customerRepository = new CustomerRepository(); CustomerTypeRepository customerTypeRepository = new CustomerTypeRepository(); var customerList = customerRepository.Retrieve(); var customerTypeList = customerTypeRepository.Retrieve(); // Act var query = customerRepository.GetNamesAndTypes(customerList, customerTypeList); }
public void GetNamesAndTypeTest() //For output { // Arrange CustomerRepository repository = new CustomerRepository(); var customerList = repository.Retrieve(); CustomerTypeRepository typeRepository = new CustomerTypeRepository(); var customerTypeList = typeRepository.Retrieve(); // Act var query = repository.GetNamesAndType(customerList, customerTypeList); }
public void GetInvoiceTotalByCustomerTypeTest() { // Arrange var repository = new CustomerRepository(); var customerList = repository.Retrieve(); var typeRepository = new CustomerTypeRepository(); var customerTypeList = typeRepository.Retrieve(); // Act var query = repository.GetInvoiceTotalByCustomerType(customerList, customerTypeList); }
public void GetNamesAndTypeTest() { //Arange CustomerRepository customerRepo = new CustomerRepository(); var customerList = customerRepo.Retrieve(); CustomerTypeRepository customerTypeRepo = new CustomerTypeRepository(); var customerTypeList = customerTypeRepo.Retrieve(); //Act var customerNamesAndType = customerRepo.GetNamesAndType(customerList, customerTypeList); }
public void GetInvoiceTotalByCustomerType() { var repo = new CustomerRepository(); var customerList = repo.Retrieve(); var typeRepo = new CustomerTypeRepository(); var typeList = typeRepo.Retrieve(); var query = repo.GetInvoiceTotalByCustomerType(customerList, typeList); //NOT REALLY A TEST }
public void GetNamesAndTypeTest() { var repo = new CustomerRepository(); var customerList = repo.Retrieve(); var typeRepo = new CustomerTypeRepository(); var typeList = typeRepo.Retrieve(); var query = repo.GetNamesAndType(customerList, typeList); //NOT REALLY A TEST }
public void GetNamesAndTypesTest() { CustomerRepository repo = new CustomerRepository(); var names = repo.Retrieve(); CustomerTypeRepository typeRepo = new CustomerTypeRepository(); var types = typeRepo.Retrieve(); var result = repo.GetNamesAndTypes(names, types); // NOT really a test because no assertions }
public void GetInvoiceTotalByCustomerTypeTest() { CustomerRepository repo = new CustomerRepository(); var customerList = repo.Retrieve(); CustomerTypeRepository custTypeRepo = new CustomerTypeRepository(); var customerTypeList = custTypeRepo.Retrieve(); var result = repo.GetInvoiceTotalByCustomerType(customerList, customerTypeList); //Assert.IsTrue(result.Count() > 0); //Assert.AreEqual(null, result.Last().CustomerType); }
public void GetNamesAndType() { //Arrange var repository = new CustomerRepository(); var typeRepository = new CustomerTypeRepository(); var customerList = repository.Retrieve(); var customerTypeList = typeRepository.Retrieve(); //Act var customers = repository.GetNamesAndType(customerList, customerTypeList); //Assert }
public void GetInvoiceTotalByCustomerTest() { //Arrange CustomerRepository repository = new CustomerRepository(); var customerList = repository.Retrieve(); CustomerTypeRepository typeRepository = new CustomerTypeRepository(); var customerTypeList = typeRepository.Retrieve(); //Act var query = repository.GetInvoiceTotalByCustomerType(customerList, customerTypeList); //NOT REALLY A TEST }
private void GetCustomersButton_Click(object sender, EventArgs e) { //CustomerGridView.DataSource = customerRepository.Retrieve(); var customerList = customerRepository.Retrieve(); //CustomerGridView.DataSource = customerRepository.SortByName(customerList).ToList(); CustomerTypeRepository customerTypeRepository = new CustomerTypeRepository(); var customerTypeList = customerTypeRepository.Retrieve(); CustomerGridView.DataSource = customerRepository.GetNamesAndType(customerList, customerTypeList); }
public void GetNamesAndTypeTest() { //-- Arrange var customerRepository = new CustomerRepository(); var customerList = customerRepository.Retrieve(); var customerTypeRepository = new CustomerTypeRepository(); var customerTypeList = customerTypeRepository.Retrieve(); //-- Act var query = customerRepository.GetNamesAndType(customerList, customerTypeList); //-- NOT AN ACTUAL TEST }
public void GetNamesAndTypeTest() { // Arrange CustomerRepository repository = new CustomerRepository(); var customerList = repository.Retrieve(); CustomerTypeRepository typeRepository = new CustomerTypeRepository(); var customerTypeList = typeRepository.Retrieve(); // Act var query = repository.GetNamesAndType(customerList, customerTypeList); //NOT REALLY A TEST - it just lets us see output easily. }
public void GetNamesAndTypeTest() { // Arrange CustomerRepository repository = new CustomerRepository(); var customerList = repository.Retrive(); CustomerTypeRepository typeRepository = new CustomerTypeRepository(); var customerTypeList = typeRepository.Retrive(); // Act var query = repository.GetNamesAndType(customerList, customerTypeList); // NOT REALLY A TEST }
public void GetInvoiceTotalByCustomerTypeTest() { //Arrange CustomerRepository customerRepository = new CustomerRepository(); CustomerTypeRepository customerTypeRepository = new CustomerTypeRepository(); var customerList = customerRepository.Retrieve(); var customerTypeList = customerTypeRepository.Retrieve(); //Act var invoiceTotalByCustomerTypeList = customerRepository.GetInvoiceTotalByCustomerType(customerList, customerTypeList); //Assert Assert.IsNotNull(customerList); }
public void GetDueByCustomertype() { //Arrange var customerTypeRepository = new CustomerTypeRepository(); var types = customerTypeRepository.Retreive(); //Act var result = _repository.GetInvoiceTotalByCustomerType(_list, types); foreach (var group in result) { Debug.WriteLine(group); } //Assert Assert.IsNotNull(result); }
public void GetNameAndType() { //Arrange var customerTypeRepository = new CustomerTypeRepository(); var typeList = customerTypeRepository.Retreive(); //Act var list = _repository.GetNameAndType(_list, typeList); //Analyze foreach (var item in list) { Debug.WriteLine(item); } //Assert Assert.IsNotNull(list); }
public void GetInvoicebyCustomerTypeTest() { //Begin Arrange CustomerRepository repository = new CustomerRepository(); var customerList = repository.Retrieve(); CustomerTypeRepository typeRepsoitory = new CustomerTypeRepository(); var customerTypeList = typeRepsoitory.Retrieve(); //End Arrange //Begin Act var query = repository.GetInvoiceTotalByCustomerType(customerList, customerTypeList); //End Act //Begin Assert //not really a test I justplay a test on netflix //End Assert }
public void LoadData() { _customers = new ObservableCollection <CustomerModel>(); var customerList = customerRepository.Retrieve(); var customerTypeList = new CustomerTypeRepository().Retreive(); //var customers = customerRepository.GetNameAndType(customerList, customerTypeList); var customers = customerList.Join(customerTypeList, //Iinner List customer => customer.CustomerTypeId, //Property of the outer object on which Join will happen type => type.CustomerTypeId, //Property of the inner object on which Join will happen (c, ct) => new CustomerModel() //New Property that will be created { CustomerName = string.Format("{0}, {1}", c.LastName, c.FirstName), CustomerTypeName = ct.CustomerTypeName }); foreach (var customer in customers) { _customers.Add(customer); } }
// Anytime we would create a CustomerTypeEngine object // it would create an instance of the CustomerTypeRepository class public CustomerTypeEngine() { _repository = new CustomerTypeRepository(); }
public void TestInitialize() { _customerRepo = new CustomerRepository(); _customerTypeRepo = new CustomerTypeRepository(); }
public void GetNamesAndTypeTest() { //Begin Arrange CustomerRepository repository = new CustomerRepository(); var customerList = repository.Retrieve(); CustomerTypeRepository typeRepository = new CustomerTypeRepository(); var customerTypeList = typeRepository.Retrieve(); //End Arrange //Begin Act var query = repository.GetNamesAndType(customerList, customerTypeList); //End Act //Begin Assert //End Assert }
protected void btnImport_Click(object sender, EventArgs e) { btnImport.Enabled = false; fuImport.Enabled = false; btnImport.Text = "Processing..."; if (!fuImport.HasFile) ScriptManager.RegisterStartupScript(this, this.GetType(), "Message", "alert('Chọn file để nhập');", true); else { string ext = fuImport.FileName.Substring(fuImport.FileName.LastIndexOf('.') + 1).ToLower(); if (!ext.Equals("xls") && !ext.Equals("xlsx")) ScriptManager.RegisterStartupScript(this, this.GetType(), "Message", "alert('Định dạng file nhập ko đúng');", true); else { string newFileName = Guid.NewGuid().ToString("N") + "." + ext; string pathToFile = Server.MapPath("~\\Import") + "\\" + newFileName; fuImport.SaveAs(pathToFile); try { ObjLogin adm = (ObjLogin)Session["objLogin"]; int smsquota = int.Parse(ConfigurationManager.AppSettings["SMSQuota"]); double expiredDateConfig = Convert.ToDouble(ConfigurationManager.AppSettings["ExpiredDate"]); DateTime expiredDate = Convert.ToDateTime(DateTime.Now.AddDays(expiredDateConfig)); var GRepo = new GroupsRepository(); var RegionRepo = new RegionsRepository(); var AreaRepo = new AreasRepository(); var LocalRepo = new LocalsRepository(); var ChRepo = new ChannelRepository(); var SaleRepo = new SalesmanRepository(); var CLogRepo = new CustomersLogRepository(); var CRepo = new CustomersRepository(); var CTRepo = new CustomerTypeRepository(); var DisRepo = new DistrictsRepository(); var proviceRepo = new ProvincesRepository(); var sectionRepo = new SectionRepository(); SpreadsheetInfo.SetLicense("E24D-D739-F65A-4E00"); ExcelFile ef = new ExcelFile(); ef.LoadXls(pathToFile); ExcelWorksheet ws = ef.Worksheets[0]; for (int i = 2; i < ws.Rows.Count; i++) { try { vwMasterList vmMasterItem = new vwMasterList(ws.Rows[i].Cells[4].Value.ToString(), ws.Rows[i].Cells[5].Value.ToString(), ws.Rows[i].Cells[6].Value.ToString(), ws.Rows[i].Cells[7].Value.ToString(), ws.Rows[i].Cells[8].Value.ToString(), ws.Rows[i].Cells[9].Value.ToString(), ws.Rows[i].Cells[10].Value.ToString(), ws.Rows[i].Cells[11].Value.ToString(), ws.Rows[i].Cells[12].Value.ToString(), ws.Rows[i].Cells[13].Value.ToString(), ws.Rows[i].Cells[14].Value.ToString(), ws.Rows[i].Cells[15].Value.ToString(), ws.Rows[i].Cells[17].Value.ToString(), ws.Rows[i].Cells[18].Value.ToString(), ws.Rows[i].Cells[19].Value.ToString(), ws.Rows[i].Cells[20].Value.ToString(), ws.Rows[i].Cells[22].Value.ToString(), ws.Rows[i].Cells[23].Value.ToString(), ws.Rows[i].Cells[24].Value.ToString()); // Add Group - Region - Area - Local var groupId = GRepo.Import("", vmMasterItem.Group, ""); var regionId = RegionRepo.Import("", vmMasterItem.Region, "", groupId); var areaId = AreaRepo.Import("", vmMasterItem.Area, "", regionId); var localId = LocalRepo.Import("", vmMasterItem.Local, "", areaId); // Add section var sectionId = sectionRepo.Import(vmMasterItem.Area); // Add Province var provinceId = proviceRepo.Import(vmMasterItem.Local, sectionId); // Add District var districtId = DisRepo.Import(vmMasterItem.Local, provinceId); // Add Channel ChRepo.Insert("", vmMasterItem.Channel1, 0); ChRepo.Insert("", vmMasterItem.Channel2, ChRepo.GetChannelIdByName(vmMasterItem.Channel1)); ChRepo.Insert("", vmMasterItem.Channel3, ChRepo.GetChannelIdByName(vmMasterItem.Channel2)); // Add Customer Type CTRepo.Add("", vmMasterItem.Channel3); // Add Salesmen var tromId = SaleRepo.ImportSalesmen("", vmMasterItem.TROM, "", (int)SalesmenRole.TROM, smsquota, expiredDate, -1); var tpsId = SaleRepo.ImportSalesmen("", vmMasterItem.TPS, "", (int)SalesmenRole.TPS, smsquota, expiredDate, tromId); var tprId = SaleRepo.ImportSalesmen("", vmMasterItem.TPR, "", (int)SalesmenRole.TPR, smsquota, expiredDate, tpsId); var eromId = SaleRepo.ImportSalesmen("", vmMasterItem.EROM, "", (int)SalesmenRole.EROM, smsquota, expiredDate, -1); var pss1Id = SaleRepo.ImportSalesmen("", vmMasterItem.PSS1, "", (int)SalesmenRole.PSS1, smsquota, expiredDate, eromId); var psr1Id = SaleRepo.ImportSalesmen("", vmMasterItem.PSR1, "", (int)SalesmenRole.PSR1, smsquota, expiredDate, pss1Id); var erom2Id = SaleRepo.ImportSalesmen("", vmMasterItem.EROM2, "", (int)SalesmenRole.EROM2, smsquota, expiredDate, -1); var pss2Id = SaleRepo.ImportSalesmen("", vmMasterItem.PSS2, "", (int)SalesmenRole.PSS2, smsquota, expiredDate, erom2Id); var psr2Id = SaleRepo.ImportSalesmen("", vmMasterItem.PSR2, "", (int)SalesmenRole.PSR2, smsquota, expiredDate, pss2Id); // Add Salesgroup - salesregion - salesarea - saleslocal ImportSalesGroup(tromId, tpsId, tprId, eromId, pss1Id, psr1Id, erom2Id, pss2Id, psr2Id, GRepo, groupId); ImportSalesRegion(tromId, tpsId, tprId, eromId, pss1Id, psr1Id, erom2Id, pss2Id, psr2Id, RegionRepo, regionId); ImportSalesArea(tromId, tpsId, tprId, eromId, pss1Id, psr1Id, erom2Id, pss2Id, psr2Id, AreaRepo, areaId); ImportSalesLocal(tromId, tpsId, tprId, eromId, pss1Id, psr1Id, erom2Id, pss2Id, psr2Id, LocalRepo, localId); // Add Customer - Customer Log int CustomerId = CRepo.InsertCustomer(vmMasterItem.CustomerCode, vmMasterItem.Customername, vmMasterItem.Customeraddress, "", "", "", "", CTRepo.GetCustomerTypeIdByName(vmMasterItem.Channel3), ChRepo.GetChannelIdByName(vmMasterItem.Channel3), districtId, localId, DateTime.Now, DateTime.Now, true, false); CLogRepo.InsertCustomer(vmMasterItem.CustomerCode, vmMasterItem.Customername, vmMasterItem.Customeraddress, "", "", "", "", CTRepo.GetCustomerTypeIdByName(vmMasterItem.Channel3), ChRepo.GetChannelIdByName(vmMasterItem.Channel3), districtId, localId, DateTime.Now, DateTime.Now, true, CustomerId, false, 0, adm.Id, string.Empty); lstCustomer.Add(vmMasterItem); } catch (Exception ex) { // write log here => TBD } } CustomerList.DataSource = lstCustomer; CustomerList.DataBind(); } catch (Exception ex) { ScriptManager.RegisterStartupScript(this, this.GetType(), "Message", "alert('" + ex.Message + "');", true); } finally { } } } btnImport.Enabled = true; fuImport.Enabled = true; btnImport.Text = "Import"; }
public CustomerTypeController() { _customerTypeRepository = new CustomerTypeRepository(); }
public void GetNamesAndTypeTest() { // Arrange CustomerRepository repository = new CustomerRepository(); var customerList = repository.Retrieve(); CustomerTypeRepository typeRepository = new CustomerTypeRepository(); var customerTypeList = typeRepository.Retrieve(); // Act var query = repository.GetNamesAndType(customerList, customerTypeList); // NOT REALLY A TEST }