コード例 #1
0
 private void UpdateAccidentRecordInjuryDetailsOverview(InjuryDetailsViewModel model)
 {
     var request = new UpdateInjuryDetailsRequest()
                       {
                           AccidentRecordId = model.AccidentRecordId
                           , BodyPartsInjured = model.SelectedBodyPartIds == null ? new List<long>() : model.SelectedBodyPartIds.ToList()
                           , CompanyId = CurrentUser.CompanyId
                           , CurrentUserId = CurrentUser.UserId
                           , WasTheInjuredPersonBeenTakenToHospital = model.InjuredPersonWasTakenToHospital
                           , HasTheInjuredPersonBeenAbleToCarryOutTheirNormalWorkActivity = model.InjuredPersonAbleToCarryOutWork
                           , Injuries = model.SelectedInjuryIds == null ? new List<long>() : model.SelectedInjuryIds.ToList()
                           , SeverityOfInjury = model.SeverityOfInjury
                           , LengthOfTimeUnableToCarryOutWork = model.LengthOfTimeUnableToCarryOutWork
                           , CustomInjuryDescription = model.CustomInjuryDescription
                           , CustomBodyPartDescription = model.CustomBodyPartyDescription
                       };
     _accidentRecordService.UpdateInjuryDetails(request);
 }
コード例 #2
0
        public void Setup()
        {
            _accidentRecord = new AccidentRecord() { Id = 123123, Jurisdiction = new Jurisdiction{ Name = JurisdictionNames.GB } };

            _accidentRecordRepository = new Mock<IAccidentRecordRepository>();
            _userRepository = new Mock<IUserForAuditingRepository>();
            _log = new Mock<IPeninsulaLog>();
            _injuryRepo = new Mock<IInjuryRepository>();
            _bodyRepo = new Mock<IBodyPartRepository>();

            _userRepository
                .Setup(curUserRepository => curUserRepository.GetByIdAndCompanyId(It.IsAny<Guid>(), It.IsAny<long>()))
                .Returns(() => _user);

            _userRepository
                .Setup(curUserRepository => curUserRepository.GetById(It.IsAny<Guid>()))
                .Returns(() => _user);

            _accidentRecordRepository.Setup(x => x.GetByIdAndCompanyId(It.IsAny<long>(), It.IsAny<long>()))
                .Returns(() => _accidentRecord);

            _bodyRepo.Setup(x => x.GetById(It.IsAny<long>()))
                .Returns<long>(x => new BodyPart(){Id = x});

            _injuryRepo.Setup(x => x.GetById(It.IsAny<long>()))
                .Returns<long>(x => new Injury() { Id = x });

            _bodyRepo.Setup(x => x.GetByIds(It.IsAny<IList<long>>()))
                .Returns<IList<long>>(x =>  x.Select(id => new BodyPart() { Id = id }));

            _injuryRepo.Setup(x => x.GetByIds(It.IsAny<IList<long>>()))
                .Returns<IList<long>>(ids => ids.Select(id => new Injury() { Id = id }));

            _request = new UpdateInjuryDetailsRequest()
            {
                AccidentRecordId = 56456,
                CurrentUserId = _user.Id
            };
        }
コード例 #3
0
        public void UpdateInjuryDetails(UpdateInjuryDetailsRequest request)
        {
            var user = _userForAuditingRepository.GetByIdAndCompanyId(request.CurrentUserId, request.CompanyId);
            var accidentRecord = _accidentRecordRepository.GetByIdAndCompanyId(request.AccidentRecordId, user.CompanyId);
            var bodyParts = request.BodyPartsInjured != null ? _bodyPartRepository.GetByIds(request.BodyPartsInjured).ToList() : new List<BodyPart>();
            var injuries = request.Injuries != null ? _injuryRepository.GetByIds(request.Injuries).ToList() : new List<Injury>();

            accidentRecord.UpdateInjuryDetails(request.SeverityOfInjury,
                                               bodyParts,
                                               request.CustomBodyPartDescription,
                                               injuries,
                                               request.CustomInjuryDescription,
                                               request.WasTheInjuredPersonBeenTakenToHospital,
                                               request.HasTheInjuredPersonBeenAbleToCarryOutTheirNormalWorkActivity,
                                               request.LengthOfTimeUnableToCarryOutWork, user);

            _accidentRecordRepository.Save(accidentRecord);
        }