Exemple #1
0
            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));
            }
Exemple #2
0
        public async Task <JsonResult> OnPostDeleteAsync(int id)
        {
            var customer = await _customer.GetByIdAsync(id);

            await _customer.DeleteAsync(customer);

            await _unitOfWork.Commit();

            Customers = await _customer.GetAllAsync();

            var html = await _renderService.ToStringAsync("_ViewAll", Customers);

            return(new JsonResult(new { isValid = true, html = html }));
        }
Exemple #3
0
        public async Task <IActionResult> DeleteAsync(int id)
        {
            try
            {
                var status = await _customerRepository.DeleteAsync(id);

                if (!status)
                {
                    return(BadRequest());
                }
                return(Ok());
            }
            catch (Exception ex)
            {
                _logger.LogError(ex.Message);
                return(BadRequest());
            }
        }