Example #1
0
        public async Task <CustomerEntity> Add(CustomerEntity customerEntity)
        {
            var data = ReadDataFromFile();

            if (data != null && data.Customers != null && data.Customers.Any())
            {
                // check for duplicate customer
                if (data.Customers.Exists(c => c.Name.Equals(customerEntity.Name, System.StringComparison.OrdinalIgnoreCase)))
                {
                    throw new DuplicateCustomerException(Constants.CustomerAlreadyExists);
                }
                var maxId  = data.Customers.Max(c => c.Id);
                var nextId = maxId + 1;
                customerEntity.Id = nextId;
                data.Customers.Add(customerEntity);
                WriteDataToFile(data);
            }
            else
            {
                var customers = new ListCustomers();
                customerEntity.Id = 1;
                customers.Customers.Add(customerEntity);
                WriteDataToFile(customers);
            }

            return(await Task.FromResult(customerEntity));
        }
Example #2
0
        public void addCustomerToList(Customer c)
        {
            CustomerViewModel customer = new CustomerViewModel(c);

            customer.DelCustomer += deleteCustomer;
            ListCustomers.Add(customer);
        }
 public ListCustomersModel(BrowserViewModel BrowserWindow, SelectionMode SelectionMode)
 {
     view                = new ListCustomers(this);
     selectionMode       = SelectionMode;
     contextList         = AppCore.CurrentCustomerList;
     browserWindow       = BrowserWindow;
     browserWindow.width = 300;
 }
Example #4
0
 public void Remove(Customer customer)
 {
     if (this.CustomerHasProject(customer))
     {
         throw new Exception(string.Format("Cstomer {0}  {1} can't be Deleted, because has project",
                                           customer.Name, customer.Surname));
     }
     ListCustomers.Remove(customer);
 }
Example #5
0
        private void listCustomerToolStripMenuItem_Click(object sender, EventArgs e)
        {
            try
            {
                if (_ListCustomers.IsDisposed)
                {
                    _ListCustomers = new ListCustomers();
                }

                Home.Home_pnl.Visible      = false;
                _ListCustomers.MdiParent   = this;
                _ListCustomers.WindowState = FormWindowState.Maximized;
                _ListCustomers.Show();
                _ListCustomers.Focus();
            }
            catch (Exception ex)
            {
                notifyIcon1.ShowBalloonTip(1000, this.Name, ex.Message, ToolTipIcon.Info);;
            }
        }
Example #6
0
        public static List <Revenue> getCustomerReport()
        {
            BangazonConnection connection = _connection;

            connection.execute(@"SELECT
                                CustomerFirstName,
                                CustomerLastName,
                                SUM(ProductRevenue) AS 'GrossSales'
                                FROM Revenue
                                GROUP BY CustomerFirstName || CustomerLastName
                                ORDER BY GrossSales DESC",
                               (SqliteDataReader reader) => {
                while (reader.Read())
                {
                    ListCustomers.Add(new Revenue {
                        CustomerFirstName = reader[0].ToString(),
                        CustomerLastName  = reader[1].ToString(),
                        ProductRevenue    = reader.GetInt32(2)
                    });
                }
            });
            return(ListCustomers);
        }
Example #7
0
        private void WriteDataToFile(ListCustomers data)
        {
            var json = JsonConvert.SerializeObject(data);

            File.WriteAllText(dbFile, json);
        }
Example #8
0
 public int IndexOf(Customer customer)
 {
     return(ListCustomers.IndexOf(customer));
 }
Example #9
0
 public void Add(Customer customer)
 {
     ListCustomers.Add(customer);
 }
Example #10
0
 public object Get(ListCustomers request)
 {
     // You can then access the instance in the scope of the request
     // So you now have access to the current user identity
     Envers.Username = Session.Username;     // Just an example modify as required.
 }
Example #11
0
 private void Menu_KeyPress(object sender, KeyPressEventArgs e)
 {
     if (e.KeyChar == (char)Keys.Back)
     {
         this.Hide();
         Menu menu = new Menu();
         menu.ShowDialog();
         this.Close();
     }
     else if (e.KeyChar == (char)Keys.D1)
     {
         this.Hide();
         RegisterNewCar registerNewCar = new RegisterNewCar();
         registerNewCar.ShowDialog();
         this.Close();
     }
     else if (e.KeyChar == (char)Keys.D2)
     {
         this.Hide();
         UpdateCarRental updateCarRental = new UpdateCarRental();
         updateCarRental.ShowDialog();
         this.Close();
     }
     else if (e.KeyChar == (char)Keys.D3)
     {
         this.Hide();
         ListRents listRents = new ListRents();
         listRents.ShowDialog();
         this.Close();
     }
     else if (e.KeyChar == (char)Keys.D4)
     {
         this.Hide();
         AvailableCars availableCars = new AvailableCars();
         availableCars.ShowDialog();
         this.Close();
     }
     else if (e.KeyChar == (char)Keys.D5)
     {
         this.Hide();
         RegisterNewCustomer registerNewCustomer = new RegisterNewCustomer();
         registerNewCustomer.ShowDialog();
         this.Close();
     }
     else if (e.KeyChar == (char)Keys.D6)
     {
         this.Hide();
         UpdateCustomer updateCustomer = new UpdateCustomer();
         updateCustomer.ShowDialog();
         this.Close();
     }
     else if (e.KeyChar == (char)Keys.D7)
     {
         this.Hide();
         ListCustomers listCustomers = new ListCustomers();
         listCustomers.ShowDialog();
         this.Close();
     }
     else if (e.KeyChar == (char)Keys.D8)
     {
         this.Close();
     }
     else
     {
         MessageBox.Show("Please insert a valid number");
         this.Hide();
         Menu menu = new Menu();
         menu.ShowDialog();
         this.Close();
     }
 }