public RedirectToRouteResult DeleteEmployee(string id = null, string forename = null, string surname = null, string dob = null, string role = null, string room = null) { int count = 0; if (!id.IsNullOrWhiteSpace()) { model.SearchById(id); count++; } if (!forename.IsNullOrWhiteSpace()) { model.SearchByFirstName(forename); count++; } if (!surname.IsNullOrWhiteSpace()) { model.SearchBySurname(surname); count++; } if (!dob.IsNullOrWhiteSpace()) { model.SearchByDob(dob); count++; } if (!role.IsNullOrWhiteSpace()) { model.SearchByRole(role); count++; } if (!room.IsNullOrWhiteSpace()) { model.SearchByRoom(room); count++; } if (count > 0) { model.DeleteEmployee(); } return(RedirectToAction("Index")); }
public void DeleteEmployee_CallsEmployeeHandler() { //Arrange var employee = new Employee { Id = "1" }; var employeeHandlerMock = new Mock <IEmployeeHandler>(); employeeHandlerMock.Setup(m => m.DeleteEmployee(employee.Id)).Returns(Task.FromResult("Delete successful")); var viewModel = new EmployeeViewModel(employeeHandlerMock.Object, null); viewModel.SelectedEmployee = employee; //Act viewModel.DeleteEmployee(); //Assert employeeHandlerMock.Verify(m => m.DeleteEmployee(employee.Id), Times.Once); Assert.That(viewModel.Status, Is.EqualTo("Delete successful")); }
private async void lstData_ItemSelected(object sender, SelectedItemChangedEventArgs e) { if (e.SelectedItem != null) { EmployeeModel obj = (EmployeeModel)e.SelectedItem; string res = await DisplayActionSheet("Operation", "Cancel", null, "Update", "Delete"); switch (res) { case "Update": await this.Navigation.PushAsync(new AddEmployee(obj)); break; case "Delete": viewModel.DeleteEmployee(obj); showEmployee(); break; } lstData.SelectedItem = null; } }