public void Save(IEnumerable <DependentDisqualifiedTest> answers) { using (var adapter = PersistenceLayer.GetDataAccessAdapter()) { var entities = Mapper.Map <IEnumerable <DependentDisqualifiedTest>, IEnumerable <DependentDisqualifiedTestEntity> >(answers); var collection = new EntityCollection <DependentDisqualifiedTestEntity>(); collection.AddRange(entities); if (adapter.SaveEntityCollection(collection) <= 0) { throw new PersistenceFailureException(); } } }
public void Save(IEnumerable <CustomerIcdCode> customerIcdCodes, long customerId) { DeactiveCustomerIcdCodes(customerId); using (var adapter = PersistenceLayer.GetDataAccessAdapter()) { var entities = Mapper.Map <IEnumerable <CustomerIcdCode>, IEnumerable <CustomerIcdCodeEntity> >(customerIcdCodes); var collection = new EntityCollection <CustomerIcdCodeEntity>(); collection.AddRange(entities); adapter.SaveEntityCollection(collection); } }
private async Task Initialize(CancellationToken cancellationToken) { _excludedMatchDateEntities.Clear(); _excludedMatchDateEntities.AddRange( await _appDb.ExcludedMatchDateRepository.GetExcludedMatchDatesAsync( _tenantContext.TournamentContext.MatchPlanTournamentId, cancellationToken)); _availableMatchDateEntities.Clear(); _availableMatchDateEntities.AddRange( await _appDb.AvailableMatchDateRepository.GetAvailableMatchDatesAsync( _tenantContext.TournamentContext.MatchPlanTournamentId, cancellationToken)); _generatedAvailableMatchDateEntities.Clear(); }
public bool SaveScreeningAuthorizations(List <ScreeningAuthorization> screeningAuthorizations) { using (var adapter = PersistenceLayer.GetDataAccessAdapter()) { var entitiesToSave = _mapper.MapMultiple(screeningAuthorizations); var entities = new EntityCollection <ScreeningAuthorizationEntity>(); entities.AddRange(entitiesToSave); if (adapter.SaveEntityCollection(entities) == 0) { throw new PersistenceFailureException(); } return(true); } }
public void Update(IEnumerable <CustomerCallNotes> customerCallNoteses) { using (var adapter = PersistenceLayer.GetDataAccessAdapter()) { var entities = new EntityCollection <CustomerRegistrationNotesEntity>(); entities.AddRange(Mapper.MapMultiple(customerCallNoteses)); if (adapter.SaveEntityCollection(entities) == 0) { throw new PersistenceFailureException(); } } }
private void SaveEventCoupons(long sourceCodeId, IEnumerable <long> eventIds) { using (var adapter = PersistenceLayer.GetDataAccessAdapter()) { var entities = eventIds.Select(e => new EventCouponsEntity { CouponId = sourceCodeId, EventId = e }).ToArray(); var entityCollection = new EntityCollection <EventCouponsEntity>(); entityCollection.AddRange(entities); adapter.SaveEntityCollection(entityCollection); } }
public void AddRange_Sets_Foreign_Field() { // arrange var entity = TestHelper.CreateEntityWithId <Artist>(1); var artistStatisticValues = new ArtistStatisticValues(); var entityCollection = new EntityCollection <ArtistStatisticValues>(entity, "AnotherArtist", "StatisticValues"); // act entityCollection.AddRange(new[] { artistStatisticValues }); // assert Assert.Equal(artistStatisticValues.AnotherArtist, entity); }
public void SaveAll(IEnumerable <EventCustomerTestNotPerformedNotification> domainList) { using (var adapter = PersistenceLayer.GetDataAccessAdapter()) { var entities = Mapper.Map <IEnumerable <EventCustomerTestNotPerformedNotification>, IEnumerable <EventCustomerTestNotPerformedNotificationEntity> >(domainList); var collection = new EntityCollection <EventCustomerTestNotPerformedNotificationEntity>(); collection.AddRange(entities); if (adapter.SaveEntityCollection(collection) == 0) { throw new PersistenceFailureException(); } } }
public void SaveSourceCodeSignupMode(IEnumerable <SignUpMode> signUpModes, long sourceCodeId) { using (var adapter = PersistenceLayer.GetDataAccessAdapter()) { var entities = signUpModes.Select( sm => new CouponSignUpModeEntity { CouponId = sourceCodeId, SignUpMode = (byte)sm }).ToArray(); var entityCollection = new EntityCollection <CouponSignUpModeEntity>(); entityCollection.AddRange(entities); adapter.SaveEntityCollection(entityCollection, true, false); } }
public void SaveCustomerClinicalQuestionAnswers(IEnumerable <CustomerClinicalQuestionAnswer> answers) { using (var adapter = PersistenceLayer.GetDataAccessAdapter()) { var entities = Mapper.Map <IEnumerable <CustomerClinicalQuestionAnswer>, IEnumerable <CustomerClinicalQuestionAnswerEntity> >(answers); var entityCollection = new EntityCollection <CustomerClinicalQuestionAnswerEntity>(); entityCollection.AddRange(entities); if (adapter.SaveEntityCollection(entityCollection, true, false) == 0) { throw new PersistenceFailureException(); } } }
public void SaveAnswer(IEnumerable <ChaperoneAnswer> answers) { using (var adapter = PersistenceLayer.GetDataAccessAdapter()) { if (!answers.IsNullOrEmpty()) { var eventCustomerId = answers.First().EventCustomerId; var orgRoleUserId = answers.First().CreatedBy; DeactivateAll(eventCustomerId, orgRoleUserId); } var entities = Mapper.Map <IEnumerable <ChaperoneAnswer>, IEnumerable <ChaperoneAnswerEntity> >(answers); var collection = new EntityCollection <ChaperoneAnswerEntity>(); collection.AddRange(entities); adapter.SaveEntityCollection(collection); } }
public void SaveCustomerAnswer(IEnumerable <MedicareQuestionAnswer> customerAnswers, long customerEventId, long createdBy) { using (var adapter = PersistenceLayer.GetDataAccessAdapter()) { adapter.DeleteEntitiesDirectly(typeof(CustomerMedicareQuestionAnswerEntity), new RelationPredicateBucket(CustomerMedicareQuestionAnswerFields.EventCustomerId == customerEventId)); var collection = new EntityCollection <CustomerMedicareQuestionAnswerEntity>(); var entities = MapMultiple(customerAnswers, createdBy); collection.AddRange(entities); if (adapter.SaveEntityCollection(collection) == 0) { throw new PersistenceFailureException(); } } }
public IEnumerable <PackageTest> Save(IEnumerable <PackageTest> domainObjects) { if (domainObjects == null || domainObjects.Count() < 1) { return(null); } using (var adapter = PersistenceLayer.GetDataAccessAdapter()) { adapter.DeleteEntitiesDirectly("PackageTestEntity", new RelationPredicateBucket(PackageTestFields.PackageId == domainObjects.First().PackageId)); var entities = Mapper.Map <IEnumerable <PackageTest>, IEnumerable <PackageTestEntity> >(domainObjects); var entitycollection = new EntityCollection <PackageTestEntity>(); entitycollection.AddRange(entities); adapter.SaveEntityCollection(entitycollection, true, false); return(Mapper.Map <IEnumerable <PackageTestEntity>, IEnumerable <PackageTest> >(entities)); } }
public void SaveRolesforGivenPackageAvailability(long packageId, IEnumerable <long> roleIds) { using (var adapter = PersistenceLayer.GetDataAccessAdapter()) { adapter.DeleteEntitiesDirectly("PackageAvailabilityToRolesEntity", new RelationPredicateBucket(PackageAvailabilityToRolesFields.PackageId == packageId)); if (roleIds == null || roleIds.Count() < 1) { return; } var roles = roleIds.Select(roleId => new PackageAvailabilityToRolesEntity { RoleId = roleId, PackageId = packageId }).ToArray(); var entityCollection = new EntityCollection <PackageAvailabilityToRolesEntity>(); entityCollection.AddRange(roles); adapter.SaveEntityCollection(entityCollection); } }
public void SaveAnswer(IEnumerable <SurveyAnswer> answer) { if (answer.IsNullOrEmpty()) { return; } using (var adapter = PersistenceLayer.GetDataAccessAdapter()) { var survey = answer.First(); DeleteSurveyAnswers(survey.Id, survey.DataRecorderMetaData.DataRecorderCreator.Id); var entities = Mapper.Map <IEnumerable <SurveyAnswer>, IEnumerable <SurveyAnswerEntity> >(answer); var collection = new EntityCollection <SurveyAnswerEntity>(); collection.AddRange(entities); adapter.SaveEntityCollection(collection); } }
protected override void InitializeCollection() { Output.WriteLine("Initialized"); //TODO: Fix this removing this line causes InitializeCollection not being called randomly EntityCollection = Enumerable.Range(1, 10).Select(x => new UserProfileEntity { DisplayName = $"User Name {x}", UserName = $"username{x}", PassKey = $"passKey{x}" }).ToList(); EntityCollection.AddRange(new[] { new UserProfileEntity { UserName = "******", DisplayName = "nainaanu" }, new UserProfileEntity { UserName = "******", DisplayName = "jiaanu" } }); }
private IEnumerable <SourceCodeItemWiseDiscount> SaveProductSourceCodeDiscounts(long sourceCodeId, IEnumerable <SourceCodeItemWiseDiscount> shippingDiscounts) { using (var adapter = PersistenceLayer.GetDataAccessAdapter()) { var entities = shippingDiscounts.Select(td => new ProductSourceCodeDiscountEntity { SourceCodeId = sourceCodeId, ProductId = td.Id, Discount = td.DiscountAmount, IsPercentage = (td.DiscountValueType == DiscountValueType.Percent ? true : false), IsNew = true }).ToArray(); var entityCollection = new EntityCollection <ProductSourceCodeDiscountEntity>(); entityCollection.AddRange(entities); adapter.SaveEntityCollection(entityCollection, true, false); return(Mapper.Map <IEnumerable <ProductSourceCodeDiscountEntity>, IEnumerable <SourceCodeItemWiseDiscount> >(entities)); } }
public void Adding_MultipleEntities_WithEmptyIds_ViaAddRange_HasCorrectCount() { // Arrange var collection = new EntityCollection <AttributeType>(); var entity1 = new AttributeType() { Id = HiveId.Empty }; var entity2 = new AttributeType() { Id = HiveId.Empty }; // Act collection.AddRange(new[] { entity1, entity2 }); // Assert Assert.AreEqual(2, collection.Count); CollectionAssert.Contains(collection, entity1); CollectionAssert.Contains(collection, entity2); }
public void Draw(LevelSpriteBatchPool spriteBatchPool, GameTime gameTime) { spriteBatchPool.Begin(_gameState.Camera); // Draw Tiles. foreach (var coords in QueryCoordinates(_gameState.Camera.Bound)) { GetTile(coords).Draw(spriteBatchPool.Tiles, coords, GetTileDataAt(coords), this, gameTime); } ParticleSystem.Draw(spriteBatchPool.Tiles, gameTime); var entitiesToDraw = new EntityCollection(); entitiesToDraw.AddRange(QueryEntity(_gameState.Camera.Bound.Inflate(Game.Unit * 4f, Game.Unit * 12f))); entitiesToDraw.SortForRender(); // Draw Entities, Shadows and lights. foreach (var e in entitiesToDraw) { // Draw the entity. e.Draw(spriteBatchPool, gameTime); // Draw Entity overlay. if (Rise.Ui.Enabled) { e.Overlay(spriteBatchPool.Overlay, gameTime); } if (Rise.Debug.GAME) { spriteBatchPool.Overlay.PutPixel(e.Position, Color.Magenta); } } FinalizeDraw(spriteBatchPool); }
public WeeklySummaryCollection Confirm(int confirmUserID, int entityID) { User _confirmUser = (new UserAccessClient(EndpointName.UserAccess)).QueryuserID(confirmUserID)[0]; WeeklySummaryCollection _confirm = new WeeklySummaryCollection(); Entity _entity = EntityService.Instance.LoadEntity(entityID)[0]; if ((_entity.SumType != SumType.Transaction) && (_entity.SumType != SumType.Subtotal)) { return _confirm; } _entity.SubEntities = ((_entity.SumType == SumType.Transaction) ? SetSubtotal(_entity.SubEntities, new WeeklySummaryCollection()) : SetLastLevel(_entity.SubEntities, new WeeklySummaryCollection())); ConfirmTransfer(new EntityCollection(new Entity[] { _entity }), _confirm); if (_confirm.Count <= 0) { return _confirm; } foreach (WeeklySummary _weeklySummary in _confirm) { _weeklySummary.Status = WeeklySummaryStatus.Confirm; _weeklySummary.ConfirmUser = _confirmUser; } using (WeeklySummaryAccessClient _weeklySummaryAccessClient = new WeeklySummaryAccessClient(EndpointName.WeeklySummaryAccess)) { _weeklySummaryAccessClient.Update2(_confirm.ToArray()); } //<EntityID, RecordID> Dictionary<int, int> _pairs = new Dictionary<int, int>(); foreach (WeeklySummary _weeklySummary in _confirm) { int _recordID = -1; using (RecordAccessClient _recordAccessClient = new RecordAccessClient(EndpointName.RecordAccess)) { _pairs[_weeklySummary.Entity.EntityID] = (_recordID = _recordAccessClient.QueryRecordID(_weeklySummary.Entity.EntityID, PeriodService.Instance.GetCurrentPeriod()[0].ID)); } if (_recordID > 0) { if (_pairs.Values.Count(RecordID => (RecordID == _recordID)) == 1) { using (RecordAccessClient _recordAccessClient = new RecordAccessClient(EndpointName.RecordAccess)) { _recordAccessClient.ChangeStatus(_recordID, RecordStatus.Confirm); } } } } foreach (KeyValuePair<int, int> _pair in _pairs) { if (_pair.Value > 0) { continue; } Entity _subtotal = null; if (_entity.SumType == SumType.Transaction) { if ((_subtotal = _entity.SubEntities.FirstOrDefault(Entity => (_pair.Key == Entity.EntityID))) == null) { continue; } } else if (_pair.Key == _entity.EntityID) { _subtotal = _entity; } else { continue; } EntityCollection _entityCollection = new EntityCollection() { _subtotal }; _entityCollection.AddRange(_subtotal.SubEntities); decimal[] _baseTransfer = new decimal[_entityCollection.Count]; for (int i = 1; i < _entityCollection.Count; i++) { _baseTransfer[i] = _confirm.FirstOrDefault(WeeklySummary => (WeeklySummary.Entity.EntityID == _entityCollection[i].EntityID)).BaseTransfer; } Transfer _transfer = CalculateService.Instance.Transfer(confirmUserID, _entityCollection, _baseTransfer).Item1; DataEntryService.Instance.InsertTransfer(_transfer.RecordNotInDB, _transfer); } return _confirm; }
public static void Load() { Persistence.Deserialize( _FilePath, reader => { var version = reader.ReadInt(); switch (version) { case 1: { var entries = reader.ReadInt(); while (--entries >= 0) { var key = reader.ReadString(); var ents = reader.ReadInt(); var col = new EntityCollection(ents); IEntity ent; while (--ents >= 0) { ent = World.FindEntity(reader.ReadInt()); if (ent != null && !ent.Deleted) { col.Add(ent); } } _Collections[key] = col; } } break; case 0: { var entries = reader.ReadInt(); while (--entries >= 0) { var key = reader.ReadString(); var items = reader.ReadStrongItemList(); var mobiles = reader.ReadStrongMobileList(); var col = new EntityCollection(items.Count + mobiles.Count); col.AddRange(items); col.AddRange(mobiles); _Collections[key] = col; } } break; } }); }