/// <summary> /// Saving into Elastic /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnSave_Click(object sender, EventArgs e) { try { //TODO Validation DTO.Customer entity = new DTO.Customer(); entity.Age = int.Parse(nudAge.Value.ToString()); entity.Birthday = dtpBirthday.Value.ToString(DTO.Constants.BASIC_DATE); entity.EnrollmentFee = double.Parse(mskEnrollmentFee.Text); entity.HasChildren = bool.Parse(cboHasChildren.Text); entity.Name = txtName.Text; entity.Opinion = txtOpnion.Text; entity.Id = int.Parse(mskId.Text); if (_customerBll.Index(entity)) { MessageBox.Show("Index saved!", "Ok", MessageBoxButtons.OK, MessageBoxIcon.Information); } } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } }
public static List <DTO.Customer> GetCustomers() { ACMEEntities db = new ACMEEntities(); var dbCustomers = db.Customers.OrderBy(p => p.Name).ToList(); var dtoCustomers = new List <DTO.Customer>(); foreach (var dbCustomer in dbCustomers) { var dtoCustomer = new DTO.Customer(); dtoCustomer.CustomerId = dbCustomer.CustomerId; dtoCustomer.Name = dbCustomer.Name; dtoCustomer.Address = dbCustomer.Address; dtoCustomer.City = dbCustomer.City; dtoCustomer.State = dbCustomer.State; dtoCustomer.PostalCode = dbCustomer.PostalCode; dtoCustomer.Notes = dbCustomer.Notes; dtoCustomers.Add(dtoCustomer); } return(dtoCustomers); }
public static void AddOrder(DTO.Order current_order, DTO.Customer current_customer) { PapaBobEntities db = new PapaBobEntities(); System.Data.Entity.DbSet <Order> dbOrders = db.Orders; var dbCustomers = db.Customers; var new_order = new Persistence.Order(); CreateNewOrder(current_order, out new_order); var dbCustomersList = db.Customers.ToList(); bool check_if_customer_exits = CustomerRepository.CustomerExists(dbCustomersList, current_customer); if (!check_if_customer_exits) { var new_customer = new Customer(); CustomerRepository.CreateNewCustomer(current_customer, out new_customer); new_order.customer_id = new_customer.customer_id; new_customer.amount_owing = current_order.payment_type != DTO.Payment.Cash ? current_order.cost : 0; new_order.Customer = new_customer; dbCustomers.Add(new_customer); } else { var existing_customer = dbCustomersList?.Find(p => p.phone_number == current_customer.phone_number); new_order.customer_id = existing_customer.customer_id; existing_customer.amount_owing += current_order.payment_type != DTO.Payment.Cash ? current_order.cost : 0; } dbOrders.Add(new_order); db.SaveChanges(); }
public static void CreateNewCustomer(DTO.Customer current_customer, out Persistence.Customer new_customer) { new_customer = new Customer(); CustomerMapper(current_customer, out new_customer); System.Guid customer_id = Guid.NewGuid(); new_customer.customer_id = customer_id; }
public static void AddCustomer(DTO.Customer newCustomer) { ACMEEntities db = new ACMEEntities(); var dbCustomers = db.Customers; var customer = new Customer(); if (newCustomer.Name.Trim().Length == 0) { throw new Exception("Name is a required field."); } customer.CustomerId = newCustomer.CustomerId; customer.Name = newCustomer.Name; customer.Address = newCustomer.Address; customer.City = newCustomer.City; customer.State = newCustomer.State; customer.PostalCode = newCustomer.PostalCode; customer.Notes = newCustomer.Notes; try { dbCustomers.Add(customer); db.SaveChanges(); } catch (Exception ex) { //Log the exception. throw ex; } }
public static void CustomerMapper(DTO.Customer current_customer, out Persistence.Customer new_customer) { new_customer = new Persistence.Customer(); new_customer.name = current_customer.name; new_customer.address = current_customer.address; new_customer.zip_code = current_customer.zip_code; new_customer.phone_number = current_customer.phone_number; }
public static void CustomerMapper(Persistence.Customer current_customer, out DTO.Customer new_customer) { new_customer = new DTO.Customer(); new_customer.name = current_customer.name; new_customer.address = current_customer.address; new_customer.zip_code = current_customer.zip_code; new_customer.phone_number = current_customer.phone_number; new_customer.customer_id = current_customer.customer_id; new_customer.amount_owing = current_customer.amount_owing; }
/// <summary> /// Querying by all fields with 'AND' operator /// </summary> /// <param name="costumer"></param> /// <returns></returns> public List <DTO.Customer> QueryByAllFieldsUsingAnd(DTO.Customer costumer) { IQueryContainer query = CreateSimpleQueryUsingAnd(costumer); var hits = _EsClientDAL.Current .Search <DTO.Customer>(s => s.Query(query)) .Hits; List <DTO.Customer> typedList = hits.Select(hit => ConvertHitToCustumer(hit)).ToList(); return(typedList); }
public static void AddCustomer(DTO.Customer customer) { try { Persistence.CustomersRespository.AddCustomer(customer); } catch (Exception) { // Log it throw; } }
/// <summary> /// Create Entity for searching /// </summary> /// <returns></returns> private DTO.Customer CreateEntityForSearching() { //TODO: Validation DTO.Customer entity = new DTO.Customer(); entity.Age = int.Parse(nudQryAge.Value.ToString()); entity.Birthday = dtpQryBirthday.Value.ToString(DTO.Constants.BASIC_DATE); entity.EnrollmentFee = double.Parse(mskQryEnrol.Text); entity.HasChildren = bool.Parse(cboQryChildren.Text); entity.Name = txtQryName.Text; entity.Id = int.Parse(mskQryId.Text); return(entity); }
private DTO.Customer createCustomer() { var customer = new DTO.Customer() { customerID = Guid.NewGuid(), Name = nameTextBox.Text, PostalCode = postalTextBox.Text, Phone = phoneTextBox.Text, Address = addressTextBox.Text, }; return(customer); }
/// <summary> /// Running query /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnQrt3_Click(object sender, EventArgs e) { try { DTO.Customer entity = CreateEntityForSearching(); FillListView(_customerBll.QueryByAllFieldsUsingOr(entity), lvwHits); } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } }
public static List <DTO.Customer> GetCustomerList() { PapaBobEntities db = new PapaBobEntities(); var dbCustomers = db.Customers.ToList(); List <DTO.Customer> dto_customers_list = new List <DTO.Customer>(); foreach (var customer in dbCustomers) { DTO.Customer new_customer = new DTO.Customer(); CustomerMapper(customer, out new_customer); dto_customers_list.Add(new_customer); } return(dto_customers_list); }
/// <summary> /// Inserting or Updating a doc /// </summary> /// <param name="customer"></param> public bool Index(DTO.Customer customer) { //TODO: Validation var response = _EsClientDAL.Current.Index(customer, c => c.Type(DTO.Constants.DEFAULT_INDEX_TYPE)); if (response.Created == false && response.ServerError != null) { throw new Exception(response.ServerError.Error); } else { return(true); } }
//Add information to the database public void AddCustomer(DTO.Customer newCustomer) { var customer = new Customer() { customerID = newCustomer.customerID, Name = newCustomer.Name, Address = newCustomer.Address, PostalCode = newCustomer.PostalCode, Phone = newCustomer.Phone }; var dbCustomer = db.Customer; dbCustomer.Add(customer); db.SaveChanges(); }
private static void OrderMapper(Persistence.Order current_order, out DTO.Order new_order) { new_order = new DTO.Order(); new_order.completed = false; new_order.cost = current_order.cost; new_order.size = (DTO.Size)current_order.size; new_order.crust = (DTO.Crust)current_order.crust; new_order.payment_type = (DTO.Payment)current_order.payment_type; new_order.onions = current_order.onions; new_order.green_peppers = current_order.green_peppers; new_order.sausage = current_order.sausage; new_order.pepperoni = current_order.pepperoni; new_order.customer_id = current_order.customer_id; new_order.order_id = current_order.order_id; DTO.Customer customer = new DTO.Customer(); CustomerRepository.CustomerMapper(current_order.Customer, out customer); new_order.Customer = customer; }
//Get information from the database and sends it to the domain level. public List <DTO.Customer> GetCustomers() { var customers = db.Customer; var dtoCustomers = new List <DTO.Customer>(); foreach (var customer in customers) { var dtoCustomer = new DTO.Customer() { customerID = customer.customerID, Name = customer.Name, Address = customer.Address, Phone = customer.Phone, PostalCode = customer.PostalCode }; dtoCustomers.Add(dtoCustomer); } return(dtoCustomers); }
/// <summary> /// Create a query using all fields with 'AND' operator /// </summary> /// <param name="customer"></param> /// <returns></returns> private IQueryContainer CreateSimpleQueryUsingOr(DTO.Customer customer) { QueryContainer queryContainer = null; queryContainer |= new TermQuery() { Field = "_id", Value = customer.Id }; queryContainer |= new TermQuery() { Field = "name", Value = customer.Name }; queryContainer |= new TermQuery() { Field = "age", Value = customer.Age }; queryContainer |= new TermQuery() { Field = "birthday", Value = customer.Birthday }; queryContainer |= new TermQuery() { Field = "hasChildren", Value = customer.HasChildren }; queryContainer |= new TermQuery() { Field = "enrollmentFee", Value = customer.EnrollmentFee }; return(queryContainer); }
public static Models.Customer ToModel(this DTO.Customer DTOObject) { return(DTOObject.ParseObject <DTO.Customer, Models.Customer>()); }
//recieve order and customer object from presentation and pass onto persistence public static void AddOrder(DTO.Order current_order, DTO.Customer current_customer) { Persistence.OrderRepository.AddOrder(current_order, current_customer); }
public static void AddCustomer(DTO.Customer customer) { Persistence.CustomersRepository.AddCustomer(customer); }
public static bool CustomerExists(List <Persistence.Customer> dbCustomersList, DTO.Customer current_customer) { var count = dbCustomersList?.Where(p => p.phone_number == current_customer.phone_number).Count(); if (count > 0) { return(true); } else { return(false); } }
//Add information to the persistence layer. public void AddCustomer(DTO.Customer customer) { pizzaRepository.AddCustomer(customer); }