public RentVehicleCommand(RegularViewModel viewModel, NetTcpBinding binding, EndpointAddress address, string endDate, RegularView view)
 {
     this.viewModel = viewModel;
     this.binding   = binding;
     this.address   = address;
     this.endDate   = endDate;
     this.view      = view;
 }
Beispiel #2
0
        public RegularViewModel(RegularView viewParam, NetTcpBinding binding, EndpointAddress address, string endDate)
        {
            this.RentVehicleCommand = new RentVehicleCommand(this, binding, address, endDate, viewParam);

            WCFClient client = new WCFClient(binding, address, ConnectionUser.Instance().CurrentUser.Username);

            List = client.ReturnVehicle(1);
        }
Beispiel #3
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            if (usernameTextBox.Text == "" || passwordBox.Password == "")
            {
                MessageBox.Show("None field can be empty!");
                return;
            }

            User user = null;

            client = new WCFClient(binding, address, usernameTextBox.Text);

            UserRole result = client.LogIn(usernameTextBox.Text, passwordBox.Password, out user);

            if (result == UserRole.unauthenticated)
            {
                MessageBox.Show(String.Format("User with username: {0}, does not exits or username/password combination is not right", usernameTextBox.Text));
                Audit.AnnotateEvent(String.Format("Error while login with username {0} and password {1}", usernameTextBox.Text, passwordBox.Password));
            }
            else
            {
                ConnectionUser.Instance().CurrentUser = user;
            }

            if (ConnectionUser.Instance().CurrentUser != null)
            {
                if (result == UserRole.admin)
                {
                    AdminView viewNew = new AdminView();
                    this.Close();
                    viewNew.ShowDialog();
                }
                else if (result == UserRole.korisnik)
                {
                    RegularView viewNew = new RegularView();
                    this.Close();
                    viewNew.ShowDialog();
                }
                else
                {
                    return;
                }
            }
        }