public void CustomerDaoTests() { Assert.AreEqual(91, customerDao.GetAll().Count); Customer c = new Customer(new DefaultCustomerClassificationCalculator()); c.Id = "MPOLL"; c.CompanyName = "Interface21"; customerDao.Save(c); c = customerDao.Get("MPOLL"); Assert.AreEqual(c.Id, "MPOLL"); Assert.AreEqual(c.CompanyName, "Interface21"); //Without flushing, nothing changes in the database: int customerCount = (int)AdoTemplate.ExecuteScalar(CommandType.Text, "select count(*) from Customers"); Assert.AreEqual(91, customerCount); //Flush the session to execute sql in the db. SessionFactoryUtils.GetSession(sessionFactory, true).Flush(); //Now changes are visible outside the session but within the same database transaction customerCount = (int)AdoTemplate.ExecuteScalar(CommandType.Text, "select count(*) from Customers"); Assert.AreEqual(92, customerCount); Assert.AreEqual(92, customerDao.GetAll().Count); c.CompanyName = "SpringSource"; customerDao.Update(c); c = customerDao.Get("MPOLL"); Assert.AreEqual(c.Id, "MPOLL"); Assert.AreEqual(c.CompanyName, "SpringSource"); customerDao.Delete(c); SessionFactoryUtils.GetSession(sessionFactory, true).Flush(); customerCount = (int)AdoTemplate.ExecuteScalar(CommandType.Text, "select count(*) from Customers"); Assert.AreEqual(92, customerCount); try { c = customerDao.Get("MPOLL"); Assert.Fail("Should have thrown HibernateObjectRetrievalFailureException when finding customer with Id = MPOLL"); } catch (HibernateObjectRetrievalFailureException e) { Assert.AreEqual("Customer", e.PersistentClassName); } }
private void DisplayAllCustomers() { IDaoFactory daoFactory = new NHibernateDaoFactory(); ICustomerDao customerDao = daoFactory.GetCustomerDao(); grdEmployees.DataSource = customerDao.GetAll(); grdEmployees.DataBind(); }
public IActionResult GetAll([FromQuery] Page page, [FromQuery] CustomerFilter filter, [FromServices] CustomerDb db) { if (page == null || page.PageNo < 1 || page.PageSize < 1) { return(StatusCode((int)HttpStatusCode.BadRequest, new { error = "invalid page details" })); } return(Ok(_dao.GetAll(page, filter, db))); }
public bool CheckIfRealPerson(Customer entity) { foreach (var customer in _customerDao.GetAll()) { if ((customer.CustomerName == entity.CustomerName) && (customer.CustomerPassword == entity.CustomerPassword)) { return(true); } } return(false); }
public IHttpActionResult GetAll() { var results = _dao.GetAll(); return(Rop.Match(results, customers => { var dtos = customers.Select(DtoConverter.CustomerToDto); return Ok(dtos); }, failure => this.InternalServerErrorResponse("bad customers"))); }
public IHttpActionResult GetAll() { try { var dtos = _dao.GetAll().Select(DtoConverter.CustomerToDto); return(Ok(dtos)); } catch (Exception ex) { return(this.InternalServerError(ex)); } }
public ActionResult GetAll() { try { var dtos = _dao.GetAll().Select(DtoConverter.CustomerToDto); return(Ok(dtos)); } catch (Exception ex) { return(StatusCode(StatusCodes.Status500InternalServerError, ex)); } }
public IActionResult GetAll() { try { var dtos = _dao.GetAll().Select(DtoConverter.CustomerToDto); return(Ok(dtos)); } catch (Exception ex) { return(new ContentResult { StatusCode = 500, Content = ex.Message }); //StatusCode(500); } }
private void Page_InitializeControls(object sender, EventArgs e) { // create/initialize controls here customerList.DataSource = customerDao.GetAll(); customerList.ItemCommand += new DataGridCommandEventHandler(CustomerList_ItemCommand); customerList.PageIndexChanged += new DataGridPageChangedEventHandler(CustomerList_PageIndexChanged); if (!IsPostBack) { customerList.DataBind(); } else { customerList.ItemCreated += new DataGridItemEventHandler(this.CustomerList_ItemCreated); } }
public Aspose.Pdf.Generator.Pdf GetCustomerLabels() { Aspose.Pdf.Generator.Pdf pdf = new Aspose.Pdf.Generator.Pdf(); pdf.IsTruetypeFontMapCached = false; // If you have purchased a license, // Set license like this: // string licenseFile = MapPath("License") + "\\Aspose.Pdf.lic"; // Aspose.Pdf.License lic = new Aspose.Pdf.License(); // lic.SetLicense(licenseFile); string xmlFile = Server.MapPath("~/App_Data/xml/CustomerLabels.xml"); pdf.BindXML(xmlFile, null); Section section = pdf.Sections["section1"]; Aspose.Pdf.Generator.Table table1 = (Aspose.Pdf.Generator.Table)section.Paragraphs["table1"]; IList <Customer> customersList = customerDao.GetAll(); string[] strArr = new string[customersList.Count]; for (int i = 0; i < customersList.Count; i++) { strArr[i] = customersList[0].CompanyName.ToString() + "#$NL" + customersList[1].Address.ToString() + "#$NL" + customersList[2].City.ToString() + " " + (customersList[3].Region == null ? string.Empty : customersList[3].Region.ToString()) + " " + customersList[4].PostalCode.ToString() + "#$NL" + customersList[5].Country.ToString(); } table1.DefaultCellTextInfo.FontSize = 10; table1.ImportArray(strArr, 0, 0, false); foreach (Row cRow in table1.Rows) { foreach (Cell curCell in cRow.Cells) { curCell.Padding = new MarginInfo(); curCell.Padding.Top = 10; } } return(pdf); }
private void Page_InitializeControls(object sender, EventArgs e) { //searching the database only once per conversation. if (this.CustomersLoadedOncePerConvList == null) { // create/initialize controls here this.CustomersLoadedOncePerConvList = customerDao.GetAll(); } customerList.DataSource = this.CustomersLoadedOncePerConvList; customerList.ItemCommand += new DataGridCommandEventHandler(CustomerList_ItemCommand); customerList.PageIndexChanged += new DataGridPageChangedEventHandler(CustomerList_PageIndexChanged); if (!IsPostBack) { customerList.DataBind(); } else { customerList.ItemCreated += new DataGridItemEventHandler(this.CustomerList_ItemCreated); } }
public IDataResult <List <Customer> > GetAll() { return(new SuccessDataResult <List <Customer> >(_customerDao.GetAll())); }
public Workbook CreateCustomerLabels() { IList <Customer> customersList = customerDao.GetAll(); //Open a template file string designerFile = MapPath("~/App_Data/xls/Northwind.xls"); Workbook workbook = new Workbook(designerFile); //Get a worksheet Worksheet sheet = workbook.Worksheets["Sheet4"]; //Name the worksheet sheet.Name = "Customer Labels"; //Get the cells collection in the worksheet Aspose.Cells.Cells cells = sheet.Cells; int row = 0; byte column = 0; for (int i = 0; i < customersList.Count; i++) { int remainder = i % 3; Cell cell; switch (remainder) { case 0: column = 0; break; case 1: column = 3; break; case 2: column = 6; break; } //Get a cell cell = cells[row, column]; //Put a value into it cell.PutValue((string)customersList[i].CompanyName); //Get another cell cell = cells[row + 1, column]; //Put a value into it cell.PutValue((string)customersList[i].Address); //Get another cell cell = cells[row + 2, column]; string contact = ""; contact += (string)customersList[i].City + " "; contact += (string)customersList[i].Region + " "; contact += (string)customersList[i].PostalCode; //Put the value to it cell.PutValue(contact); //Get another cell cell = cells[row + 3, column]; //Put a value to it cell.PutValue((string)customersList[i].Country); if (remainder == 2) { row += 5; } } //Remove unnecessary worksheets in the workbook for (int i = 0; i < workbook.Worksheets.Count; i++) { sheet = workbook.Worksheets[i]; if (sheet.Name != "Customer Labels") { workbook.Worksheets.RemoveAt(i); i--; } } //Get the generated workbook return(workbook); }
public void InitView() { ICustomerDao customerDao = DaoFactory.GetCustomerDao(); view.Customers = customerDao.GetAll(); }
public List <Customer> GetAll() { return(_customerDao.GetAll()); }
public IList <CustomerDto> GetList() { return(DtoConverter.Convert(_customerDao.GetAll())); }