public void Given_that_request_is_valid_When_mark_hazard_as_deleted_Then_should_call_correct_methods()
        {
            //Given
            var target = CreateNonEmployeeervice();

            var hazard = new Mock<Hazard>();
            hazard.Setup(x => x.MarkForDelete(_user.Object));

           

            var request = new MarkCompanyDefaultAsDeletedRequest(1, 2, Guid.NewGuid());

            _userRepository
              .Setup(x => x.GetByIdAndCompanyId(request.UserId, request.CompanyId))
              .Returns(_user.Object);

            _repo
                .Setup(x => x.GetByIdAndCompanyId(request.CompanyDefaultId, request.CompanyId))
                .Returns(hazard.Object);


            //When
            target.MarkHazardAsDeleted(request);

            //Then
            hazard.VerifyAll();
            _repo.Verify(x => x.SaveOrUpdate(It.IsAny<Hazard>()));
        }
        public void Given_that_request_is_valid_When_mark_person_at_risk_as_deleted_Then_should_call_correct_methods()
        {
            //Given
            var request = new MarkCompanyDefaultAsDeletedRequest(1, 2, Guid.NewGuid());

            var target = CreateNonEmployeeervice();

            var user = new UserForAuditing();
            _userRepository
                .Setup(x => x.GetByIdAndCompanyId(request.UserId, request.CompanyId))
                .Returns(user);

            var person = new Mock<PeopleAtRisk>();
            person.Setup(x => x.MarkForDelete(user));
            
            _repo
                .Setup(x => x.GetByIdAndCompanyId(request.CompanyDefaultId, request.CompanyId))
                .Returns(person.Object);

            //When
            target.MarkPersonAtRiskAsDeleted(request);

            //Then
            person.VerifyAll();
            _repo.Verify(x => x.SaveOrUpdate(It.IsAny<PeopleAtRisk>()));
        }
Пример #3
0
        public void MarkSupplierAsDeleted(MarkCompanyDefaultAsDeletedRequest request)
        {
            if(_hazardousSubstancesRepository.DoesHazardousSubstancesExistForSupplier(request.CompanyDefaultId, request.CompanyId))
            {
                throw new TryingToDeleteSupplierThatUsedByHazardousSubstanceException(request.CompanyDefaultId);
            }

            var user = _userForAuditingRepository.GetByIdAndCompanyId(request.UserId, request.CompanyId);
            var supplier = _supplierRepository.GetByIdAndCompanyId(request.CompanyDefaultId, request.CompanyId);

            supplier.MarkForDelete(user);
            _supplierRepository.SaveOrUpdate(supplier);
        }
        public void MarkPersonAtRiskAsDeleted(MarkCompanyDefaultAsDeletedRequest request)
        {
            _log.Add(request);

            try
            {
                var user = _userForAuditingRepository.GetByIdAndCompanyId(request.UserId, request.CompanyId);
                var personAtRisk = _peopleAtRiskRepository.GetByIdAndCompanyId(request.CompanyDefaultId, request.CompanyId);

                personAtRisk.MarkForDelete(user);
                _peopleAtRiskRepository.SaveOrUpdate(personAtRisk);
            }
            catch (Exception ex)
            {
                _log.Add(ex);
                throw;
            }


        }
        public void MarkHazardAsDeleted(MarkCompanyDefaultAsDeletedRequest request)
        {
            _log.Add(request);

            try
            {
                var user = _userForAuditingRepository.GetByIdAndCompanyId(request.UserId, request.CompanyId);
                var hazard = _hazardRepository.GetByIdAndCompanyId(request.CompanyDefaultId, request.CompanyId);
                hazard.MarkForDelete(user);
                _hazardRepository.SaveOrUpdate(hazard);
            }
            catch (Exception ex)
            {
                _log.Add(ex);
                throw;
            }

        }