예제 #1
0
        public async Task <IActionResult> Create(RegisterNewCustomer customerViewModel)
        {
            if (!ModelState.IsValid)
            {
                return(View(customerViewModel));
            }
            await _mediator.Send(customerViewModel);

            if (IsValidOperation())
            {
                ViewBag.Sucesso = "Customer Registered!";
            }

            return(RedirectToAction("Index"));
        }
예제 #2
0
        public ActionResult Create(RegisterNewCustomer command, FormCollection collection)
        {
            try
            {
                command.CustomerId = Guid.NewGuid();
                _serviceBus.Send(command);

                return(RedirectToAction("Index"));
            }
            catch (Exception ex)
            {
                ModelState.AddModelError("Exception", ex.Message);
                return(View());
            }
        }
예제 #3
0
        public async Task <IActionResult> Post([FromBody] RegisterNewCustomer registerNewCustomer)
        {
            await _mediator.Send(new CreateCustomerCommand(new Customer(registerNewCustomer.Name)));

            return(Ok());
        }
예제 #4
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();
     }
 }