public IActionResult CreateNewCustomer(CustomerVM newCustomer)
        {
            if (!ModelState.IsValid)
            {
                return(View());
            }

            service.CreateCustomer(newCustomer);
            return(RedirectToAction(nameof(CustomersPage)));
        }
Ejemplo n.º 2
0
        protected async Task Save()
        {
            if (CurrentCustomer.Id <= 0)
            {
                await CustomersService.CreateCustomer(CurrentCustomer);
            }
            else
            {
                await CustomersService.UpdateCustomer(CurrentCustomer);
            }

            Cancel();
        }
        public IActionResult CreateCustomer([FromBody] CustomerCreateModel customerCreateModel)
        {
            try
            {
                var createdCustomer = CustomersService.CreateCustomer(customerCreateModel);

                return(CreatedAtAction("GetCustomerById", new { Id = createdCustomer.Id }, createdCustomer));
            }
            catch (Exception e)
            {
                Logger.LogCritical(e, "Error while creating new Customer");
                return(StatusCode(500));
            }
        }