private void deleteCustomer(string obj) { Customers.Remove(this.selectedCustomer); CustomersCollection.Remove(this.selectedCustomer); PropertyChanged(Customers, new PropertyChangedEventArgs("Customers")); saveFile(Customers); }
public async Task <Customer> GetCustomerIfPasswordVerified(string name, string pass) { try { var v = await CustomersCollection.Find(x => x.Name == name).FirstAsync(); Customer customer; if (v is Customer) { customer = v as Customer; if (customer.Password == pass) { return(customer); } } else { System.Diagnostics.Debug.WriteLine("error, returned not customer in GetCustomer in MongoService"); } } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.Message); } return(null); }
static void Main() { CustomersCollection customersCollection = new CustomersCollection(); //FindAll //List<Customer> matchingCustomers = customersCollection.FindAll(temp => temp.CustomerName.StartsWith("S")); //Sort customersCollection.Sort(); foreach (Customer cst in customersCollection) { Console.WriteLine(cst.CustomerID + ", " + cst.CustomerName + ", " + cst.Age + ", " + cst.CustomerType); } //MoveNext //Contains - IEquatable Customer customerToSearch = new Customer() { CustomerID = 102, CustomerName = "Scott1" }; //Console.WriteLine(customersCollection.Contains(customerToSearch)); //Output: True Console.ReadKey(); }
public CustomersCollection Customers_LoadAll() { CustomersCollection coll = new CustomersCollection(); coll.es.IsLazyLoadDisabled = true; coll.LoadAll(); return(coll); }
public CustomersCollection Customers_LoadByDynamic(string serializedQuery) { CustomersQuery query = CustomersQuery.SerializeHelper.FromXml( serializedQuery, typeof(CustomersQuery), AllKnownTypes) as CustomersQuery; CustomersCollection coll = new CustomersCollection(); coll.es.IsLazyLoadDisabled = true; coll.Load(query); return(coll); }
public CustomersCollectionProxyStub Customers_SaveCollection(CustomersCollectionProxyStub collection) { if (collection != null) { CustomersCollection c = collection.GetCollection(); c.Save(); return(c); } return(null); }
public CustomersCollection.CustomersCollectionWCFPacket Customers_LoadAll() { CustomersCollection coll = new CustomersCollection(); if (coll.LoadAll()) { return(coll); } return(null); }
public CustomersCollectionProxyStub Customers_LoadAll() { CustomersCollection coll = new CustomersCollection(); if (coll.LoadAll()) { return(coll); } return(null); }
public CustomersCollectionProxyStub Customers_QueryForCollection(string serializedQuery) { CustomersQuery query = CustomersQuery.SerializeHelper.FromXml( serializedQuery, typeof(CustomersQuery), AllKnownTypes) as CustomersQuery; CustomersCollection coll = new CustomersCollection(); if (coll.Load(query)) { return(coll); } return(null); }
private void saveCustomer(string obj) { Customer customer = new Customer() { FirstName = firstName, LastName = lastName, Contact = new Contact() { Mail = mail, Adress = adress } }; Customers.Add(customer); CustomersCollection.Add(customer); Debug.WriteLine(Customers); PropertyChanged(Customers, new PropertyChangedEventArgs("Customers")); saveFile(Customers); }
public static CustomersCollection GetAllCustomers() { CustomersCollection ac = new CustomersCollection(); using (SqlConnection conn = new SqlConnection(PhoneSQL.csPhone)) { SqlCommand cmd = new SqlCommand(PhoneSQL.cGetAllPhones, conn); cmd.CommandType = CommandType.StoredProcedure; conn.Open(); SqlDataReader reader = cmd.ExecuteReader(); FillPhoneList(ac, reader); reader.Close(); conn.Close(); return(ac); } }
private void editCustomer(string obj) { Customer customer = selectedCustomer; Customers.Remove(selectedCustomer); CustomersCollection.Remove(selectedCustomer); customer.FirstName = firstName; customer.LastName = lastName; customer.Contact.Mail = mail; customer.Contact.Adress = adress; Customers.Add(customer); CustomersCollection.Add(customer); PropertyChanged(Customers, new PropertyChangedEventArgs("Customers")); saveFile(Customers); }
public async Task <List <Customer> > GetAllCustomers() { try { var allCustomers = await CustomersCollection .Find(new BsonDocument()) .ToListAsync(); return(allCustomers); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.Message); } return(null); }
public static Customer[] GetCustomersFromXml() { try { CustomersCollection customersCollection = null; XmlSerializer serializer = new XmlSerializer(typeof(CustomersCollection)); StreamReader reader = new StreamReader(xmlFilePath); customersCollection = (CustomersCollection)serializer.Deserialize(reader); reader.Close(); return(customersCollection.CustomerArray); } catch (Exception ex) { //Log exception if needed. return(null); } }
public static void FillCustomerList(CustomersCollection coll, SqlDataReader reader, int totalRows, int firstRow) { int index = 0; bool readMore = true; while (reader.Read()) { if (index >= firstRow && readMore) { if (coll.Count >= totalRows && totalRows > 0) { readMore = false; } else { Customer trx = Customer.GetCustomer(reader); coll.Add(trx); } } index++; } }
public void Check_AddCustomer_AddsCustomerToDatabase() { var options = new DbContextOptionsBuilder <Store_DbContext>() .UseInMemoryDatabase(databaseName: "CustomerDatabase") .Options; CustomersCollection customersCollection = new CustomersCollection(); Customer newCustomer = new Customer(); newCustomer.FirstName = "FirstName"; newCustomer.LastName = "LastName"; int customerRecordCount; using (var context = new Store_DbContext(options)) { customersCollection.db = context; customersCollection.AddToDatabase(newCustomer); customerRecordCount = context.Customers.Count(); } Assert.Equal(1, customerRecordCount); }
public async Task EditCustomer(Customer customer) { await CustomersCollection.ReplaceOneAsync(t => t.Id.Equals(customer.Id), customer); }
private void AddCustomer(Customer customer) { CustomersCollection.Add((Customer)customer.Clone()); Customer = new Customer(); }
public static void FillCustomerList(CustomersCollection coll, SqlDataReader reader) { FillCustomerList(coll, reader, -1, 0); }
public async Task CreateCustomer(Customer customer) { await CustomersCollection.InsertOneAsync(customer); }