public void Delete(int id) { _vendorService.Delete(id); var unitOfWork = new UnitOfWork(_vendorRepository.SCMSContext); unitOfWork.Complete(); }
public async void Delete() { var mock = new ServiceMockFacade <IVendorRepository>(); var model = new ApiVendorRequestModel(); mock.RepositoryMock.Setup(x => x.Delete(It.IsAny <int>())).Returns(Task.CompletedTask); var service = new VendorService(mock.LoggerMock.Object, mock.RepositoryMock.Object, mock.ModelValidatorMockFactory.VendorModelValidatorMock.Object, mock.BOLMapperMockFactory.BOLVendorMapperMock, mock.DALMapperMockFactory.DALVendorMapperMock, mock.BOLMapperMockFactory.BOLProductVendorMapperMock, mock.DALMapperMockFactory.DALProductVendorMapperMock, mock.BOLMapperMockFactory.BOLPurchaseOrderHeaderMapperMock, mock.DALMapperMockFactory.DALPurchaseOrderHeaderMapperMock); ActionResponse response = await service.Delete(default(int)); response.Should().NotBeNull(); mock.RepositoryMock.Verify(x => x.Delete(It.IsAny <int>())); mock.ModelValidatorMockFactory.VendorModelValidatorMock.Verify(x => x.ValidateDeleteAsync(It.IsAny <int>())); }
public ActionResult Delete(int vendorId) { try { vendorService.Delete(vendorId); var responseModel = new ResponseModel { StatusCode = (int)HttpStatusCode.OK, MessageAr = AppResource.DeletedSuccessfully }; return(Json(responseModel, JsonRequestBehavior.AllowGet)); } catch (System.Exception) { var responseModel = new ResponseModel { StatusCode = (int)HttpStatusCode.OK, MessageAr = AppResource.DeleteErrorValidation }; return(Json(responseModel, JsonRequestBehavior.AllowGet)); } }