public Territory CreateTerritory(TerritoryEntity territoryEntity) { switch ((TerritoryType)territoryEntity.Type) { case TerritoryType.Franchisee: return(_franchiseeTerritoryMapper.Map(territoryEntity)); case TerritoryType.HospitalPartner: return(_hospitalPartnerTerritoryMapper.Map(territoryEntity)); case TerritoryType.ReadingPhysician: return(_readingPhysicianTerritoryMapper.Map(territoryEntity)); case TerritoryType.Advertiser: return(_advertiserTerritoryMapper.Map(territoryEntity)); case TerritoryType.SalesRep: return(_salesRepTerritoryMapper.Map(territoryEntity)); case TerritoryType.Pod: return(_podTerritoryMapper.Map(territoryEntity)); default: throw new NotSupportedException(string.Format ("The persisted territory type {0} is currently unsupported.", ((TerritoryType)territoryEntity.Type))); } }
public void Initialize(TerritoryEntity territory) { _myTerritoryEntity = territory; territory.OnChangeFaithPoint .Subscribe(_ => UpdateFaithPoint()) .AddTo(this); territory.OnChangeMoney .Subscribe(_ => UpdateMoney()) .AddTo(this); UpdateBuildingTemplate(territory.BuildingTemplates); territory.BuildingTemplates .ObserveMove() .Subscribe(_ => UpdateBuildingTemplate(territory.BuildingTemplates)) .AddTo(this); if (myTerritoryDetailView == null) { throw new NullReferenceException(); } myTerritoryDetailView.OnCommandToMoney .Subscribe(item => CommandFaithToMoney(item.faith, item.money)) .AddTo(this); }
protected EventPodEntity(SerializationInfo info, StreamingContext context) : base(info, context) { if (SerializationHelper.Optimization != SerializationOptimization.Fast) { _eventPodRoom = (EntityCollection <EventPodRoomEntity>)info.GetValue("_eventPodRoom", typeof(EntityCollection <EventPodRoomEntity>)); _events = (EventsEntity)info.GetValue("_events", typeof(EventsEntity)); if (_events != null) { _events.AfterSave += new EventHandler(OnEntityAfterSave); } _podDetails = (PodDetailsEntity)info.GetValue("_podDetails", typeof(PodDetailsEntity)); if (_podDetails != null) { _podDetails.AfterSave += new EventHandler(OnEntityAfterSave); } _territory = (TerritoryEntity)info.GetValue("_territory", typeof(TerritoryEntity)); if (_territory != null) { _territory.AfterSave += new EventHandler(OnEntityAfterSave); } base.FixupDeserialization(FieldInfoProviderSingleton.GetInstance()); } // __LLBLGENPRO_USER_CODE_REGION_START DeserializationConstructor // __LLBLGENPRO_USER_CODE_REGION_END }
private static void SetZipCollectionForTerritoryEntity(TerritoryEntity territoryEntity, IEnumerable <ZipEntity> zipEntities) { territoryEntity.ZipCollectionViaTerritoryZip.IsReadOnly = false; territoryEntity.ZipCollectionViaTerritoryZip.Clear(); territoryEntity.ZipCollectionViaTerritoryZip.AddRange(zipEntities); }
/// <summary> /// Handles the RowCommand event of the theGrid control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.Web.UI.WebControls.GridViewCommandEventArgs"/> instance containing the event data.</param> protected void theGrid_RowCommand(object sender, GridViewCommandEventArgs e) { switch (e.CommandName) { case "EditExisting": case "ViewExisting": break; default: // apparently another command, return return; } int index = Convert.ToInt32(e.CommandArgument); TerritoryEntity selectedEntity = (TerritoryEntity)_TerritoryDS.EntityCollection[index]; StringBuilder pkFieldsAndValues = new StringBuilder(); pkFieldsAndValues.AppendFormat("&TerritoryId={0}", selectedEntity.TerritoryId); switch (e.CommandName) { case "EditExisting": Response.Redirect("~/EditExisting.aspx?EntityType=" + (int)EntityType.TerritoryEntity + pkFieldsAndValues.ToString()); break; case "ViewExisting": Response.Redirect("~/ViewExisting.aspx?EntityType=" + (int)EntityType.TerritoryEntity + pkFieldsAndValues.ToString()); break; } }
protected override void MapUniqueTerritoryFields(TerritoryEntity territoryEntity, PodTerritory territoryToMapTo) { List <long> packageIds = territoryEntity.TerritoryPackage.Select(tp => tp.PackageId).ToList(); territoryToMapTo.PackageIds = packageIds; }
public static TerritoryEntity FromDto(this Territory dto) { OnBeforeDtoToEntity(dto); var entity = new TerritoryEntity(); // Map entity properties entity.TerritoryId = dto.TerritoryId; entity.TerritoryDescription = dto.TerritoryDescription; entity.RegionId = dto.RegionId; // Map entity associations // 1:n EmployeeTerritories association if (dto.EmployeeTerritories != null && dto.EmployeeTerritories.Any()) { foreach (var relatedDto in dto.EmployeeTerritories) { entity.EmployeeTerritories.Add(relatedDto.FromDto()); } } // n:1 Region association if (dto.Region != null) { entity.Region = dto.Region.FromDto(); } OnAfterDtoToEntity(dto, entity); return(entity); }
public void MapMapsEntityHospitalPartnerOwnerIdsToHospitalPartnerTerritoryOwnerIds() { const long territoryId = 23; var expectedHospitalPartnerOwnerIds = new List <long> { 29, 645, 97 }; var territoryEntity = new TerritoryEntity(territoryId) { Type = (byte)TerritoryType.HospitalPartner }; var hospitalPartnerTerritoryEntities = new List <HospitalPartnerTerritoryEntity> { new HospitalPartnerTerritoryEntity(expectedHospitalPartnerOwnerIds[0], territoryId), new HospitalPartnerTerritoryEntity(expectedHospitalPartnerOwnerIds[1], territoryId), new HospitalPartnerTerritoryEntity(expectedHospitalPartnerOwnerIds[2], territoryId) }; territoryEntity.HospitalPartnerTerritory.AddRange(hospitalPartnerTerritoryEntities); Territory territory = _mapper.Map(territoryEntity); Assert.AreEqual(expectedHospitalPartnerOwnerIds, ((HospitalPartnerTerritory)territory).HospitalPartnerOwnerIds, "Hospital Partner Owner Ids were not mapped correctly."); }
/// <summary>Creates a new, empty TerritoryEntity object.</summary> /// <returns>A new, empty TerritoryEntity object.</returns> public override IEntity Create() { IEntity toReturn = new TerritoryEntity(); // __LLBLGENPRO_USER_CODE_REGION_START CreateNewTerritory // __LLBLGENPRO_USER_CODE_REGION_END return(toReturn); }
protected override void MapUniqueTerritoryFields(TerritoryEntity territoryEntity, HospitalPartnerTerritory territoryToMapTo) { List <long> hospitalPartnerIds = territoryEntity.HospitalPartnerTerritory. Select(hpt => hpt.HospitalPartnerId).ToList(); territoryToMapTo.HospitalPartnerOwnerIds = hospitalPartnerIds; }
public void MapSetsParentTerritoryToNullWhenEntityParentTerritoryIdIsNull() { var territoryEntity = new TerritoryEntity(); Territory territory = _territoryFactory.Map(territoryEntity); Assert.IsNull(territory.ParentTerritoryId, "Parent Territory set to non-null value."); }
protected override void MapUniqueTerritoryFields(TerritoryEntity territoryEntity, FranchiseeTerritory territoryToMapTo) { long franchiseeOwnerId = territoryEntity.FranchiseeTerritory != null ? territoryEntity.FranchiseeTerritory.OrganizationId : 0; territoryToMapTo.FranchiseeOwnerId = franchiseeOwnerId; }
/// <summary> setups the sync logic for member _territory</summary> /// <param name="relatedEntity">Instance to set as the related entity of type entityType</param> private void SetupSyncTerritory(IEntity2 relatedEntity) { if (_territory != relatedEntity) { DesetupSyncTerritory(true, true); _territory = (TerritoryEntity)relatedEntity; base.PerformSetupSyncRelatedEntity(_territory, new PropertyChangedEventHandler(OnTerritoryPropertyChanged), "Territory", TerritoryPackageEntity.Relations.TerritoryEntityUsingTerritoryId, true, new string[] { }); } }
public void CreateTerritoryEntitySetsIsActiveToTrue() { var territory = new FranchiseeTerritory(); TerritoryEntity territoryEntity = _territoryFactory.CreateTerritoryEntity(territory, DateTime.Now, DateTime.Now); Assert.IsTrue(territoryEntity.IsActive, "TerritoryEntity IsActive not set to true."); }
public long SaveTerritory(Territory territoryToSave) { TerritoryEntity territoryEntity = GetTerritoryEntity(territoryToSave); SaveTerritoryEntity(territoryEntity); UpdateTerritoryOwnerMappings(territoryEntity.TerritoryId, territoryToSave); UpdateTerritoryZipMappings(territoryEntity.TerritoryId, territoryToSave.ZipCodes); return(territoryEntity.TerritoryId); }
public void MapMapsEntityIdToTerritoryId() { const long expectedTerritoryId = 3; var territoryEntity = new TerritoryEntity(expectedTerritoryId); Territory territory = _territoryFactory.Map(territoryEntity); Assert.AreEqual(expectedTerritoryId, territory.Id, "Territory ID was not mapped correctly."); }
public void MapCreatesEmptyZipCodeListWhenEntityZipCollectionIsEmpty() { var territoryEntity = new TerritoryEntity(); Territory territory = _territoryFactory.Map(territoryEntity); Assert.IsNotNull(territory.ZipCodes, "Null zip code collection returned."); Assert.IsEmpty(territory.ZipCodes, "Non-empty zip code collection returned."); }
/// <summary> Initializes the class members</summary> protected virtual void InitClassMembers() { _organization = null; _territory = null; PerformDependencyInjection(); // __LLBLGENPRO_USER_CODE_REGION_START InitClassMembers // __LLBLGENPRO_USER_CODE_REGION_END OnInitClassMembersComplete(); }
public void MapSetsGivenTerritoryIdToEntityTerritoryId() { const long expectedTerritoryId = 3; var fakeTerritory = new FakeTerritory(expectedTerritoryId); TerritoryEntity territoryEntity = _territoryFactory.Map(fakeTerritory); Assert.AreEqual(expectedTerritoryId, territoryEntity.TerritoryId, "Territory ID was not mapped to entity correctly."); }
public void MapSetsParentTerritoryIdToNullWhenNullEntityParentTerritoryIdGiven() { var territoryEntity = new TerritoryEntity { ParentTerritoryId = null }; Territory territory = _territoryFactory.Map(territoryEntity); Assert.IsNull(territory.ParentTerritoryId, "Non-null Parent Territory ID mapped."); }
public void CreateTerritoryEntitySetsDateCreatedToGivenDateCreated() { var expectedDateCreated = new DateTime(2003, 2, 3); var territory = new FranchiseeTerritory(); TerritoryEntity territoryEntity = _territoryFactory.CreateTerritoryEntity(territory, expectedDateCreated, DateTime.Now); Assert.AreEqual(expectedDateCreated, territoryEntity.DateCreated, "DateCreated was not set on the entity correctly."); }
public void CreateTerritoryCreatesFranchiseeTerritoryWhenEntityTypeIsFranchiseeTerritory() { var territoryEntity = new TerritoryEntity { Type = (byte)TerritoryType.Franchisee }; Territory territory = _territoryFactory.CreateTerritory(territoryEntity); Assert.IsInstanceOf <FranchiseeTerritory>(territory); }
protected sealed override void MapDomainFields(TerritoryEntity entity, T domainObjectToMapTo) { domainObjectToMapTo.Id = entity.TerritoryId; domainObjectToMapTo.Name = entity.Name; domainObjectToMapTo.Description = entity.Description; domainObjectToMapTo.ZipCodes = _zipCodeMapper. MapMultiple(entity.ZipCollectionViaTerritoryZip).ToList(); domainObjectToMapTo.ParentTerritoryId = entity.ParentTerritoryId; MapUniqueTerritoryFields(entity, domainObjectToMapTo); }
public void CreateTerritoryCreatesAdvertiserTerritoryWhenEntityIsAdvertiser() { var territoryEntity = new TerritoryEntity { Type = (byte)TerritoryType.Advertiser }; Territory territory = _territoryFactory.CreateTerritory(territoryEntity); Assert.IsInstanceOf <AdvertiserTerritory>(territory, "Incorrect type of Territory created."); }
public void MapSetsParentTerritoryIdToNullIfParentTerritoryIsNull() { var fakeTerritory = new FakeTerritory { ParentTerritoryId = null }; TerritoryEntity territoryEntity = _territoryFactory.Map(fakeTerritory); Assert.IsNull(territoryEntity.ParentTerritoryId, "Parent Territory ID of entity set to non-null value."); }
private void SaveTerritoryEntity(TerritoryEntity territoryEntity) { using (var myAdapter = PersistenceLayer.GetDataAccessAdapter()) { if (!myAdapter.SaveEntity(territoryEntity)) { throw new PersistenceFailureException ("The territory could not be saved to the database."); } } }
public void CreateTerritoryCreatesHospitalPartnerTerritoryWhenEntityIsHospitalPartner() { var territoryEntity = new TerritoryEntity { Type = (byte)TerritoryType.HospitalPartner }; Territory territory = _territoryFactory.CreateTerritory(territoryEntity); Assert.IsInstanceOf <HospitalPartnerTerritory>(territory); }
public void MapMapsEntityNameToTerritoryName() { const string expectedName = "Bob's Territory"; var territoryEntity = new TerritoryEntity { Name = expectedName }; Territory territory = _territoryFactory.Map(territoryEntity); Assert.AreEqual(expectedName, territory.Name, "Territory Name was not mapped correctly."); }
public void MapMapsParentTerritoryIdToEntityParentTerritoryId() { const long expectedParentTerritoryId = 3; var fakeTerritory = new FakeTerritory { ParentTerritoryId = expectedParentTerritoryId }; TerritoryEntity territoryEntity = _territoryFactory.Map(fakeTerritory); Assert.AreEqual(expectedParentTerritoryId, territoryEntity.ParentTerritoryId, "Parent Territory ID not mapped to entity correctly."); }
public void MapMapsTerritoryTypeToEntityTerritoryType() { const TerritoryType expectedTerritoryType = TerritoryType.Pod; var fakeTerritory = new FakeTerritory { FakeTerritoryType = expectedTerritoryType }; TerritoryEntity territoryEntity = _territoryFactory.Map(fakeTerritory); Assert.AreEqual((byte)expectedTerritoryType, territoryEntity.Type, "Territory Type was not mapped to entity correctly."); }
public void Add(Territory territory) { var entity = new TerritoryEntity { Description = territory.Description, IsActive = true, }; _context.Territories.AddObject(entity); _context.SaveChanges(); territory.Id = entity.Id; }