public LicencePivot GetLicence(long id) { var item = licenceRepository.GetById((int)id); LicencePivot licencePivot = Mapper.Map <GES_Licence, LicencePivot>(item); return(licencePivot); }
public LicenceStatusViewModel BuildLatestStatus(int licenceId) { var licence = licenceRepository.GetById(licenceId); var latestStatus = licence.CurrentStatusChange.Status; var model = mapper.Map <LicenceStatusViewModel>(latestStatus); return(model); }
public void it_should_update_the_licence_field_from_the_model() { const int expectedId = 1; const string expectedName = "Name"; var licence = new Licence { Id = expectedId, BusinessName = string.Empty }; var model = new BusinessNameViewModel { BusinessName = expectedName }; licenceRepository.GetById(expectedId).Returns(licence); var pdh = new LicenceApplicationPostDataHandler(mapper, repository, licenceRepository, statusRepository, dateTimeProvider); pdh.Update(expectedId, l => l, model); repository.Received(1).Upsert(Arg.Is <Licence>(l => l.BusinessName == expectedName)); }
public void it_updates_a_principal_authority_that_is_linked_to_a_director() { const int licenceId = 1; const int paId = 2; const int dopId = 3; const string expectedName = "Name"; var licence = new Licence { Id = licenceId, PrincipalAuthorities = new List <PrincipalAuthority> { new PrincipalAuthority { Id = paId, DirectorOrPartner = new DirectorOrPartner { Id = dopId } } } }; var model = new FullNameViewModel { FullName = expectedName }; licenceRepository.GetById(licenceId).Returns(licence); repository.Upsert(Arg.Any <PrincipalAuthority>()).Returns(paId); var pdh = new LicenceApplicationPostDataHandler(mapper, repository, licenceRepository, statusRepository, dateTimeProvider); var result = pdh.UpsertPrincipalAuthorityAndLinkToDirectorOrPartner(licenceId, dopId, paId, model); Assert.AreEqual(paId, result); repository.Received(1).Upsert(Arg.Is <PrincipalAuthority>(p => p.FullName.Equals(expectedName) && p.DirectorOrPartner.Id == dopId)); repository.Received(0).Create <PrincipalAuthority>(); repository.Received(0).GetById <DirectorOrPartner>(Arg.Any <int>()); }
public PublicRegisterLicenceDetailViewModel BuildLicence(int id) { var licence = _licenceRepository.GetById(id); return(LicenceRepository.GetLatestStatus(licence).Status.IsLicence ? BuildDetail(licence) : null); }
public LicenceApplicationViewModel Build(int id) { var licence = licenceRepository.GetById(id); return(BuildFromLicence(licence)); }
public void Update <T, U>(int licenceId, Func <Licence, U> objectSelector, T model) where U : class, IId, new() { var licence = licenceRepository.GetById(licenceId); var selectedObject = objectSelector(licence) ?? repository.Create <U>(); mapper.Map(model, selectedObject); repository.Upsert(licence); }