public async void Delete() { var mock = new ServiceMockFacade <IShiftRepository>(); var model = new ApiShiftRequestModel(); mock.RepositoryMock.Setup(x => x.Delete(It.IsAny <int>())).Returns(Task.CompletedTask); var service = new ShiftService(mock.LoggerMock.Object, mock.RepositoryMock.Object, mock.ModelValidatorMockFactory.ShiftModelValidatorMock.Object, mock.BOLMapperMockFactory.BOLShiftMapperMock, mock.DALMapperMockFactory.DALShiftMapperMock, mock.BOLMapperMockFactory.BOLEmployeeDepartmentHistoryMapperMock, mock.DALMapperMockFactory.DALEmployeeDepartmentHistoryMapperMock); ActionResponse response = await service.Delete(default(int)); response.Should().NotBeNull(); mock.RepositoryMock.Verify(x => x.Delete(It.IsAny <int>())); mock.ModelValidatorMockFactory.ShiftModelValidatorMock.Verify(x => x.ValidateDeleteAsync(It.IsAny <int>())); }
public ActionResult Delete(int id) { IShiftService service = new ShiftService(); try { if (id < 0) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } var Shift = service.Getbykey(id); if (Shift == null) { return(HttpNotFound()); } service.Delete(Shift.ID); return(RedirectToAction("ShiftIndex")); } catch (Exception ex) { return(View("Error")); } }