예제 #1
0
        public async Task <IActionResult> List()
        {
            try
            {
                var customers = await _customerService.Read();

                return(Json(CustomerViewModel.FromCustomer(customers)));
            }
            catch (ApplicationException a)
            {
                return(BadRequest(a.Message));
            }
            catch (Exception e)
            {
                return(BadRequest(e.Message));
            }
        }
예제 #2
0
        // GET: Customers/Read/5
        public async Task <IActionResult> Read(int?id)
        {
            if (id == null)
            {
                BadRequest("Cliente não encontrado");
            }

            try
            {
                var customer = await _customerService.Read(id);

                return(Json(CustomerViewModel.FromCustomer(customer)));
            }
            catch (ApplicationException a)
            {
                return(BadRequest(a.Message));
            }
            catch (Exception e)
            {
                return(BadRequest(e.Message));
            }
        }