private void deleteCustomer(string obj)
 {
     Customers.Remove(this.selectedCustomer);
     CustomersCollection.Remove(this.selectedCustomer);
     PropertyChanged(Customers, new PropertyChangedEventArgs("Customers"));
     saveFile(Customers);
 }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
        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();
        }
Exemplo n.º 4
0
        public CustomersCollection Customers_LoadAll()
        {
            CustomersCollection coll = new CustomersCollection();

            coll.es.IsLazyLoadDisabled = true;
            coll.LoadAll();
            return(coll);
        }
Exemplo n.º 5
0
        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);
        }
Exemplo n.º 7
0
        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);
        }
Exemplo n.º 10
0
        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);
        }
Exemplo n.º 11
0
        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);
            }
        }
Exemplo n.º 12
0
        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);
        }
Exemplo n.º 13
0
        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);
        }
Exemplo n.º 14
0
 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);
     }
 }
Exemplo n.º 15
0
        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++;
            }
        }
Exemplo n.º 16
0
        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);
        }
Exemplo n.º 17
0
 public async Task EditCustomer(Customer customer)
 {
     await CustomersCollection.ReplaceOneAsync(t => t.Id.Equals(customer.Id), customer);
 }
Exemplo n.º 18
0
 private void AddCustomer(Customer customer)
 {
     CustomersCollection.Add((Customer)customer.Clone());
     Customer = new Customer();
 }
Exemplo n.º 19
0
 public static void FillCustomerList(CustomersCollection coll, SqlDataReader reader)
 {
     FillCustomerList(coll, reader, -1, 0);
 }
Exemplo n.º 20
0
 public async Task CreateCustomer(Customer customer)
 {
     await CustomersCollection.InsertOneAsync(customer);
 }