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)); } }
// 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)); } }