//Create new legal entity public void CreateLegalEntity(LegalEntity legalEntity) { using (TradingDatabaseEntities context = new TradingDatabaseEntities()) { if (legalEntity == null) { context.LegalEntities.Add(legalEntity); context.SaveChanges(); } } }
public async Task AddAsync(LegalEntity legalEntity) { var existingLegalEntity = await _legalEntityRepository.GetByIdAsync(legalEntity.Id); if (existingLegalEntity != null) { throw new LegalEntityAlreadyExistsException(legalEntity.Id); } await _legalEntityRepository.InsertAsync(legalEntity); await _log.WriteInfoAsync(nameof(LegalEntityService), nameof(AddAsync), legalEntity.ToJson(), "Legal entity added"); }
/// <summary> /// Copy values from View Model to Dynamics legal entity /// </summary> /// <param name="to"></param> /// <param name="from"></param> public static void CopyValues(this MicrosoftDynamicsCRMadoxioLegalentity to, LegalEntity from) { to.AdoxioCommonnonvotingshares = from.commonnonvotingshares; to.AdoxioCommonvotingshares = from.commonvotingshares; to.AdoxioDateofbirth = from.dateofbirth; to.AdoxioFirstname = from.firstname; to.AdoxioInterestpercentage = from.interestpercentage; to.AdoxioIsindividual = (from.isindividual != null && (bool)from.isindividual) ? 1 : 0; to.AdoxioLastname = from.lastname; to.AdoxioIstrustee = from.IsTrustee; if (from.legalentitytype != null) { to.AdoxioLegalentitytype = (int?)from.legalentitytype; } if (from.partnerType != null) { to.AdoxioPartnertype = (int?)from.partnerType; } to.AdoxioMiddlename = from.middlename; to.AdoxioName = from.name; to.AdoxioIspartner = from.isPartner; to.AdoxioIsshareholder = from.isShareholder; to.AdoxioIstrustee = false; to.AdoxioIsdirector = from.isDirector; to.AdoxioIsofficer = from.isOfficer; to.AdoxioIsseniormanagement = from.isSeniorManagement; to.AdoxioIsowner = from.isOwner; to.AdoxioIskeypersonnel = from.isKeyPersonnel; to.AdoxioPreferrednonvotingshares = from.preferrednonvotingshares; to.AdoxioPreferredvotingshares = from.preferredvotingshares; to.AdoxioSameasapplyingperson = (from.sameasapplyingperson != null && (bool)from.sameasapplyingperson) ? 1 : 0; to.AdoxioEmail = from.email; to.AdoxioDateofappointment = from.dateofappointment; to.AdoxioDateofsharesissued = from.dateIssued; to.AdoxioJobtitle = from.jobTitle; to.AdoxioNumberofmembers = from.NumberOfMembers; to.AdoxioAnnualmembershipfee = from.AnnualMembershipFee; to.AdoxioTotalshares = from.TotalShares; // Assigning the account this way throws exception: // System.InvalidOperationException: Collection was modified; enumeration operation may not execute. //if (from.account.id != null) //{ // // fetch the account from Dynamics. // var getAccountTask = _system.GetAccountById(null, Guid.Parse(from.account.id)); // getAccountTask.Wait(); // to.Adoxio_Account= getAccountTask.Result; //} to.AdoxioDateemailsent = from.securityAssessmentEmailSentOn; }
public ActionResult UnOwner(int?legalEntityPK) { ILegalEntitiesRepository legalEntitiesRepository = new LegalEntitiesRepository(db); if (legalEntityPK != null) { LegalEntity legalEntity = legalEntitiesRepository.GetLegalEntityByPK((int)legalEntityPK); legalEntity.Owner = false; legalEntitiesRepository.SaveChanges(); } return(Redirect(Request.UrlReferrer.AbsoluteUri)); }
public void ConvertFrom(LegalEntityLegalRepresentative legalEntityLegalRepresentative, LegalEntityLegalRepresentativeView legalEntityLegalRepresentativeView, ObjectContext db) { legalEntityLegalRepresentativeView.LegalEntityLegalRepresentativePK = legalEntityLegalRepresentative.LegalEntityLegalRepresentativePK; legalEntityLegalRepresentativeView.LegalEntityFK = legalEntityLegalRepresentative.LegalEntityFK; legalEntityLegalRepresentativeView.WayOfRepresentationFK = legalEntityLegalRepresentative.WayOfRepresentationFK; legalEntityLegalRepresentativeView.LegalRepresentativeFK = legalEntityLegalRepresentative.LegalRepresentativeFK; legalEntityLegalRepresentativeView.Deleted = legalEntityLegalRepresentative.Deleted; ILegalEntitiesRepository legalEntitiesRepository = new LegalEntitiesRepository(db); LegalEntity legalEntity = legalEntitiesRepository.GetLegalEntityByPK((int)legalEntityLegalRepresentative.LegalEntityFK); legalEntityLegalRepresentativeView.LegalEntityName = legalEntity.Name + " (" + legalEntity.OIB + ")"; }
public void Then_signed_version_is_set(int?currentVersion, int signedVersion, int minimumRequiredVersion, int?expectedVersion) { // Arrange var model = _fixture.Build <LegalEntityModel>() .With(x => x.SignedAgreementVersion, currentVersion) .Create(); var legalEntity = LegalEntity.Create(model); // Act legalEntity.SignedAgreement(signedVersion, minimumRequiredVersion); // Assert model.SignedAgreementVersion.Should().Be(expectedVersion); }
public LegalEntityViewModel(EntityWithETag <LegalEntity> ewe, IEventAggregator eventAggregator) { this.eventAggregator = eventAggregator; this.legalentity = ewe.Object; this.Id = this.legalentity.MdmId(); this.ETag = ewe.ETag; if (this.legalentity.MdmSystemData != null && this.legalentity.MdmSystemData.StartDate != null) { this.Start = this.legalentity.MdmSystemData.StartDate.Value; } if (this.legalentity.MdmSystemData != null && this.legalentity.MdmSystemData.EndDate != null) { this.End = this.legalentity.MdmSystemData.EndDate.Value; } this.Name = this.legalentity.Details.Name; this.RegisteredName = this.legalentity.Details.RegisteredName; this.RegistrationNumber = this.legalentity.Details.RegistrationNumber; this.Address = this.legalentity.Details.Address; this.Website = this.legalentity.Details.Website; this.Email = this.legalentity.Details.Email; this.Fax = this.legalentity.Details.Fax; this.Phone = this.legalentity.Details.Phone; this.CountryOfIncorporation = this.legalentity.Details.CountryOfIncorporation; this.PartyStatus = this.legalentity.Details.PartyStatus; this.PartyId = this.legalentity.Party.MdmId(); this.PartyName = this.legalentity.Party != null ? this.legalentity.Party.Name : null; this.InvoiceSetup = this.legalentity.Details.InvoiceSetup; this.CustomerAddress = this.legalentity.Details.CustomerAddress; this.VendorAddress = this.legalentity.Details.VendorAddress; }
public string Insert_Entity(LegalEntity entity) { if (entity != null) { using (SampleEntities Obj = new SampleEntities()) { Obj.LegalEntities.Add(entity); Obj.SaveChanges(); return("Entity Added Successfully"); } } else { return("Entity Not Inserted! Try Again"); } }
public EntitiesController.EntityViewModel Create(LegalEntity entity) { return(new EntitiesController.EntityViewModel { FirstName = entity.FirstName, LastName = entity.LastName, Email = entity.Email, PhoneNumber = entity.PhoneNumber, BankAccountNumber = entity.BankAccountNumber, Note = entity.Note, CompanyName = entity.CompanyName, IdentifyingNumber = entity.IdentifyingNumber, TaxIdentifyingNumber = entity.TaxIdentifyingNumber, Id = entity.Id }); }
public void ConvertFrom(LegalEntity legalEntity, LegalEntityView legalEntityView) { legalEntityView.LegalEntityPK = legalEntity.LegalEntityPK; legalEntityView.Name = legalEntity.Name; legalEntityView.ShortName = legalEntity.ShortName; legalEntityView.OIB = legalEntity.OIB; legalEntityView.MB = legalEntity.MB; legalEntityView.MBS = legalEntity.MBS; legalEntityView.FormFK = legalEntity.FormFK; legalEntityView.Company = legalEntity.Company; legalEntityView.Active = legalEntity.Active; legalEntityView.Deleted = legalEntity.Deleted; }
// GET: Admin/LegalEntities/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } LegalEntity legalEntity = db.LegalEntity.Find(id); if (legalEntity == null) { return(HttpNotFound()); } ViewBag.bloodgroup_id = new SelectList(db.BloodGroups, "id", "name", legalEntity.bloodgroup_id); ViewBag.city_id = new SelectList(db.Cities, "id", "name", legalEntity.city_id); return(View(legalEntity)); }
//Method to update an existing legal entity public void UpdateLegalEntity(int id, LegalEntity newLegalEntity) { using (TradingDatabaseEntities context = new TradingDatabaseEntities()) { LegalEntity legalEntityToUpdate = (from l in context.LegalEntities where l.id == id select l).FirstOrDefault(); if (newLegalEntity != null) { legalEntityToUpdate.Name = legalEntityToUpdate.Name; legalEntityToUpdate.Address = legalEntityToUpdate.Address; context.SaveChanges(); } } }
public async Task Then_The_Signed_Agreements_Are_Returned( GetBankingDataQuery query, IncentiveApplicationDto applicationResponse, LegalEntity legalEntityResponse, [Frozen] Mock <IApplicationService> applicationService, [Frozen] Mock <IAccountsService> accountsService, GetBankingDataHandler handler ) { applicationService.Setup(x => x.Get(query.AccountId, query.ApplicationId)).ReturnsAsync(applicationResponse); accountsService.Setup(x => x.GetLegalEntity(query.HashedAccountId, applicationResponse.LegalEntityId)).ReturnsAsync(legalEntityResponse); var actual = await handler.Handle(query, CancellationToken.None); actual.Data.SignedAgreements.Should().BeEquivalentTo(legalEntityResponse.Agreements.Where(x => x.Status == EmployerAgreementStatus.Signed || x.Status == EmployerAgreementStatus.Expired || x.Status == EmployerAgreementStatus.Superseded), opts => opts.ExcludingMissingMembers()); }
/// <summary> /// Method, that retrieves Legal Entity data /// </summary> /// <param name="cvr">string</param> /// <param name="legalEntity">LegalEntity</param> public LegalEntity GetCvrData(string cvr) { this.tempLegalEntity = new LegalEntity(); try { GetCvrRootsObject(cvr); GetLegalEntityFromRootObject(cvr); } catch (Exception ex) { MessageBox.Show(ex.Message); } return(this.tempLegalEntity); }
public void Then_no_legalEntities_are_unchanged_if_it_does_not_exist() { // Arrange var legalEntityModel = _fixture.Create <LegalEntityModel>(); var legalEntity = LegalEntity.Create(legalEntityModel); _sut.LegalEntities.Count.Should().Be(2); _sut.LegalEntities.SingleOrDefault(i => i.GetModel().AccountLegalEntityId == legalEntityModel.AccountLegalEntityId).Should().BeNull(); // Act _sut.RemoveLegalEntity(legalEntity); // Assert _sut.LegalEntities.Count.Should().Be(2); _sut.LegalEntities.SingleOrDefault(i => i.GetModel().AccountLegalEntityId == legalEntityModel.AccountLegalEntityId).Should().BeNull(); }
/// <summary> /// Method, that updates Entrepeneur data /// </summary> /// <param name="entity">LegalEntity</param> /// <returns>LegalEntity</returns> public UpdateData UpdateCvrData(LegalEntity entity) { updatedData.Entity = entity; cvrRootRootObject = new RootObject(); try { GetCvrRootsObject(updatedData.Entity.Cvr); UpdateLegalEntityFromRootObject(); } catch (Exception ex) { MessageBox.Show(ex.Message); } return(updatedData); }
public void Create_intersection_after_legal_entity_creation() { var client = DataMother.TestClient(); var org = new LegalEntity { Name = "тараканов и сыновья", Payer = client.Payers.First() }; session.Save(org); Maintainer.LegalEntityCreated(session, org); var count = ArHelper.WithSession(s => s.CreateSQLQuery(@"select count(*) from Customers.Intersection where LegalEntityId = :LegalEntityId") .SetParameter("LegalEntityId", org.Id) .UniqueResult <long>()); Assert.That(count, Is.GreaterThan(0)); }
public void Arrange() { _mediator = new Mock <IMediator>(); _legalEntityId = long.MaxValue; _accountHashedId = "H4#h3d"; _legalEntity = new LegalEntity(); _response = new GetLegalEntityResponse { LegalEntity = _legalEntity }; _mediator.Setup(m => m.SendAsync( It.Is <GetLegalEntityQuery>( q => q.AccountHashedId.Equals(_accountHashedId) && q.LegalEntityId.Equals(_legalEntityId)))) .ReturnsAsync(_response); _controller = new LegalEntitiesController(_mediator.Object); }
public ActionResult Delete(int?legalEntityPK) { ILegalEntitiesRepository legalEntitiesRepository = new LegalEntitiesRepository(db); if (legalEntityPK != null) { LegalEntity legalEntity = legalEntitiesRepository.GetLegalEntityByPK((int)legalEntityPK); legalEntity.Deleted = true; legalEntitiesRepository.SaveChanges(); TempData["message"] = LayoutHelper.GetMessage("DELETE", legalEntity.LegalEntityPK); } return(Redirect(Request.UrlReferrer.AbsoluteUri)); }
public async Task Then_The_Api_Is_Called_Returning_The_Legal_Entity( string accountId, long legalEntityId, LegalEntity apiResponse, [Frozen] Mock <IAccountsApiClient <AccountsConfiguration> > client, AccountsService service ) { client.Setup(x => x.Get <LegalEntity>( It.Is <GetLegalEntityRequest>(c => c.GetUrl.Contains(accountId) && c.GetUrl.Contains(legalEntityId.ToString())))) .ReturnsAsync(apiResponse); var actual = await service.GetLegalEntity(accountId, legalEntityId); actual.Should().BeEquivalentTo(apiResponse); }
public void Then_the_legalEntity_is_added_if_it_is_different_to_a_previously_added_one() { // Arrange var firstAccountLegalEntityId = _fixture.Create <long>(); var firstLegalEntity = LegalEntity.Create(_fixture.Build <LegalEntityModel>().With(f => f.AccountLegalEntityId, firstAccountLegalEntityId).Create()); _sut.AddLegalEntity(firstAccountLegalEntityId, firstLegalEntity); var secondAccountLegalEntityId = firstAccountLegalEntityId + 1; var secondLegalEntity = LegalEntity.Create(_fixture.Build <LegalEntityModel>().With(f => f.Id, firstLegalEntity.Id + 1).With(f => f.AccountLegalEntityId, secondAccountLegalEntityId).Create()); // Act _sut.AddLegalEntity(secondAccountLegalEntityId, secondLegalEntity); // Assert _sut.LegalEntities.Should().Contain(new [] { firstLegalEntity, secondLegalEntity }); }
public ActionResult Edit(int?legalEntityPK) { if (legalEntityPK != null) { ILegalEntitiesRepository legalEntitiesRepository = new LegalEntitiesRepository(db); LegalEntity legalEntity = legalEntitiesRepository.GetLegalEntityByPK((int)legalEntityPK); LegalEntityView legalEntityView = new LegalEntityView(); legalEntityView.ConvertFrom(legalEntity, legalEntityView); legalEntityView.BindDDLs(legalEntityView, db); return(View(legalEntityView)); } else { return(RedirectToAction("Index", "LegalEntity")); } }
public LegalEntityViewModel(IEventAggregator eventAggregator) { this.eventAggregator = eventAggregator; this.legalentity = new LegalEntity { MdmSystemData = new SystemData { StartDate = DateUtility.MinDate, EndDate = DateUtility.MaxDate } }; this.Start = this.legalentity.MdmSystemData.StartDate.Value; this.End = this.legalentity.MdmSystemData.EndDate.Value; }
public void Bind_legal_entity() { var begin = DateTime.Now; var payer = client.Payers[0]; var org = new LegalEntity("Тестовый", payer); payer.JuridicalOrganizations.Add(org); session.Flush(); Request.Params.Add("address.Value", "тестовый адрес доставки"); Request.Params.Add("address.AvaliableForUsers[0].Id", user.Id.ToString()); Request.Params.Add("address.LegalEntity.Id", org.Id.ToString()); controller.Add(new Contact[0], client.Id, "тестовое сообщение для биллинга"); var addresses = Registred(); Assert.That(addresses.LegalEntity.Id, Is.EqualTo(org.Id)); }
/// <summary> /// Method, retrieves a Legal Entity from a RootObject /// </summary> /// <param name="cvr"></param> private void GetLegalEntityFromRootObject(string cvr) { int cvrLength = cvr.Length; switch (cvrLength) { case 8: this.tempLegalEntity = new LegalEntity(cvrRootRootObject.vat.ToString(), cvrRootRootObject.name, cvrRootRootObject.addressco, new Address(cvrRootRootObject.address, cvrRootRootObject.cityname, new ZipTown(cvrRootRootObject.zipcode.ToString(), cvrRootRootObject.city)), new ContactInfo(cvrRootRootObject.phone.ToString(), cvrRootRootObject.fax.ToString(), "", cvrRootRootObject.email), ""); break; case 10: ConvertProductionUnitDataToLegalEntity(cvr); break; default: break; } }
public async Task Then_Agreements_Without_a_Signed_Date_Are_Not_Returned( GetBankingDataQuery query, IncentiveApplicationDto applicationResponse, LegalEntity legalEntityResponse, [Frozen] Mock <IApplicationService> applicationService, [Frozen] Mock <IAccountsService> accountsService, GetBankingDataHandler handler ) { var agreementWithoutDate = legalEntityResponse.Agreements.First(x => x.Status == EmployerAgreementStatus.Signed || x.Status == EmployerAgreementStatus.Expired || x.Status == EmployerAgreementStatus.Superseded); agreementWithoutDate.SignedDate = null; applicationService.Setup(x => x.Get(query.AccountId, query.ApplicationId)).ReturnsAsync(applicationResponse); accountsService.Setup(x => x.GetLegalEntity(query.HashedAccountId, applicationResponse.LegalEntityId)).ReturnsAsync(legalEntityResponse); var actual = await handler.Handle(query, CancellationToken.None); actual.Data.SignedAgreements.Count().Should().Be(legalEntityResponse.Agreements.Count(x => x.Status == EmployerAgreementStatus.Signed || x.Status == EmployerAgreementStatus.Expired || x.Status == EmployerAgreementStatus.Superseded) - 1); }
static Context() { using (var client = new Context()) { client.Database.EnsureCreated(); client.Persons.Clear(); client.LegalEntities.Clear(); client.Accounts.Clear(); client.SaveChanges(); var p1 = new Person { BirthDate = new DateTime(1982, 3, 7), Name = "Andrey", Surname = "Ivanov" }; var p2 = new Person { BirthDate = new DateTime(1975, 4, 13), Name = "Sergey", Surname = "Petrov" }; client.Persons.Add(p1); client.Persons.Add(p2); var le1 = new LegalEntity { LegalEntityType = LegalEntityTypes.OOO, Name = "Microsoft" }; var le2 = new LegalEntity { LegalEntityType = LegalEntityTypes.AO, Name = "Apple" }; client.LegalEntities.Add(le1); client.LegalEntities.Add(le2); client.SaveChanges(); client.Accounts.Add(new Account { Balance = 900, Number = "5678", Person = p1 }); client.Accounts.Add(new Account { Balance = 100, Number = "7876", LegalEntity = le1 }); client.Accounts.Add(new Account { Balance = 200, Number = "2534", LegalEntity = le2 }); client.SaveChanges(); } }
public string Update_Entity(LegalEntity entity) { if (entity != null) { using (SampleEntities Obj = new SampleEntities()) { var entity_ = Obj.Entry(entity); LegalEntity EmpObj = Obj.LegalEntities.Where(x => x.EntityId == entity.EntityId).FirstOrDefault(); EmpObj.EntityName = entity.EntityName; EmpObj.Abbreviation = entity.Abbreviation; Obj.SaveChanges(); return("Entity Updated Successfully"); } } else { return("Entity Not Updated! Try Again"); } }
//----------------------------------------------------- private static IEnumerable <Partner> Initial() { List <Partner> partners = new List <Partner>(); List <Individual> individuals = new List <Individual>(); for (int i = 1; i <= 15; i++) { var individual = new Individual { Id = i, Iin = $"44445555666{i}", FirstName = $"FName_{i}", LastName = $"LName_{i}", Patronymic = $"PName_{i}", CreationDate = DateTime.Now, LegalEntityId = i }; individuals.Add(individual); } for (int i = 0; i <= 8; i++) { var legalEntity = new LegalEntity { Id = (i + 1), CreationDate = DateTime.Now.AddDays(-(i + 1)), Iin = $"11112222333{i}", Name = $"Name_{i + 1}" // ContactIndividuals = new List<Individual>() { individuals[i], individuals[i + i], individuals[i + i + 1] } }; partners.Add(legalEntity); } individuals[5].LegalEntityId = 3; individuals[6].LegalEntityId = 3; individuals[2].LegalEntityId = 3; individuals[7].LegalEntityId = 4; individuals[8].LegalEntityId = 4; individuals[11].LegalEntityId = 4; individuals[13].LegalEntityId = 4; partners.AddRange(individuals); return(partners); }
public async Task <EmployerAgreementView> CreateLegalEntity( long accountId, LegalEntity legalEntity) { return(await WithConnection(async c => { var parameters = new DynamicParameters(); parameters.Add("@accountId", accountId, DbType.Int64); parameters.Add("@companyNumber", legalEntity.Code, DbType.String); parameters.Add("@companyName", legalEntity.Name, DbType.String); parameters.Add("@CompanyAddress", legalEntity.RegisteredAddress, DbType.String); parameters.Add("@CompanyDateOfIncorporation", legalEntity.DateOfIncorporation, DbType.DateTime); parameters.Add("@legalEntityId", null, DbType.Int64, ParameterDirection.Output); parameters.Add("@employerAgreementId", null, DbType.Int64, ParameterDirection.Output); parameters.Add("@status", legalEntity.CompanyStatus, DbType.String); parameters.Add("@source", legalEntity.Source, DbType.Int16); parameters.Add("@publicSectorDataSource", legalEntity.PublicSectorDataSource, DbType.Int16); parameters.Add("@sector", legalEntity.Sector, DbType.String); var trans = c.BeginTransaction(); var result = await c.ExecuteAsync( sql: "[employer_account].[CreateLegalEntityWithAgreement]", param: parameters, commandType: CommandType.StoredProcedure, transaction: trans); trans.Commit(); var legalEntityId = parameters.Get <long>("@legalEntityId"); var agreementId = parameters.Get <long>("@employerAgreementId"); return new EmployerAgreementView { Id = agreementId, AccountId = accountId, LegalEntityId = legalEntityId, LegalEntityName = legalEntity.Name, LegalEntityCode = legalEntity.Code, LegalEntityAddress = legalEntity.RegisteredAddress, LegalEntityInceptionDate = legalEntity.DateOfIncorporation, Sector = legalEntity.Sector, Status = EmployerAgreementStatus.Pending, }; })); }
public virtual void ChangePayer(ISession session, Payer payer, LegalEntity org) { CommonChangePayer(() => { foreach (var address in Addresses) { address.Payer.Addresses.Remove(address); address.Payer = payer; address.LegalEntity = org; address.Payer.Addresses.Add(address); } session.CreateSQLQuery(@" update Customers.intersection set LegalEntityId = :orgId where ClientId = :clientId") .SetParameter("clientId", Id) .SetParameter("orgId", org.Id) .ExecuteUpdate(); }, payer); }
private LegalEntity GetLegalEntityTree(string accountId) { LegalEntity result = null; var filter = "_adoxio_account_value eq " + accountId; filter += " and _adoxio_legalentityowned_value eq null"; var response = _dynamicsClient.Legalentities.Get(filter: filter); if (response != null && response.Value != null) { var legalEntity = response.Value.FirstOrDefault(); if (legalEntity != null) { result = legalEntity.ToViewModel(); result.children = this.GetLegalEntityChildren(result.id); } } return(result); }
public static LegalEntity CreateEntityWithTwoDetailsAndTwoMappings() { SourceSystem endur = repository.Queryable<SourceSystem>().Where(system => system.Name == "Endur").First(); SourceSystem trayport = repository.Queryable<SourceSystem>().Where(system => system.Name == "Trayport").First(); var entity = new LegalEntity(); entity.Party = ObjectMother.Create<Party>(); baseDate = DateTime.Today.Subtract(new TimeSpan(72, 0, 0)); SystemTime.UtcNow = () => new DateTime(DateTime.Today.Subtract(new TimeSpan(73, 0, 0)).Ticks); AddDetailsToEntity(entity, DateTime.MinValue, baseDate); AddDetailsToEntity(entity, baseDate, DateTime.MaxValue); SystemTime.UtcNow = () => DateTime.Now; var trayportMapping = new PartyRoleMapping { MappingValue = Guid.NewGuid().ToString(), System = trayport, Validity = new DateRange(DateTime.MinValue, DateTime.MaxValue) }; var endurMapping = new PartyRoleMapping { MappingValue = Guid.NewGuid().ToString(), System = endur, IsDefault = true, Validity = new DateRange(DateTime.MinValue, DateTime.MaxValue) }; entity.ProcessMapping(trayportMapping); entity.ProcessMapping(endurMapping); repository.Add(entity); repository.Flush(); return entity; }
public void ValidContractIsSaved() { // Arrange var validatorFactory = new Mock<IValidatorEngine>(); var mappingEngine = new Mock<IMappingEngine>(); var repository = new Mock<IRepository>(); var searchCache = new Mock<ISearchCache>(); var service = new LegalEntityService(validatorFactory.Object, mappingEngine.Object, repository.Object, searchCache.Object); var legalentity = new LegalEntity(); var contract = new EnergyTrading.MDM.Contracts.Sample.LegalEntity(); validatorFactory.Setup(x => x.IsValid(It.IsAny<EnergyTrading.MDM.Contracts.Sample.LegalEntity>(), It.IsAny<IList<IRule>>())).Returns(true); mappingEngine.Setup(x => x.Map<EnergyTrading.MDM.Contracts.Sample.LegalEntity, LegalEntity>(contract)).Returns(legalentity); // Act var expected = service.Create(contract); // Assert Assert.AreSame(expected, legalentity, "LegalEntity differs"); repository.Verify(x => x.Add(legalentity)); repository.Verify(x => x.Flush()); }
//Create new legal entity public void CreateLegalEntities(LegalEntity legalEntity) { ledb.CreateLegalEntity(legalEntity); }
//Update legal entity public void UpdateLegalEntities(int id, LegalEntity legalEntity) { ledb.UpdateLegalEntity(id, legalEntity); }
public static void CreateSearch(Search search, LegalEntity entity1, LegalEntity entity2) { CreateSearchData(search, entity1, entity2); }
private static void AddDetailsToEntity(LegalEntity entity, DateTime startDate, DateTime endDate) { var newEntity = ObjectMother.Create<LegalEntity>(); entity.PartyRoleType = newEntity.PartyRoleType; entity.AddDetails(new LegalEntityDetails { Name = newEntity.Details[0].Name, }); }
private static void CreateSearchData(Search search, LegalEntity entity1, LegalEntity entity2) { search.AddSearchCriteria(SearchCombinator.Or) .AddCriteria("Name", SearchCondition.Equals, entity1.LatestDetails.Name) .AddCriteria("Name", SearchCondition.Equals, entity2.LatestDetails.Name); }