public void TestDeleteEmployees() { onSetUp(); var employeeBuilder = new EmployeeBuilder().setName(NAME); employeeRepository.AddEmployees(new List <Employee>() { employeeBuilder.CreateEmployee() }); var removeEmployeeRequest = new RemoveEmployeeRequest() { Name = NAME }; employeeController.Delete(removeEmployeeRequest); try { employeeController.Get(NAME); Assert.Fail("Expected exception to be thrown."); } catch (NoSuchEntityException e) { Assert.IsTrue(e.Message.Contains(NAME)); } }
public void Delete([FromBody] RemoveEmployeeRequest requestModel) { string name = requestModel.Name; int personalID = requestModel.PersonalID; if (name == null && personalID == 0) { throw new MalformedRequestException("Unable to parse name or personal ID from request parameters"); } if (name == null) { try { employeeRepository.RemoveEmployee(personalID); } catch (NoSuchEntityException) { throw new NoSuchEntityException("No employee exists with ID: " + personalID); } } else { try { employeeRepository.RemoveEmployee(name); } catch (NoSuchEntityException) { throw new NoSuchEntityException("No employee exists with name: " + name); } } }
public void TestDeleteEmployeeByID() { onSetUp(); // Create an employee var employeeBuilder = new EmployeeBuilder().setName(NAME); var addEmployeesRequest = employeeBuilder.CreateAddEmployeesRequest(); // Add them to the database employeeController.Post(addEmployeesRequest); //Get them from the database and find their ID var databaseEmployee = employeeController.Get(NAME); var ID = databaseEmployee.Employees.Last().PersonalId; var removeEmployeeRequest = new RemoveEmployeeRequest() { PersonalID = ID }; employeeController.Delete(removeEmployeeRequest); try { employeeController.GetEmployeeByID(ID); Assert.IsTrue(false); //Means that it found the employee so fail the test } catch { Assert.IsTrue(true); } }
public JsonResult Delete(System.Int32 id) { RemoveEmployeeRequest request = new RemoveEmployeeRequest(); request.EmployeeID = id; RemoveEmployeeResponse response = _employeeService.RemoveEmployee(request); return(Json(response)); }
/// <summary> /// Remove /// </summary> /// <param name="request"></param> /// <param name="context"></param> /// <returns></returns> public override async Task <RemoveEmployeeReply> Remove(RemoveEmployeeRequest request, ServerCallContext context) { CheckRequestInvalid(request); var result = new RemoveEmployeeReply(); result.IsSuccess = _EmployeeBO.DeleteEntiy(new EmployeeDto { EmployeeID = request.EmployeeID }); return(await Task.FromResult(result)); }
public RemoveEmployeeResponse RemoveEmployee(RemoveEmployeeRequest request) { RemoveEmployeeResponse response = new RemoveEmployeeResponse(); response.Errors = new List <BusinessRule>(); try { if (_employeeRepository.Remove(request.EmployeeID) > 0) { response.EmployeeDeleted = true; } } catch (Exception ex) { response.Errors.Add(new BusinessRule("DAL", "DAL_ERROR: " + ex.Message)); } return(response); }
public void TestDeleteNonexistentEmployee() { OnSetUp(); var removeEmployeeRequest = new RemoveEmployeeRequest { Name = Name }; try { _employeeController.Delete(removeEmployeeRequest); Assert.Fail("Expected exception to be thrown."); } catch (NoSuchEntityException e) { Assert.IsTrue(e.Message.Contains(Name)); } }
public void Delete([FromBody] RemoveEmployeeRequest requestModel) { string name = requestModel.Name; if (name == null) { throw new MalformedRequestException("Unable to parse name from request parameters"); } try { employeeRepository.RemoveEmployee(name); } catch (NoSuchEntityException) { throw new NoSuchEntityException("No employee exists with name: " + name); } }
public void Delete([FromBody] RemoveEmployeeRequest requestModel) { int Id = requestModel.EmployeeId; if (Id == 0) { throw new MalformedRequestException("Unable to parse id from request parameters"); } try { _employeeRepository.RemoveEmployee(Id); } catch (NoSuchEntityException) { throw new NoSuchEntityException("No employee exists with Id: " + Id); } }
public async Task <ActionResult> RemoveEmployee(Guid serviceRequestId, [FromBody] RemoveEmployeeRequest dto) { await _serviceRequestService.RemoveEmployee(serviceRequestId, dto); return(NoContent()); }