public async Task <JsonResult> OnGetCreateOrEditAsync(int id = 0) { if (id == 0) { return(new JsonResult(new { isValid = true, html = await _renderService.ToStringAsync("_CreateOrEdit", new Customer()) })); } else { var thisCustomer = await _customer.GetByIdAsync(id); return(new JsonResult(new { isValid = true, html = await _renderService.ToStringAsync("_CreateOrEdit", thisCustomer) })); } }
public async Task <Response <CustomerInfo> > Handle(GetCustomerByIdQuery query, CancellationToken cancellationToken) { var customerInfo = await _customerRepository.GetByIdAsync(query.Id); if (customerInfo == null) { throw new ApiException($"Customer Detail Not Found."); } return(new Response <CustomerInfo>(customerInfo)); }
public async Task <Response <int> > Handle(DeleteCustomerByIdCommand command, CancellationToken cancellationToken) { var customerInfo = await _customerRepository.GetByIdAsync(command.Id); if (customerInfo == null) { throw new ApiException($"Customer Detail Not Found."); } await _customerRepository.DeleteAsync(customerInfo); return(new Response <int>(customerInfo.Id)); }