public async Task <CustomerServiceEmployeeResponse> SaveAsync(CustomerServiceEmployee customerServiceEmployee) { try { await _customerServiceEmployeeRepository.AddAsync(customerServiceEmployee); await _unitOfWork.CompleteAsync(); return(new CustomerServiceEmployeeResponse(customerServiceEmployee)); } catch (Exception e) { return(new CustomerServiceEmployeeResponse($"An error ocurred while saving the Employee: {e.Message}")); } }
public async Task <CustomerServiceEmployeeResponse> UpdateAsync(int id, CustomerServiceEmployee customerServiceEmployee) { var existingEmployee = await _customerServiceEmployeeRepository.FindById(id); if (existingEmployee == null) { return(new CustomerServiceEmployeeResponse("Employee not found")); } existingEmployee.Name = customerServiceEmployee.Name; try { _customerServiceEmployeeRepository.Update(existingEmployee); await _unitOfWork.CompleteAsync(); return(new CustomerServiceEmployeeResponse(existingEmployee)); } catch (Exception e) { return(new CustomerServiceEmployeeResponse($"An error ocurred while updating the Employee: {e.Message}")); } }
public void Update(CustomerServiceEmployee customerServiceEmployee) { _context.CustomerServiceEmployees.Update(customerServiceEmployee); }
public void Remove(CustomerServiceEmployee customerServiceEmployee) { _context.CustomerServiceEmployees.Remove(customerServiceEmployee); }
public async Task AddAsync(CustomerServiceEmployee customerServiceEmployee) { await _context.CustomerServiceEmployees.AddAsync(customerServiceEmployee); }