/// <summary> /// 删除客户分类 /// </summary> /// <param name="request"></param> /// <param name="cancellationToken"></param> /// <returns></returns> public async Task <bool> Handle(DeleteCustomerTypeCommand request, CancellationToken cancellationToken) { var entity = await _customerTypeRepository.GetAsync(request.Id); entity.VerifyUsed(); await _customerTypeRepository.UnitOfWork.SaveEntitiesAsync(); return(await _customerTypeRepository.DeleteAsync(request.Id)); }
public async Task <IActionResult> Delete(long id) { var customerType = await _customerTypeRepo.GetAsync(id); if (customerType == null) { return(NotFound(Resources.Customers.CustomerResource.CustomerTypeNotFound)); } var affectedRows = await _customerTypeRepo.DeleteAsync(customerType); if (affectedRows == -1) { return(BadRequest(Resources.Customers.CustomerResource.CanNotDeleteCustomerType)); } if (affectedRows > 0) { var viewModel = AutoMapper.Mapper.Map <CustomerTypeViewModel>(customerType); return(Ok(viewModel)); } return(BadRequest()); }