Beispiel #1
0
        public void can_select_all_customers()
        {
            CustomerRepository <Custommer <int>, int> cr = new CustomerRepository <Custommer <int>, int>();
            Custommer <int> customer1 = new Custommer <int>();

            customer1.Id = 1;
            cr.Save(customer1);

            Custommer <int> customer2 = new Custommer <int>();

            customer2.Id = 2;
            cr.Save(customer2);

            Custommer <int> customer3 = new Custommer <int>();

            customer3.Id = 3;
            cr.Save(customer3);

            int count = 0;

            foreach (var item in cr.GetAll())
            {
                count++;
            }
            Assert.IsTrue(count == 3, "The respository does not return all customers");
        }
 public void Reset()
 {
     SelectedCustommer        = null;
     CustommerNameEntry.Text  = "";
     CustommerPhoneEntry.Text = "";
     BillItems.Clear();
     DiscountEntry.Text = "0";
 }
Beispiel #3
0
        public void can_add_customer()
        {
            CustomerRepository <Custommer <int>, int> cr = new CustomerRepository <Custommer <int>, int>();
            Custommer <int> customer1 = new Custommer <int>();

            customer1.Id = 1;
            cr.Save(customer1);

            Assert.IsTrue(cr.Get(1) == customer1, "Unable to save a customer");
        }
 private void CustommerCollectionView_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     if (CustommersCollectionView.SelectedItem != null)
     {
         SelectedCustommer        = e.CurrentSelection[0] as Custommer;
         CustommerNameEntry.Text  = SelectedCustommer.Name;
         CustommerPhoneEntry.Text = SelectedCustommer.PhoneNo;
     }
     CustommersCollectionView.SelectedItem = null;
 }
Beispiel #5
0
        public void can_select_customer_by_customer_id()
        {
            CustomerRepository <Custommer <int>, int> cr = new CustomerRepository <Custommer <int>, int>();
            Custommer <int> customer1 = new Custommer <int>();

            customer1.Id = 1;
            cr.Save(customer1);

            var customer = cr.Get(1);

            Assert.IsNotNull(customer, "Could not find customer by id");
        }
Beispiel #6
0
        public void can_delete_customer()
        {
            CustomerRepository <Custommer <int>, int> cr = new CustomerRepository <Custommer <int>, int>();
            Custommer <int> customer1 = new Custommer <int>();

            customer1.Id = 1;
            cr.Save(customer1);
            cr.Delete(customer1.Id);

            var customer = cr.Get(1);

            Assert.IsNull(customer, "Could not delete customer");
        }
 private void CustommerPhoneEntry_TextChanged(object sender, TextChangedEventArgs e)
 {
     SearchCustommers.Clear();
     for (int i = 0; i < Custommers.Count; i++)
     {
         if (Custommers[i].PhoneNo.Contains(e.NewTextValue))
         {
             SearchCustommers.Add(Custommers[i]);
         }
     }
     if (SearchCustommers.Count == 0)
     {
         SelectedCustommer = null;
     }
 }
        public IHttpActionResult getContatto(string cognome = "", string mail = "", string nome = "")
        {
            if (cognome == null)
            {
                return(Ok());
            }
            if (mail == null)
            {
                return(Ok());
            }
            if (nome == null)
            {
                return(Ok());
            }

            if ((cognome == null & mail == null & nome == null) | (cognome == "" & mail == "" & nome == ""))
            {
                return(Ok());
            }

            Custommer cust = FilmeServices.GetByCustomerProp().Where(prop => prop.cognome == cognome | prop.mail == mail | prop.nome == nome).FirstOrDefault();

            return(Json(cust));
        }
Beispiel #9
0
        public void test()
        {
            int senderid   = 123456789;
            int receiverid = 123456781;

            Custommer[] cust = new Custommer[]
            {
                new Custommer()
                {
                    ID   = 123456789,
                    Name = "John_Sender"
                },
                new Custommer()
                {
                    ID   = 123456781,
                    Name = "Bob_Receiver"
                }
            };
            Shipments[] shipments = new Shipments[]
            {
                new Shipments()
                {
                    ID            = 150,
                    SenderID      = 123456789,
                    ReceiverID    = 123456781,
                    ReceivingDate = new DateTime(2016, 09, 01),
                    DeliveryDate  = new DateTime(2016, 09, 02),
                    Status        = "Delivered"
                },
            };
            ShipmentDetail[] shipmentdetails = new ShipmentDetail[]
            {
                new ShipmentDetail()
                {
                    ShipmentID = 150,
                    Weight     = 25.00,
                    Volume     = 25.00,
                    Type       = "Whatever",
                    Cost       = 25.00,
                    Distance   = 25.00
                },
            };
            var q1 = from _shipment in shipments
                     join _shipmentdetail in shipmentdetails on _shipment.ID equals _shipmentdetail.ShipmentID
                     where _shipment.SenderID == senderid && _shipment.ReceiverID == receiverid
                     select new
            {
                ShipmentID   = _shipment.ID,
                Status       = _shipment.Status,
                SenderID     = _shipment.SenderID,
                SenderName   = cust.Where(s => s.ID == _shipment.SenderID).Select(s => s.Name).FirstOrDefault(),
                ReceiverID   = _shipment.ReceiverID,
                ReceiverName = cust.Where(s => s.ID == _shipment.ReceiverID).Select(s => s.Name).FirstOrDefault(),
            };
            var q2 = q1.First();

            Console.WriteLine
            (
                "Shipment Id  = " + q2.ShipmentID.ToString() + "\n" +
                "Status = " + q2.Status + "\n" +
                "Sender ID = " + q2.SenderID + "\n" +
                "SenderName = " + q2.SenderName + "\n" +
                "Receiver ID = " + q2.ReceiverID + "\n" +
                "Receiver Name = " + q2.ReceiverName
            );
        }
 public Custommer Create(Custommer item)
 {
     item.Id = list.Count + 1;
     list.Add(item);
     return(item);
 }
        private void CreateBillButton_Clicked(object sender, EventArgs e)
        {
            if (CustommerNameEntry.Text != "" && CustommerPhoneEntry.Text != "" && BillItems.Count > 0)
            {
                if (SelectedCustommer == null)
                {
                    Custommer custommer = new Custommer()
                    {
                        Name    = CustommerNameEntry.Text,
                        PhoneNo = CustommerPhoneEntry.Text
                    };
                    SelectedCustommer = custommer;
                    bool cont = false;

                    if (SearchCustommers.Count > 0)
                    {
                        for (int i = 0; i < SearchCustommers.Count; i++)
                        {
                            if (SearchCustommers[i].Name == custommer.Name && SearchCustommers[i].PhoneNo == custommer.PhoneNo)
                            {
                                cont = true;
                                break;
                            }
                        }
                    }

                    if (!cont)
                    {
                        Custommers.Add(custommer);
                        string cdata = JsonConvert.SerializeObject(Custommers);
                        App.Current.Properties["Custommers"] = cdata;
                        try
                        {
                            string FilePath = Path.Combine(FileSystem.AppDataDirectory, "Custommers.json");
                            File.WriteAllText(FilePath, cdata);
                        }
                        catch (Exception n)
                        {
                        }
                    }
                }
                ObservableCollection <Product> items = new ObservableCollection <Product>()
                {
                };
                for (int i = 0; i < BillItems.Count; i++)
                {
                    items.Add(BillItems[i]);
                }

                SingleSale sale = new SingleSale()
                {
                    Customer    = SelectedCustommer,
                    ItesmsSold  = items,
                    date        = DateTime.Now,
                    Discount    = DiscountEntry.Text,
                    TotalAmount = Total
                };
                SaleData.Insert(0, sale);
                CreateBillfile(sale);
                string salesdata = JsonConvert.SerializeObject(SaleData);
                App.Current.Properties["Sales"] = salesdata;
                try
                {
                    string FilePath2 = Path.Combine(FileSystem.AppDataDirectory, "Sales.json");
                    File.WriteAllText(FilePath2, salesdata);
                }
                catch (Exception t)
                {
                }
                string data = JsonConvert.SerializeObject(products);
                App.Current.Properties["Products"] = data;
                try
                {
                    string FilePath = Path.Combine(FileSystem.AppDataDirectory, "ProductsData.json");
                    File.WriteAllText(FilePath, data);
                }
                catch (Exception h)
                {
                }
                SelectedCustommer = null;

                UpdateCustommerData();
                Reset();
            }
            else
            {
                DisplayAlert("Enter Custommer Data", "Please enter custommer name and phone number", "Ok");
            }
        }