public async Task <IActionResult> Delete(string id) { var salesemployee = await _salesEmployeeService.GetSalesEmployeeById(id); if (salesemployee == null) { throw new ArgumentException("No sales employee found with the specified id"); } var customers = await _customerService.GetAllCustomers(salesEmployeeId : id); if (customers.Any()) { return(Json(new DataSourceResult { Errors = "Sales employee is related with customers" })); } var orders = await _orderService.SearchOrders(salesEmployeeId : id); if (orders.Any()) { return(Json(new DataSourceResult { Errors = "Sales employee is related with orders" })); } await _salesEmployeeService.DeleteSalesEmployee(salesemployee); //activity log await _customerActivityService.InsertActivity("DeleteSalesEmployee", salesemployee.Id, _localizationService.GetResource("ActivityLog.DeleteSalesEmployee"), salesemployee.Name); return(new NullJsonResult()); }
public async Task <IActionResult> Delete(string id) { var salesemployee = await _salesEmployeeService.GetSalesEmployeeById(id); if (salesemployee == null) { throw new ArgumentException("No sales employee found with the specified id"); } await _salesEmployeeService.DeleteSalesEmployee(salesemployee); return(new NullJsonResult()); }