Ejemplo n.º 1
0
        public async Task <IActionResult> OnGetAsync(long?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            Customer = await customerRepository.GetById(id.Value);

            if (Customer == null)
            {
                return(NotFound());
            }
            return(Page());
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            try
            {
                var customer = new CrudCoreTest.Domain.CustomerAgg.Customer(Customer.FirstName, Customer.LastName,
                                                                            Customer.DateOfBirth.ToDateTime(), Customer.PhoneNumber, Customer.Email, Customer.BankAccountNumber);
                await customerRepository.Add(customer);
            }
            catch (Exception ex)
            {
                ModelState.AddModelError("Error", ex.InnerException != null ? ex.InnerException.Message : ex.Message);
                return(Page());
            }


            return(RedirectToPage("./Index"));
        }